fix(stylua): set cmd_cwd to root_dir for config lookup#4082
Closed
rmuir wants to merge 1 commit intoneovim:masterfrom
Closed
fix(stylua): set cmd_cwd to root_dir for config lookup#4082rmuir wants to merge 1 commit intoneovim:masterfrom
rmuir wants to merge 1 commit intoneovim:masterfrom
Conversation
PROBLEM Stylua LSP server does not make use of rootUri in any way. If nvim is launched from a directory where cwd != rootDir, stylua will apply the incorrect configuration (internal defaults), and reformat code with an unexpected style. SOLUTION Set the cmd_cwd via reuse_client(), similar to ast_grep. See neovim#3850 for more details.
Member
|
isn't this a server bug ? it should respect the root_dir that is passed to it, CWD shouldn't matter was this reported to stylua LS? |
Contributor
Author
|
I will take the issue over there: honestly didn't think it was a bug (the spec is super-vague), just another oddity of how stylua processes configuration files, and that we were "holding it wrong". |
Member
|
i'm not objecting to this since it looks pretty low-risk and clever. but also think it's worth reporting and discussing. please link to the upstream issue here |
RichGuk
added a commit
to RichGuk/nvim-lspconfig
that referenced
this pull request
Sep 25, 2025
Problem: When running from a directory other than root (i.e monorepo), ruby-lsp does not load correctly. Unsure why, [previous lspconfig](https://github.com/neovim/nvim-lspconfig/blob/33d351cbcc2b12b8e12078515829d042863743a9/lua/lspconfig/manager.lua#L119) had cmd_cwd set to the same as root_dir. Solution: Set the cmd_cwd via reuse_client(), similar to ast_grep. See neovim#3850, neovim#4082 for more details. Tested both from root_dir and monorepo multi-root project.
RichGuk
added a commit
to RichGuk/nvim-lspconfig
that referenced
this pull request
Sep 25, 2025
Problem: When running from a directory other than root (i.e monorepo), ruby-lsp does not load correctly. Unsure why, [previous lspconfig](https://github.com/neovim/nvim-lspconfig/blob/33d351cbcc2b12b8e12078515829d042863743a9/lua/lspconfig/manager.lua#L119) had cmd_cwd set to the same as root_dir. Solution: Set the cmd_cwd via reuse_client(), similar to ast_grep. See neovim#3850, neovim#4082 for more details. Tested both from root_dir and monorepo multi-root project.
RichGuk
added a commit
to RichGuk/nvim-lspconfig
that referenced
this pull request
Sep 25, 2025
Problem: When running from a directory other than root (i.e monorepo), ruby-lsp does not load correctly. Unsure why, previous lspconfig had cmd_cwd set to the same as root_dir. Solution: Set the cmd_cwd via reuse_client(), similar to ast_grep. See neovim#3850, neovim#4082 for more details. Tested both from root_dir and monorepo multi-root project.
justinmk
pushed a commit
that referenced
this pull request
Sep 25, 2025
Problem: When running from a directory other than root (i.e monorepo), ruby-lsp does not load correctly. Unsure why, previous lspconfig had cmd_cwd set to the same as root_dir. Solution: Set the cmd_cwd via reuse_client(), similar to ast_grep. See #3850, #4082 for more details. Tested both from root_dir and monorepo multi-root project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PROBLEM
Stylua LSP server does not make use of rootUri in any way. If nvim is launched from a directory where cwd != rootDir, stylua will apply the incorrect configuration (internal defaults), and reformat code with an unexpected style.
SOLUTION
Set the cmd_cwd via reuse_client(), similar to ast_grep. See #3850 for more details.