-
Right now with
The reason is, I assume, is this code in my config: local on_attach = function(client, bufnr)
if client.resolved_capabilities.document_highlight then
vim.api.nvim_create_autocmd("CursorHold", {
callback = vim.lsp.buf.document_highlight,
desc = "Highlight lsp references",
})
vim.api.nvim_create_autocmd("CursorHoldI", {
callback = vim.lsp.buf.document_highlight,
desc = "Highlight lsp references",
})
vim.api.nvim_create_autocmd("CursorMoved", {
callback = vim.lsp.buf.clear_references,
desc = "Clear references",
})
vim.api.nvim_create_autocmd("CursorMovedI", {
callback = vim.lsp.buf.clear_references,
desc = "Clear references",
})
end
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
local opts = { silent = true }
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
end and the fact that null-ls broadcasts all capabilities as mentioned here: null-ls.nvim/lua/null-ls/client.lua Line 47 in b66946a This happens only if I have another buffer with null-ls attached open. For example a *.go file. I can disable this builtin for certain filetypes as mentioned here #297 but this seems like a bad solution. Is there anyway to just "unresolve" Looks like it should be possible but I can't figure out how: null-ls.nvim/lua/null-ls/client.lua Line 49 in b66946a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The meaning of the comment is that null-ls broadcasts capabilities for the methods it supports, and I can't replicate your issue, but you could try changing |
Beta Was this translation helpful? Give feedback.
-
That is because you create autocmd for all buffers For LSP thing, you have to specify which buffer (which is why we have access to You can try to convert your local on_attach = function(client, bufnr)
local support = client.supports_method
local augroup = vim.api.nvim_create_augroup
local autocmd = vim.api.nvim_create_autocmd
if support("textDocument/documentHighlight") then
-- It is always recommended to put autocmd in a augroup
local highlight_on_cursor = augroup("HighlightOnCursor", { clear = false })
autocmd({ "CursorHold", "CursorHoldI" }, {
callback = vim.lsp.buf.document_highlight,
buffer = bufnr,
group = highlight_on_cursor,
})
autocmd({ "CursorMoved", "CursorMovedI" }, {
callback = vim.lsp.buf.clear_references,
buffer = bufnr,
group = highlight_on_cursor,
})
end
end |
Beta Was this translation helpful? Give feedback.
That is because you create autocmd for all buffers
For LSP thing, you have to specify which buffer (which is why we have access to
bufnr
inon_attach
) you want to add LSP-specific features (keymap, autocmd, user-command, etc.)You can try to convert your
on_attach
like this