fix(nvim): starting lsp requires an attached buffer#234
fix(nvim): starting lsp requires an attached buffer#234rodionlim wants to merge 1 commit intoDavidyz:mainfrom rodionlim:fix/on_setup_lsp_throws_error
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #234 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 24 24
Lines 1715 1715
=======================================
Hits 1711 1711
Misses 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Would it help if you just set filetypes to |
|
I tried lazy loading vectorcode by adding {
"Davidyz/VectorCode",
version = "*",
build = "uv tool upgrade vectorcode",
opts = {
on_setup = { update = false, lsp = true },
async_backend = "lsp",
},
cmd = "VectorCode",
} |
|
The I suspect that something else is loading vectorcode earlier than necessary. For example, if you're using the lualine component, it might load vectorcode too early (before a buffer has been created). If that's the case, there's nothing I can do from within the plugin. I'm using the following wrapper component in my personal config to avoid vectorcode being triggered by lualine: local vectorcode_component = {
function()
return require("vectorcode.integrations").lualine()[1]()
end,
cond = function()
if package.loaded["vectorcode"] == nil then
return false
else
return require("vectorcode.integrations").lualine().cond()
end
end,
}Also, have you tried setting the |
|
Ah, thank you for that. You are right, ---@module "vectorcode"
opts = {
extensions = {
vectorcode = {
---@type VectorCode.CodeCompanion.ExtensionOpts
opts = {
tool_group = {
-- this will register a tool group called `@vectorcode_toolbox` that contains all 3 tools
enabled = true,
extras = {},
collapse = false, -- whether the individual tools should be shown in the chat
},
},
},
}
} |
Is codecompanion not lazy loaded then? From what you've said, it feels like you can fix this issue by lazy loading codecompanion (via the |
|
Ah, that works now, my bad. This stems from my poor understanding on how lazy loading works in neovim. Thanks a lot for your help @Davidyz. |
|
In fact, if all you want is to make sure the LSP server is started earlier-ish than the tool call in a codecompanion chat buffer to avoid that waiting, you can try setting the |

Constantly getting the following error when starting vectorcode-server on setup due to starting an lsp without an attached buffer. This also causes neovim to send
shutdownandexitrequests to the lsp server, and as a side effect, sending back a client id of nil.Failed to start vectorcode-server due some errorRaising a PR to create a temp buffer during setup phase so that
vim.lsp.startcorrectly proceeds and returns with status 0.