Comments (7)
there already provide a min test file https://github.com/neovim/nvim-lspconfig/blob/master/test/minimal_init.lua you can try it :) no worry
from nvim-lspconfig.
I am getting the exact same error on :LspRestart
. Was about to post the same thing.
from nvim-lspconfig.
emm could you provide a min config and reproduce step i just give it a try no error through.
from nvim-lspconfig.
@glepnir Yes. My bad. I can set a note to provide a minimal start point tonight when I get home from work.
from nvim-lspconfig.
I tried with the minimal config above and did not see the error on :LspRestart
. I experimented with my lsp-config setup and found that when I removed the onAttach autocommand it did not give me the error. But with the on attach autocommand it did.
So this config gave the error:
return {
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = { "hrsh7th/cmp-nvim-lsp" },
config = function()
local lspconfig = require("lspconfig")
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("Lsp_Custom_Attach", {}),
callback = function(_, bufnr)
local opts = { buffer = bufnr }
vim.keymap.set("n", "gr", ":Telescope lsp_references<CR>", opts)
vim.keymap.set("n", "gd", ":Telescope lsp_definitions<CR>", opts)
vim.keymap.set("n", "gi", ":Telescope lsp_implementations<CR>", opts)
vim.keymap.set("n", "gt", ":Telescope lsp_type_definitions<CR>", opts)
vim.keymap.set("n", "<Leader>a", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<Leader>d", ":Telescope diagnostics bufnr=0<CR>", opts)
vim.keymap.set("n", "<Leader>s", ":Telescope lsp_document_symbols<CR>", opts)
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
local virtual_text_enabled = false
vim.keymap.set("n", "<Leader>td", function()
virtual_text_enabled = not virtual_text_enabled
vim.diagnostic.config({
virtual_text = virtual_text_enabled,
})
end, opts)
vim.keymap.set("n", "<Leader>th", function()
vim.lsp.inlay_hint.enable(0, not vim.lsp.inlay_hint.is_enabled())
end, opts)
end,
})
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
require("lspconfig.ui.windows").default_options = { border = "rounded" }
vim.diagnostic.config({
float = { border = "rounded" },
severity_sort = true,
update_in_insert = true,
virtual_text = false,
})
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
vim.lsp.handlers["textDocument/signatureHelp"] =
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
--------------- SERVER CONFIGURATIONS ---------------
local capabilities = require("cmp_nvim_lsp").default_capabilities()
lspconfig.cssls.setup({ capabilities = capabilities })
lspconfig.html.setup({ capabilities = capabilities })
lspconfig.hls.setup({
capabilities = capabilities,
settings = {
haskell = {
formattingProvider = "fourmolu",
},
},
})
lspconfig.jsonls.setup({ capabilities = capabilities })
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = { globals = { "hs", "vim" } },
},
},
})
lspconfig.pyright.setup({ capabilities = capabilities })
lspconfig.rust_analyzer.setup({ capabilities = capabilities })
lspconfig.tsserver.setup({ capabilities = capabilities })
end,
}
And this one worked fine:
return {
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = { "hrsh7th/cmp-nvim-lsp" },
config = function()
local lspconfig = require("lspconfig")
local on_attach = function(_, bufnr)
local opts = { buffer = bufnr }
vim.keymap.set("n", "gr", ":Telescope lsp_references<CR>", opts)
vim.keymap.set("n", "gd", ":Telescope lsp_definitions<CR>", opts)
vim.keymap.set("n", "gi", ":Telescope lsp_implementations<CR>", opts)
vim.keymap.set("n", "gt", ":Telescope lsp_type_definitions<CR>", opts)
vim.keymap.set("n", "<Leader>a", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<Leader>d", ":Telescope diagnostics bufnr=0<CR>", opts)
vim.keymap.set("n", "<Leader>s", ":Telescope lsp_document_symbols<CR>", opts)
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
local virtual_text_enabled = false
vim.keymap.set("n", "<Leader>td", function()
virtual_text_enabled = not virtual_text_enabled
vim.diagnostic.config({
virtual_text = virtual_text_enabled,
})
end, opts)
vim.keymap.set("n", "<Leader>th", function()
vim.lsp.inlay_hint.enable(0, not vim.lsp.inlay_hint.is_enabled())
end, opts)
end
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
require("lspconfig.ui.windows").default_options = { border = "rounded" }
vim.diagnostic.config({
float = { border = "rounded" },
severity_sort = true,
update_in_insert = true,
virtual_text = false,
})
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
vim.lsp.handlers["textDocument/signatureHelp"] =
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
--------------- SERVER CONFIGURATIONS ---------------
local capabilities = require("cmp_nvim_lsp").default_capabilities()
lspconfig.cssls.setup({ capabilities = capabilities, on_attach = on_attach })
lspconfig.html.setup({ capabilities = capabilities, on_attach = on_attach })
lspconfig.hls.setup({
capabilities = capabilities,
on_attach = on_attach,
settings = {
haskell = {
formattingProvider = "fourmolu",
},
},
})
lspconfig.jsonls.setup({ capabilities = capabilities, on_attach = on_attach })
lspconfig.lua_ls.setup({
capabilities = capabilities,
on_attach = on_attach,
settings = {
Lua = {
diagnostics = { globals = { "hs", "vim" } },
},
},
})
lspconfig.pyright.setup({ capabilities = capabilities, on_attach = on_attach })
lspconfig.rust_analyzer.setup({ capabilities = capabilities, on_attach = on_attach })
lspconfig.tsserver.setup({ capabilities = capabilities, on_attach = on_attach })
end,
}
from nvim-lspconfig.
@ZacharyRizer hmm that's odd I'll have to experiment as well because I'm doing the method you are now doing that doesn't give you there. My config has never used the LspAttach
method for setting up my lsps.
from nvim-lspconfig.
@glepnir I was also went through and re-wrote my LSP setup and that error was gone, unfortunately I still couldn't figure out why. So I'm just going to mark this as closed since for both of our cases it seemed to be related to how we were setting it up.
from nvim-lspconfig.
Related Issues (20)
- Custom command name may not conform user command naming rules HOT 8
- Outdated rockspec HOT 2
- Can't use primary constructors with C# LSP (csharp_ls) HOT 1
- Broken link - volar HOT 1
- Handlebars templating file support HOT 1
- Can't pass bool value to `diagnostics.signs` to disable diagnostics signs HOT 2
- pylsp + flake8 not working HOT 1
- `LspRestart` doesn't attach LSP again (regression in nightly) HOT 5
- ruff language server is not turned off after quit HOT 12
- ltex language server didn't let me change the language HOT 2
- Problem with jdtls HOT 1
- [Feature request]: Exclude pattern option HOT 3
- ESLint stops functioning after updating `vscode-langservers-extracted` to 4.10.0 HOT 9
- Eslint LSP Does Not Display Errors and Warnings on v4.9.0 or after HOT 2
- LspInfo not show border HOT 6
- `vim.api.nvim_list_bufs()` seems to be affected after the update HOT 4
- luarocks package is outdated again HOT 1
- possibly unintuitive lua_ls root_dir detection logic
- LspInfo reports `Running in single file mode` when current buffer is not in `root_dir` HOT 4
- attempt to call method 'flatten' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-lspconfig.