Skip to content
lidudutjuPublic

About

Neovim plugin: carry your buffer into a running dsh-TUI session (the dsh-TUI counterpart of opencode.nvim)

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dsh.nvim

Neovim 🤝 dsh-TUI — carry your buffer into a running dsh-TUI session, in the flow you already know.

Inspired by opencode.nvim: stay in your editor, keep dsh-TUI running in a terminal, and push context across with a keystroke.

dsh.nvim in action

How it works

dsh-TUI exposes a per-session local injection socket: a Unix domain socket at ~/.dsh-tui/inject/<sessionId>.sock (a named pipe on Windows), plus a discovery file ~/.dsh-tui/inject/servers.json listing every live session (pid, sessionId, cwd, socketPath).

dsh.nvim reads that discovery file, picks the session whose working directory overlaps Neovim's (prompting when several match — like opencode.nvim's cwd matching), and sends newline-delimited JSON over the socket:

{ "type": "prompt.append",   "text": "@src/foo.lua " }
{ "type": "command.execute", "command": "prompt.submit" }

The TUI appends the text to its prompt input and submits it as a turn. A trailing space (OpenCode's convention) leaves the prompt open instead of submitting.

Requirements

  • Neovim ≥ 0.10 (uses vim.uv pipe transport)
  • A dsh-TUI build that includes the injection channel (src/dsh-adapter/inject-channel.ts). This is not yet in upstream ccch1mneyyy/dsh-TUI; it lives on the fork below, on the feat/inject-channel branch (upstream PR ccch1mneyyy/dsh-TUI#428).

Verify your dsh-TUI has it: start a session, then in another terminal run

cat ~/.dsh-tui/inject/servers.json

If you see a record with your session's cwd and socketPath, the channel is live. If the file is absent, your dsh-TUI build predates the channel — see Setting up dsh-TUI.

Install

lazy.nvim:

{
  "lidudutju/dsh.nvim",
  ---@type dsh.Opts
  opts = {}, -- or set vim.g.dsh_opts; see Configuration
}

mini.deps:

require("mini.deps").add({ source = "lidudutju/dsh.nvim" })

vim.pack (Neovim 0.12+):

vim.pack.add({ { src = "https://github.com/lidudutju/dsh.nvim" } })

No setup() call is required — plugin/dsh.lua registers the commands and default keymaps on load. Configure through vim.g.dsh_opts (see below).

Local development

Point your plugin manager at a local clone instead of GitHub. With lazy.nvim:

{
  dir = "/path/to/dsh.nvim",
  name = "dsh.nvim",
  dev = true,
  event = "VeryLazy",
  config = function()
    vim.g.dsh_opts = {}
  end,
}

Setting up dsh-TUI

dsh.nvim only talks to a dsh-TUI that has the injection channel. Until the channel lands upstream, build it from the fork:

git clone https://github.com/lidudutju/dsh-TUI.git
cd dsh-TUI
git checkout feat/inject-channel
git submodule update --init          # vendored dsh-std + ecosystem spec

Then build and run it however you normally launch dsh-TUI. The channel opens automatically for every session; nothing to configure on the dsh-TUI side. Once a session is running, ~/.dsh-tui/inject/servers.json lists it and dsh.nvim can find it.

The socket path defaults to ~/.dsh-tui/inject/. If your dsh-TUI writes its data elsewhere (e.g. a custom DATA_DIR), point inject_dir at that location's inject/ subdirectory.

Configuration

---@type dsh.Opts
vim.g.dsh_opts = {
  inject_dir = nil,        -- override dsh-TUI's inject dir (default ~/.dsh-tui/inject)
  auto_submit = true,      -- submit after append, unless the text ends in a space
  prompt_prefix = "",      -- text prepended to every send, e.g. "explain: "
  default_keymaps = true,  -- install the <leader>d* keymaps below
}

Commands & keymaps

Command Default keymap Action
:DshSendBuffer <leader>db Send the current buffer as an @file reference
:DshAskBuffer <leader>da Prefill the buffer @reference, edit, then send
:DshAsk [text] <leader>dp Prompt for text and send it

<leader> is \ by default (space under LazyVim and most distros). Set default_keymaps = false and bind your own:

vim.g.dsh_opts = { default_keymaps = false }
vim.keymap.set("n", "<C-a>", function()
  require("dsh").send_buffer()
end, { desc = "dsh: send buffer" })

API

require("dsh").send_buffer()   -- current buffer as @file, submitted
require("dsh").ask_buffer()    -- prefill @reference, edit in a prompt, send
require("dsh").ask(default)    -- prompt for text (prefilled), send
require("dsh").prompt(text)    -- send text (a trailing space suppresses submit)

Health

:checkhealth dsh

Reports the injection directory, whether libuv pipe transport is available, and the dsh-TUI sessions discovered (flagging any whose cwd matches Neovim's).

Troubleshooting

  • :DshSendBuffer says "No running dsh-TUI session found" — no session is live, or none matches. Confirm ~/.dsh-tui/inject/servers.json lists a session, and that Neovim's cwd overlaps that session's cwd.
  • Nothing appears in the TUI prompt — your dsh-TUI build lacks the injection channel. Rebuild from the feat/inject-channel branch (see Setting up dsh-TUI).
  • The buffer reference looks wrong on macOS — dsh.nvim resolves symlinks (/private/var vs /var) so the @path stays relative to the session cwd; file a report if you still see an absolute path for an in-project file.
  • Multiple sessions matched — dsh.nvim prompts via vim.ui.select; the picker shows each session's cwd and a short id.

How it relates to opencode.nvim

opencode.nvim drives OpenCode's HTTP TUI server (POST /tui/publish, tui.prompt.append / tui.command.execute). dsh.nvim mirrors that model but over dsh-TUI's local injection socket instead of an HTTP port — no port allocation, no auth surface, and the endpoint is torn down with the session.

Status

The first release carries the current buffer as an @file reference. Selection ranges, cursor position, and diagnostics are natural next steps — the discovery + socket transport already supports arbitrary appended text.

License

MIT

About

Neovim plugin: carry your buffer into a running dsh-TUI session (the dsh-TUI counterpart of opencode.nvim)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages