language-tools: svelte-language-server watcher doesn't work in neovim lspconfig
I’m in the same problem with my sveltekit project.
I’m using typescript-svelte-plugin
.
Although typescript files (like +page.server.ts) works realtime, diagnostics of .svelte
file does not updated.
I’m configuring root_pattern( {"package.json", "tsconfig.json", "tsconfig.jsonc", "node_modules"})
for svelte language server
https://user-images.githubusercontent.com/1560508/237040552-0a1be152-0c2b-45ab-b98c-3e927ffeae34.mov
_Originally posted by @ryoppippi in https://github.com/sveltejs/language-tools/issues/1415#issuecomment-1539681042_
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 35 (9 by maintainers)
Links to this issue
Commits related to this issue
- (fix) move fs watcher config to language-server (#2009) #2008 #1613 — committed to sveltejs/language-tools by jasonlyu123 a year ago
Actually, you can just manually change the client capability in 0.9.x to have
dynamicRegistration = true
If this still doesn’t work, please prepare a reproduction and report to neovim. Also, to reiterate,
$/onDidChangeTsOrJsFile
is not a substitution for file watcher, They both exist for a reason.Okay, this is a truly hacky things, but I solved this problem with this setting
For people for whom the hack is still not working it might be because you are using
ctx.file
which when using telescope for example will be a relative path and not an absolute path. You can usectx.match
instead, and it fixed it for me.Make sure you include:
inside the 2nd param for
nvim_create_autocmd
function. Otherwise, new autocmd is created on every new buffer svelte lsp get attached to.Thanks everyone for all the information. I got mine working by adding this into my
on_attach()
function:I’m running
For anyone still struggling, I used following configuration in Astrovim and it worked
We can update @ryoppippi’s snippet to work without requiring the file to be saved to disk, replicating the behavior in the svelte-vscode extension. It would enable us to do the following:
foo.ts
importsMyType
frombar.svelte
.MyType
infoo.ts
.foo.ts
.bar.svelte
is now aware of the latest changes made in step 2.Some things I’m not sure of:
In the original svelte-vscode implementation, the
changes.range
property is defined. However, I’m unsure as to how to define it in nvim. Nevertheless, this still works (maybe at the cost of some performance?) because “if only a text is provided it is considered to be the full content of the document.” (source).What is the best autocmd event(s) to use to balance performance and convenience. TBH, I’m not sure if we need to worry ourselves with performance at this point. I’m only mentioning this point due to the note in
TextChanged
’s description.svelte-language-server: v0.16.1
@jasonlyu123 i install the last version but not working and fixed using example of @ryoppippi