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-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.
- Neovim ≥ 0.10 (uses
vim.uvpipe transport) - A dsh-TUI build that includes the injection channel
(
src/dsh-adapter/inject-channel.ts). This is not yet in upstreamccch1mneyyy/dsh-TUI; it lives on the fork below, on thefeat/inject-channelbranch (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.jsonIf 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.
{
"lidudutju/dsh.nvim",
---@type dsh.Opts
opts = {}, -- or set vim.g.dsh_opts; see Configuration
}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).
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,
}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 specThen 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 customDATA_DIR), pointinject_dirat that location'sinject/subdirectory.
---@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
}| 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" })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):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).
:DshSendBuffersays "No running dsh-TUI session found" — no session is live, or none matches. Confirm~/.dsh-tui/inject/servers.jsonlists a session, and that Neovim's cwd overlaps that session'scwd.- Nothing appears in the TUI prompt — your dsh-TUI build lacks the
injection channel. Rebuild from the
feat/inject-channelbranch (see Setting up dsh-TUI). - The buffer reference looks wrong on macOS — dsh.nvim resolves symlinks
(
/private/varvs/var) so the@pathstays 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.
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.
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.
