-
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
docs(lua_ls): change suggested setup to work on both nightly and 0.9.5 #3054
Conversation
In this PR you added: -- Depending on the usage, you might want to add additional paths here. I tested with and without that addition and could not detect a difference. |
Yes, this change makes sense since |
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.
Squash and fix the commit messages and we can merge.
I find the following hard to read: if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { As a suggestion: require'lspconfig'.lua_ls.setup {
on_init = function(client)
local path = client.workspace_folders[1].name
if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then
return true
end
client.settings.Lua = vim.tbl_deep_extend('force', client.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- Depending on the usage, you might want to add additional paths here.
-- E.g.: For using `vim.*` functions, add vim.env.VIMRUNTIME/lua.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
}
})
end
return true
end
settings = {
Lua = {}
}
} Also: Is return true needed? |
No it's not. |
Then I will also remove the return true if you agree What is your opinion on my early return suggestion? if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then
return true
end |
Yeah, looks fine. Again don't need to return |
@lewis6991, I added a commit. -- E.g.: For using vim.* functions, add vim.env.VIMRUNTIME/lua. Is this still needed? I did not observe any difference. |
No I don't think that does anything. |
There is one problem: By using client.settings, the suggested config will not work on version |
Ok, don't use that for now. Do what you did initially. |
I restored client.config.settings and removed the comment mentioning VIMRUNTIME/lua
Do I need to do this or is this done when merging? |
Yes please |
Done. Thanks, @lewis6991! |
Sorry for the late response. @lewis6991 is correct. And thanks for the change! |
Ref. neovim/nvim-lspconfig#3054 Signed-off-by: Antoine Cotten <[email protected]>
lsp_on_init.mp4
In
neovim
nightly, the current suggested config fails. I added a video demo, using this repro:I applied the config suggested in this Neovim issue and tested that it works on 0.9.5 and nightly.