Skip to content

feat(ts_ls): support node_modules not in workspace root directory#4422

Open
Tsukina-7mochi wants to merge 1 commit into
neovim:masterfrom
Tsukina-7mochi:fix-ts-ls
Open

feat(ts_ls): support node_modules not in workspace root directory#4422
Tsukina-7mochi wants to merge 1 commit into
neovim:masterfrom
Tsukina-7mochi:fix-ts-ls

Conversation

@Tsukina-7mochi

Copy link
Copy Markdown

This pull request enhances the TypeScript LSP (ts_ls.lua) configuration to better support projects with non-standard node_modules layouts, such as monorepos or pnpm workspaces. The main improvement is the introduction of a helper function to locate packages within node_modules directories, ensuring the correct TypeScript server and binaries are used regardless of project structure.

Improvements for locating TypeScript packages and binaries:

  • Added a new find_node_package function that searches for a specified package within node_modules directories up the directory tree, improving compatibility with monorepos and pnpm setups.
  • Updated init_options.tsserver.path to use the new helper, ensuring the TypeScript server uses the correct lib directory for the current buffer, even if node_modules is not at the project root.
  • Modified the cmd function to use find_node_package when resolving the local typescript-language-server binary, making sure the correct binary is used in complex project structures.

@justinmk

Copy link
Copy Markdown
Member

does this match what the tsgo and other js configs are doing? they all generally end up having the same problems, so want to make sure they are following the same patterns.

@Tsukina-7mochi

Copy link
Copy Markdown
Author

@justinmk I only knew about this in the context of Node.js, so I looked into it. Since this is about ts_ls, researching TypeScript and tsgo should be sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants