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: LS crashes on neovim #730

Closed
aynp opened this issue Dec 19, 2023 · 2 comments
Closed

🐛 BUG: LS crashes on neovim #730

aynp opened this issue Dec 19, 2023 · 2 comments
Labels
needs triage Issue needs to be triaged

Comments

@aynp
Copy link

aynp commented Dec 19, 2023

Describe the Bug

LS crashes and fails to attach on neovim.

Log

[ERROR][2023-12-20 03:57:21] .../vim/lsp/rpc.lua:734"rpc""astro-ls""stderr""/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/dist/languageServerPlugin.js:45
                readDirectory: modules.typescript.sys.readDirectory,
                                                  ^

TypeError: Cannot read properties of undefined (reading sys)
    at Object.resolveConfig (/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/dist/languageServerPlugin.js:45:51)
    at createProject (/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/out/common/project.js:78:35)
    at async getParsedCommandLine (/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/out/common/workspaces.js:302:29)
    at async prepareClosestootParsedCommandLine (/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/out/common/workspaces.js:224:17)
    at async findMatchConfigs (/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/out/common/workspaces.js:213:9)
    at async getProjectAndTsConfig (/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/out/common/workspaces.js:154:30)
    at async sendDocumentDiagnostics (/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/out/common/workspaces.js:136:26)
    at async updateDiagnostics (/home/aryan/.local/share/nvim/mason/packages/astro-language-server/node_modules/@astrojs/language-server/node_modules/@volar/language-server/out/common/workspaces.js:125:13)

Node.js v21.4.0
  • On VS Code, using the official astro extension, LSP works fine.

Steps to Reproduce

  1. pnpm create astro@latest
  2. Install LS using npm or a manager like Mason (tried both with the same result)
  3. Setup LS (here)
  4. Open an astro file.
  5. LS crashes instead of attaching normally.

Sorry if out of scope. Please feel free to close if so.

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 19, 2023
@Princesseuh
Copy link
Member

I think you might be missing some configuration, namely the path to TypeScript in your init config, but I don't really use Neovim so I'm not sure.

Nonetheless, I believe this crash has been fixed by #701 already, hopefully it gives a better error message once that lands.

@aynp
Copy link
Author

aynp commented Dec 25, 2023

Sorry for duplicate issue.
Thanks a lot for pointing it out and fix.

As a reference here's how to add missing path to ts for now (it uses the typescript in the project).

require("lspconfig").astro.setup {
  init_options = {
    typescript = {
      tsdk = 'node_modules/typescript/lib'
    }
  }
}

@aynp aynp closed this as completed Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants