Closed vipexv closed 1 week ago
I don't think this is an issue on our side. It might be a problem with how nvim-lspconfig searches for the root directory.
If I set the command config for svelte lsp to a non-existent path. The "not found" problem still exists even though the server is not even running.
lspconfig.svelte.setup {
cmd = { "node", "--inspect", "/path/to/language-tools/packages/language-server/bin/server.js", "--stdio" },
capabilities = lsp_capabilities,
}
And if I change the directory from [cfx]
to [cfx
. Neovim now shows an error with the "wrong config" because the language server failed to start. And it works if I remove the wrong config.
Generally speaking i'm really new to Neovim still and have no idea how allot of customization works, this is my LSP Config tho, i'm really unsure as to what the issue might be because i don't really remember specifically configuring the svelte LSP, and i installed it through Mason.
You can also find my whole Neovim config here
local telescopeBuiltIn = require("telescope.builtin")
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("user_lsp_attach", { clear = true }),
callback = function(event)
local opts = { buffer = event.buf }
vim.keymap.set("n", "gd", function()
telescopeBuiltIn.lsp_definitions()
end, opts)
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover()
end, opts)
vim.keymap.set("n", "<leader>vws", function()
vim.lsp.buf.workspace_symbol()
end, opts)
vim.keymap.set("n", "<leader>vd", function()
vim.diagnostic.open_float()
end, opts)
vim.keymap.set("n", "[d", function()
vim.diagnostic.goto_next()
end, opts)
vim.keymap.set("n", "]d", function()
vim.diagnostic.goto_prev()
end, opts)
vim.keymap.set("n", "<leader>vca", function()
vim.lsp.buf.code_action()
end, opts)
vim.keymap.set("n", "<leader>fr", function()
telescopeBuiltIn.lsp_references()
end, opts)
vim.keymap.set("n", "<leader>vrn", function()
vim.lsp.buf.rename()
end, opts)
vim.keymap.set("i", "<C-h>", function()
vim.lsp.buf.signature_help()
end, opts)
vim.keymap.set("n", "<leader>ve", function()
vim.diagnostic.setloclist()
end, opts)
end,
})
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
require("mason").setup({})
require("mason-lspconfig").setup({
ensure_installed = { "ts_ls" },
handlers = {
function(server_name)
require("lspconfig")[server_name].setup({
capabilities = lsp_capabilities,
})
end,
lua_ls = function()
require("lspconfig").lua_ls.setup({
capabilities = lsp_capabilities,
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
vim.env.VIMRUNTIME,
[vim.fn.expand(vim.fn.stdpath("config") .. "/fivem-library/")] = true,
},
},
},
},
{ "hrsh7th/cmp-buffer" },
})
end,
},
})
local cmp = require("cmp")
local cmp_select = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
}, {
{ name = "buffer" },
}),
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.confirm({ select = true }),
["<C-y>"] = cmp.mapping.complete(),
}),
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
})
From my understanding, neovim/vim doesn't open a directory like most text editor/IDE. However, root directories are required for a language server. So the root directory search is a way to emulate opening a directory. nvim-lspconfig
maintains a list of default configs for different language servers depending on the different project structures. The problem is likely how they turn the file path into a regex or glob pattern. You can try opening an issue on nvim-lspconfig
Weird, i'll see what i can do, because generally any other files/lsps work perfectly fine, confusing bug, could also be neovim honestly, thank you tho!
Describe the bug
So i'm using neovim development build due to the fact that it allows me to use Netrw to access directories that have brackets around them, so everything works fine, in React/Lua and every other language server, but in svelte it just throws an error saying not found, more info will be found below.
Reproduction
Try to access a directory that's wrapped with square brackets, and the Lsp doesn't start up.
Expected behaviour
The Lsp is expected to start and work normally.
System Info
Which package is the issue about?
svelte-language-server
Additional Information, eg. Screenshots
==============================================================================