neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
10.81k stars 2.1k forks source link

Lspconfig unable to find root dir for tsserver project #1831

Closed zakissimo closed 2 years ago

zakissimo commented 2 years ago

Description

Unless I manually npm install ts-server in the root of my project or create a git rep, lspconfig is unable to find if.

Neovim version

NVIM v0.7.0-dev+1395-ge135adcb8 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3

Nvim-lspconfig version

No response

Operating system and version

Linux desk 5.17.1-arch1-1 #1 SMP PREEMPT Mon, 28 Mar 2022 20:55:33 +0000 x86_64 GNU/Linux

Affected language servers

tsserver

Steps to reproduce

  1. Install minimal version
  2. Install tsserver
  3. open simple js file
  4. run :LspInfo

Actual behavior

Language client log: /home/zak/.cache/nvim/lsp.log
 Detected filetype:   javascript

 2 client(s) attached to this buffer: 

 Client: null-ls (id: 1, pid: 5001, bufnr: [6])
    filetypes:       sh, lua, python, css, typescript, typescriptreact, javascript, javascriptreact
    autostart:       false
    root directory:  /home/zak/programing/www/flag
    cmd:             nvim

 Client: quick_lint_js (id: 2, pid: 61501, bufnr: [6])
    filetypes:       javascript
    autostart:       true
    root directory:  Running in single file mode.
    cmd:             quick-lint-js --lsp-server

 Other clients that match the filetype: javascript

 Config: tsserver
    filetypes:         javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx
    root directory:    NA
    cmd:               typescript-language-server --stdio
    cmd is executable: true
    autostart:         true
    custom handlers:   

 Configured servers list: bashls, sumneko_lua, cmake, jsonls, vimls, html, tsserver, quick_lint_js

Expected behavior

I expect lspconfig to find the root dir

Minimal config

I'm using lsp-installer, see https://github.com/williamboman/nvim-lsp-installer/issues/585

mjlbach commented 2 years ago

As stated in our documentation, you need one of these files/folders (in the case of git) in order for the project to be detected:

npm install tsserver works because it creates a package.json, not because it installs the language server.

Please re-read the documentation:

https://github.com/neovim/nvim-lspconfig/blob/master/doc/lspconfig.txt#L359-L460

https://github.com/neovim/nvim-lspconfig#debugging

https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tsserver

williamboman commented 2 years ago

Hey again, so this is by design. When working on typescript projects it is expected for you to have at least one of these files or folders in your workspace:

zakissimo commented 2 years ago

I see, thank you for informing me and sorry for the inconvenience I caused.

williamboman commented 2 years ago

No worries! After rereading my first response I see how it could've been interpreted differently :D