diff options
| author | Igor Lacerda <igorlfs@ufmg.br> | 2025-06-13 05:05:59 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-13 01:05:59 -0700 |
| commit | c36916fff8beaba86ca40cf788b8a9439502a7bc (patch) | |
| tree | bce6445ce1839ec0085466ee2213850c9a6edd0f /lsp/svelte.lua | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-c36916fff8beaba86ca40cf788b8a9439502a7bc.tar nvim-lspconfig-c36916fff8beaba86ca40cf788b8a9439502a7bc.tar.gz nvim-lspconfig-c36916fff8beaba86ca40cf788b8a9439502a7bc.tar.bz2 nvim-lspconfig-c36916fff8beaba86ca40cf788b8a9439502a7bc.tar.lz nvim-lspconfig-c36916fff8beaba86ca40cf788b8a9439502a7bc.tar.xz nvim-lspconfig-c36916fff8beaba86ca40cf788b8a9439502a7bc.tar.zst nvim-lspconfig-c36916fff8beaba86ca40cf788b8a9439502a7bc.zip | |
fix(svelte): only attach to existing files #3899
Diffstat (limited to 'lsp/svelte.lua')
| -rw-r--r-- | lsp/svelte.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lsp/svelte.lua b/lsp/svelte.lua index 98fde15f..170c1d64 100644 --- a/lsp/svelte.lua +++ b/lsp/svelte.lua @@ -12,7 +12,14 @@ return { cmd = { 'svelteserver', '--stdio' }, filetypes = { 'svelte' }, - root_markers = { 'package.json', '.git' }, + root_dir = function(bufnr, on_dir) + local root_files = { 'package.json', '.git' } + local fname = vim.api.nvim_buf_get_name(bufnr) + -- Svelte LSP only supports file:// schema. https://github.com/sveltejs/language-tools/issues/2777 + if vim.uv.fs_stat(fname) ~= nil then + on_dir(vim.fs.dirname(vim.fs.find(root_files, { path = fname, upward = true })[1])) + end + end, on_attach = function(client, bufnr) vim.api.nvim_buf_create_user_command(bufnr, 'LspMigrateToSvelte5', function() client:exec_cmd({ |
