Skip to content

fix(svelte): only attach to existing files #3899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lsp/svelte.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down