-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add default arg to pick compilation database #3649
base: master
Are you sure you want to change the base?
fix: Add default arg to pick compilation database #3649
Conversation
7e8074a
to
6654dd2
Compare
@@ -1,8 +1,14 @@ | |||
local util = require 'lspconfig.util' | |||
|
|||
local get_compile_commands_path = function() | |||
return '--tablegen-compilation-database=' | |||
.. vim.fs.dirname(vim.fs.find('.git', { path = vim.fn.expand('%:p:h'), upward = true })[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there is not .git folder what happen here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch, I've modified the code to look directly for tablegen_compile_commands.yml
file and return an empty string if it is not found so that it falls back to LSP invocation without any arguments.
We don't need to look for a .git
at all in this case I think since the compilation commands database file is all that it needs.
05bb191
to
56b5d2a
Compare
Friendly ping for review |
return '--tablegen-compilation-database=' .. vim.fs.dirname(file) .. '/tablegen_compile_commands.yml' | ||
end | ||
|
||
return '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will send a literal empty string arg to tblgen-lsp-server
, are you sure it handles that? Try this from a shell:
tblgen-lsp-server ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, I did not know that (I'm learning both lua and nvim-lsp as I'm doing this).
tblgen-lsp-server ""
doesn't work on the shell, but weirdly enough, I did not get any errors when I tested the LSP on a directory that does not have any tablgen_compile_commands.yml
file. Maybe the error was printed in LSP log and I missed it.
Anyway, thanks for the catch. I modified the function to build the whole command instead of just the argument. This new version should definitely work in all cases as far as I can tell.
Let me know if this makes sense, thanks.
The tblgen_lsp_server doesn't seem to load any specific compilation database server and hence we need to explicitly specify the command-line argument to pick the correct database path.
56b5d2a
to
b055996
Compare
The
tblgen_lsp_server
doesn't seem to load any specific compilation database server and hence we need to explicitly specify the command-line argument to pick the correct database path.