dotfiles
1

Configure Feed

Select the types of activity you want to include in your feed.

Fix opening in referred code in new nvim window

From Claude:

Root cause (two independent bugs):
1. Ghostty eats the +cmd argument. Ghostty's -e flag scans every token
for a leading + (its own +action syntax, e.g. +new-window) and
silently drops any it doesn't recognize — including nvim's +call
cursor(...). I confirmed this by launching ghostty and dumping the
child's actual argv: +call cursor(5,10) vanished completely, leaving
only nvim and the filepath. Since the jump command never ran, nvim's
own BufReadPost autocmd (nvim/init.lua:231-240, restores cursor to
the last-visited " mark) was the only thing setting the cursor —
explaining exactly what you saw: file opens fine, cursor lands
wherever you last left off in that file.
2. Off-by-one indexing. LSP positions are 0-indexed; Vim's cursor() is
1-indexed. This was real but secondary — masked by bug #1 since the
whole command was being dropped anyway.

Fix (nvim/init.lua): added a shared open_in_new_window(filepath, line,
col) helper that shell-quotes the +cmd and filepath into a single string
and runs it via ghostty -e sh -c '<cmd>' — so the +-prefixed token is
buried inside one argv element instead of being its own, and survives
ghostty's parser. Both gd and the quickfix <CR> handler now use it.

Juan Nunez-Iglesias (Jul 8, 2026, 9:02 PM +0200) 041adb0c f2d93bfd

+19 -12
+19 -12
nvim/init.lua
··· 59 59 }) 60 60 vim.lsp.enable('basedpyright') 61 61 62 + -- Ghostty's `-e` strips any argument starting with `+` (it treats them as 63 + -- its own `+action` CLI syntax), silently dropping nvim's `+cmd` args. Route 64 + -- through `sh -c` so the `+cmd` is buried inside one shell-quoted string 65 + -- instead of being its own top-level argv token. 66 + local function shellquote(s) 67 + return "'" .. s:gsub("'", "'\\''") .. "'" 68 + end 69 + 70 + local function open_in_new_window(filepath, line, col) 71 + local cmd = string.format('nvim %s %s', 72 + shellquote(string.format('+call cursor(%d,%d)', line, col)), 73 + shellquote(filepath)) 74 + vim.fn.jobstart({ 'ghostty', '-e', 'sh', '-c', cmd }) 75 + end 76 + 62 77 vim.api.nvim_create_autocmd("LspAttach", { 63 78 callback = function(args) 64 79 local bufnr = args.buf ··· 82 97 local uri = location.uri or location.targetUri 83 98 local range = location.range or location.targetSelectionRange 84 99 local filepath = vim.uri_to_fname(uri) 85 - local line = range.start.line 86 - local col = range.start.character 87 - vim.fn.jobstart({ 88 - 'ghostty', '-e', 'nvim', 89 - string.format('+call cursor(%d,%d)', line, col), 90 - filepath 91 - }) 100 + local line = range.start.line + 1 101 + local col = range.start.character + 1 102 + open_in_new_window(filepath, line, col) 92 103 end) 93 104 end, { buffer = bufnr, desc = "Go to definition (new window)" }) 94 105 ··· 116 127 local col = qf_item.col 117 128 118 129 vim.cmd('cclose') 119 - vim.fn.jobstart({ 120 - 'ghostty', '-e', 'nvim', 121 - string.format('+call cursor(%d,%d)', line, col), 122 - filepath 123 - }) 130 + open_in_new_window(filepath, line, col) 124 131 end, { buffer = args.buf, desc = "Open reference in new window", nowait = true }) 125 132 end, 126 133 })