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

astro-ls does not update changes from external .ts files in the current workspace #2467

Closed
Odas0R opened this issue Feb 16, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@Odas0R
Copy link

Odas0R commented Feb 16, 2023

Description

I've been trying to identify the issue but no luck. When I modify a type on e.g foo.ts that change is not immediately updated on the astro lsp server, both tsserver and astro-ls are not in sync here and it affects the DX :(

Neovim version

NVIM v0.9.0-dev-77-gf175ca9f7

Nvim-lspconfig version

649137c

Operating system and version

Linux pop-os 6.0.12-76060006-generic

Affected language servers

astro-ls

Steps to reproduce

  1. npm create astro@latest
  2. create a foo.ts with
export const foo = () => {
  return {
    param: "1" // change to 1 then.
  }
}
  1. import foo.ts it on a .astro file
  2. change the foo() return value and check if the lsp updates

Actual behavior

My types are NOT updated on .astro files when I modify them.

Expected behavior

My types are updated on .astro files when I modify them.

Minimal config

-

LSP log

@Odas0R Odas0R added the bug Something isn't working label Feb 16, 2023
@glepnir
Copy link
Member

glepnir commented Feb 16, 2023

need this pr neovim/neovim#21293 i think

@Odas0R
Copy link
Author

Odas0R commented Feb 16, 2023

need this pr neovim/neovim#21293 i think

Hummmmmmmm, nice. Makes sense, I tried to achieve that, but no luck. Can you point me in a direction for a possible fix?

@glepnir
Copy link
Member

glepnir commented Feb 18, 2023

currently no good ways until that pr merge. only way is when you do edit in that file restart server. like do it in a bufwritepost callback.

@glepnir glepnir closed this as completed Feb 18, 2023
@Odas0R
Copy link
Author

Odas0R commented Mar 5, 2023

I've installed the newer neovim version where the didChangeWatchedFiles was merged. I'm currently trying to:

local workspace_capabilities = {
  workspace = {
    didChangeWatchedFiles = {
      dynamicRegistration = true,
    },
  },
}

-- Inject lsp thingy into nvim-cmp
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
capabilities = vim.tbl_deep_extend("keep", capabilities, workspace_capabilities)

require("lspconfig").astro.setup({
  on_attach = on_attach,
  capabilities = capabilities,
  flags = flags,
})

Still it does not work? @glepnir @nojnhuh

Anything I'm missing? Or is there anything I can do?

@nojnhuh
Copy link

nojnhuh commented Mar 5, 2023

@Odas0R The config you have looks like it should work at first glance. The only difference I notice with mine is that in my vim.tbl_deep_extend, I call it with "keep" and the cmp capabilities listed after my didChangeWatchedFiles override table:

local default_caps = {
  workspace = {
    didChangeWatchedFiles = {
      dynamicRegistration = true,
    },
  },
}

capabilities = vim.tbl_deep_extend(
  "keep",
  default_caps,
  require("cmp_nvim_lsp").default_capabilities()
)

I would check the following in Neovim's LSP log with the verbosity turned up to at least DEBUG:

  1. The client capability is set as expected in the initialize client call.
  2. The server sends a client/registerCapability request for the workspace/didChangeWatchedFiles method.
  3. Creating/changing/deleting a file you expect to match any of the watchers from the register request triggers a workspace/didChangeWatchedFiles notification sent to the server.

From a quick look at the source code for Astro, I can see where it consumes the notifications, but I don't see where it sends the request to register the capability.

@Odas0R
Copy link
Author

Odas0R commented Mar 5, 2023

@Odas0R The config you have looks like it should work at first glance. The only difference I notice with mine is that in my vim.tbl_deep_extend, I call it with "keep" and the cmp capabilities listed after my didChangeWatchedFiles override table:

local default_caps = {
  workspace = {
    didChangeWatchedFiles = {
      dynamicRegistration = true,
    },
  },
}

capabilities = vim.tbl_deep_extend(
  "keep",
  default_caps,
  require("cmp_nvim_lsp").default_capabilities()
)

I would check the following in Neovim's LSP log with the verbosity turned up to at least DEBUG:

1. The client capability is set as expected in the `initialize` client call.

2. The server sends a `client/registerCapability` request for the `workspace/didChangeWatchedFiles` method.

3. Creating/changing/deleting a file you expect to match any of the `watchers` from the register request triggers a `workspace/didChangeWatchedFiles` notification sent to the server.

From a quick look at the source code for Astro, I can see where it consumes the notifications, but I don't see where it sends the request to register the capability.

Thank you for taking the time for the detailed response :)

I've been trying multiple things but still no success. I'm not very proficient in how LSP is supposed to work, but the "I don't see where it sends the request to register the capability." makes sense. I guess I'll open an issue there to see if we can get this looked into.

I've also seen the lsp.log and didn't find the event workspace/didChangeWatchedFiles anywhere from the Astro server. So confirms what you've said!

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants