neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
9.98k stars 2.04k forks source link

Possibly wrong order in root_dir for tsserver #3179

Closed DanilaMihailov closed 1 month ago

DanilaMihailov commented 1 month ago

Description

Is there a reason for this order? https://github.com/neovim/nvim-lspconfig/blob/d70633830acf605ec03d9728698d9e7232442eb4/lua/lspconfig/server_configurations/tsserver.lua#L15

I see this commit moved tsconfig.json before package.json, but jsconfig.json is left after package.json. This is a little bit confusing. Maybe jsconfig.json should be before package.json?

vscode seems to have an order like this ['tsconfig.json', 'jsoncfig.json' ...] if this is any indication.

Of course I fixed this in my config by just changing this field, but maybe it should be default?

root_dir = util.root_pattern('tsconfig.json', 'jsconfig.json', 'package.json', '.git')
glepnir commented 1 month ago

It would be good if any official document describes root directory priority or refer to vscode related

justinmk commented 1 month ago

Maybe jsconfig.json should be before package.json?

Seems reasonable

DanilaMihailov commented 1 month ago

found some docs, but it just says

The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.

JavaScript projects can use a jsconfig.json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.

at least it implies that tsconfig.json and jsconfig.json should be treated the same

DanilaMihailov commented 1 month ago

Seems like a simple change, I can create a PR