Skip to content
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

🐛 BUG: Updates in typescript types are only recognized after restarting the LSP #742

Closed
t-ober opened this issue Dec 27, 2023 · 7 comments
Labels
needs response Need a response from the original author

Comments

@t-ober
Copy link

t-ober commented Dec 27, 2023

Describe the Bug

I am using the astro language server with lspconfig in neovim.

Whenever I am updating a typescript type, e.g. renaming a variable, this change does not get picked up by the language server within astro files. The change is only recognized when I restart the LSP.

There seems to be this similar issue: #489
It does not seem to be actually resolved.

I can see that a didChangeWatchedFiles is being sent:

[DEBUG][2023-12-27 09:58:21] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "workspace/didChangeWatchedFiles",  params = {    changes = { {        type = 1,        uri = "file:///Users/thomas/coding/js/immo-patt/src/interfaces/interface.ts"      } }  }

But it does not seem to be picked up by the language server.

Does anybody have anyidea

Steps to Reproduce

  1. Set up neovim with lspconfig and the astro language server
  2. Import a typescript type in an astro file
  3. Change a type definition in a typescript file
  4. Notice that the change does not get reflected within the astro file until the language server is restarted
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 27, 2023
@Princesseuh
Copy link
Member

Since this works for VS Code, https://github.com/yaegassy/coc-astro and there's many people using the language-server in Neovim, I can only assume that this is a configuration issue in Neovim, but I honestly don't know. Thank you for reporting the issue, we'll take a look as soon as possible.

@Odas0R
Copy link

Odas0R commented Dec 27, 2023

I've tried this right now and it's working on my end.

#489 (comment)

Edit: I'm using nvim-lspconfig only.

Screencast.from.12-27-2023.05.42.40.PM.webm

@Princesseuh Princesseuh added needs response Need a response from the original author and removed needs triage Issue needs to be triaged labels Dec 27, 2023
@t-ober
Copy link
Author

t-ober commented Dec 30, 2023

Thanks both of you for your feedback!
This then seems to be a layer 8 problem. Since I am new to the whole nvim thing I admittedly barely know what I am doing.

I made sure to update and reinstall the astro-language-server also the problem does not come up when importing type definitions in .ts files.

@Odas0R : Would you mind sharing your lspconfig setup with me ? I still can't quite get it to work.

@Odas0R
Copy link

Odas0R commented Dec 30, 2023

Thanks both of you for your feedback! This then seems to be a layer 8 problem. Since I am new to the whole nvim thing I admittedly barely know what I am doing.

I made sure to update and reinstall the astro-language-server also the problem does not come up when importing type definitions in .ts files.

@Odas0R : Would you mind sharing your lspconfig setup with me ? I still can't quite get it to work.

Here: https://github.com/Odas0R/dot/blob/main/nvim/lua/odas0r/plugin/lsp.lua

Hope it helps! It's pretty basic

@Princesseuh
Copy link
Member

Closing since this seems to be a setup issue. Many people are using Astro in Neovim just fine.

@Princesseuh Princesseuh closed this as not planned Won't fix, can't repro, duplicate, stale Feb 1, 2024
@emonadeo
Copy link

emonadeo commented Feb 6, 2024

I have the same issue and I have been stuck on it for days and it's driving me nuts. What is the gotcha here that I am missing? I can't get it to work on either Neovim 0.9 or 0.10-dev.

  • @astrojs/language-server v2.6.2
  • astro v4.3.2
  • typescript v5.3.3
  • typescript-language-server v4.3.2

Even if I get rid of my entire config and only include nvim-lspconfig, file changes don't get recognized until I do :LspRestart:

(Using lazy.nvim)

{
	"neovim/nvim-lspconfig",
	config = function()
		require('lspconfig').astro.setup({
			capabilities = {
				workspace = {
					didChangeWatchedFiles = {
						dynamicRegistration = true,
					},
				},
			},
		})
		require('lspconfig').tsserver.setup({
			capabilities = {
				workspace = {
					didChangeWatchedFiles = {
						dynamicRegistration = true,
					},
				},
			},
		})
	end
},

@emonadeo
Copy link

emonadeo commented Feb 9, 2024

With @astrojs/language-server 2.7 upgrading internally to Volar 2 fixed it! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs response Need a response from the original author
Projects
None yet
Development

No branches or pull requests

4 participants