Is there a way to query what the LSP detects as the root directory? I can't seem to find one.
There's a root_dir parameter with most of the language servers that you can set to detect root directory.
What would be the syntax to query that? Like with clangd or rust analyzer for example if it's specific to each LS.
I have an understanding of how to set the root directory but I'm still unclear on how to query its value.
You can do something like this :
local nvim_lsp = require'nvim_lsp'
nvim_lsp.clangd.setup{
root_dir = nvim_lsp.util.root_pattern('.git');
}
@himansingh241 you're misunderstanding him. He's asking how query for the _calculated value_ of root_dir, not how to set it.
So for example, given this:
nvim_lsp.clangd.setup {
root_dir = nvim_lsp.util.root_pattern('foo', 'bar', 'baz')
}
What's the value of root_dir when the language server starts in some directory X?
I had the same issue. Solved it with #363.
you could use checkhealth with this branch https://github.com/neovim/neovim/pull/12578
@Kyle-Thompson Technically this is exposed via :help vim.lsp.buf.list_workspace_folders() which stores the first root directory on server intitialization by default
Most helpful comment
@himansingh241 you're misunderstanding him. He's asking how query for the _calculated value_ of
root_dir, not how to set it.So for example, given this:
What's the value of
root_dirwhen the language server starts in some directory X?