lua-language-server
lua-language-server copied to clipboard
From 3.6.5 on, luarc is not being modified properly
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Linux
What is the issue affecting?
Libraries
Expected Behaviour
I expect my workspace libraries to be added to .luarc.json.
Actual Behaviour
.luarc.json is not being created nor modified at all. It also prompts for luassert addition to workspace, where I answer 1, yes and modify settings. It does not modifies them.
Reproduction steps
- Open a lua file having workspace setting set up.
- It will look for all workspace.
- It should write in
.luarc.jsonall the content.
Additional Notes
I tried and 3.6.4 was working, 3.6.5 and so on not. Maybe due to https://github.com/sumneko/lua-language-server/blob/4a9ab5b1ae9889e9732b53ad8cdf3b6db5394c3b/changelog.md?plain=1#L33
This is my config on nvim lspconfig:
Lua = {
runtime = { version = "LuaJIT" },
diagnostics = { globals = { "vim" } },
workspace = { library = vim.api.nvim_get_runtime_file("", true) },
},
Log File
No response
I also see I'm getting this error, it looks it's related:
[ERROR][2023-01-30 10:00:03] .../vim/lsp/rpc.lua:733 "rpc" "lua-language-server" "stderr" "script/json-edit.lua:408: attempt to index a userdata value (local 'ast')
stack traceback:
\tscript/json-edit.lua:408: in function <script/json-edit.lua:407>
\t(...tail calls...)
\tscript/json-edit.lua:578: in function <script/json-edit.lua:570>
\t(...tail calls...)
\tscript/client.lua:349: in upvalue 'editConfigJson'
\tscript/client.lua:401: in upvalue 'tryModifyRC'
\tscript/client.lua:499: in function <script/client.lua:485>
\t[C]: in function 'xpcall'
\tscript/client.lua:485: in function 'client.setConfig'
\tscript/library.lua:467: in upvalue 'apply3rd'
\tscript/library.lua:488: in upvalue 'askFor3rd'
\tscript/library.lua:548: in function <script/library.lua:547>
"
Thanks @sumneko! Could we get a new release soon so this applies to everyone? Thanks!
Should in these days.
Thanks!
@sumneko v3.6.8 do not solve the issue for me 😢
@sumneko v3.6.8 do not solve the issue for me 😢
Is the error gone?
Is the .luarc.json modified?
The error is gone, but .luarc.json is not created nor modified (if existed before).
@sumneko 3.6.9 do not solve the issue, and the error is still gone
Please provide your .luarc.json
It doesn't exist, I'd expect before to be created and filled due to my workspaces config, and also with luassert.
If I create an empty .luarc.json with just {} inside it don't push there all my workspace stuff from workspaces config and only pushes luassert. Even though, it keeps asking for adding luassert to it, it seems that the issue is that is not adding the workspaces stuff.
If I create an empty .luarc.json with just
{}inside it don't push there all my workspace stuff from workspaces config and only pushes luassert.
It is in designed, different configs will be merged in order. I will check other issues you mentioned.
Please check if this patch works
With that patch, luarc is created and luassert is appended if I answer yes, but it's still missing all the information the server finds from my workspace config.
but it's still missing all the information the server finds from my workspace config.
It is in design. Any other issues?
but it was not like that until 3.6.4, it was adding all the info, which prevented the server to keep asking me if I want to add luassert (because the luassert is in those libraries)
Preventing asking is nothing to do with adding all the info, since .luarc.json will be merged with your client config in design.
It should be something else.
not sure what else is missing, but until 3.6.4 was working as expected, I'm sure about that
Try this patch
now there's a first load of Loading workspace up to 100%, and then asks for luassert stuff, I answer and there's another load. Closing the editor and reopening asks another time, it doesn't recognizes that I answered yes the previous time, even though luarc is now
{
"workspace.library": [
"${3rd}/luassert/library"
]
}
Strange, I still cannot reproduce it. I will look into it tomorrow.
thank you, I'm sorry to not be able to provide so much information 😢
Please apply this patch and provide the logs, see https://github.com/sumneko/lua-language-server/wiki/FAQ#where-can-i-find-the-log-file
there you have, I added trace log level too file_home_carlo_Documents_dev_dotfiles.log
Could you please provide a log with existing .luarc.json ?
sure!
That's a log with a .luarc.json empty (well, with {}):
file_home_carlo_Documents_dev_dotfiles.log
That's another round of entering the file, after being filled the first time: file_home_carlo_Documents_dev_dotfiles.log
32cdecd solved the issue for me! 👏🏻
The only corner case I can find is when workspace.library has something inside, then it's not updated.
If initializing from a non-existing luarc I get the following one:
{
"workspace.library": [
"/home/carlo/.config/nvim",
"/etc/xdg/nvim",
"/home/carlo/.local/share/nvim/site",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-buffer",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-git",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp-signature-help",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-path",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp_luasnip",
"/home/carlo/.local/share/nvim/site/pack/packer/start/comment.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/editorconfig-vim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/fidget.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/gitsigns.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/gruvbox-material",
"/home/carlo/.local/share/nvim/site/pack/packer/start/impatient.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/jsonc.vim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/lspkind.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/lualine.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/luasnip",
"/home/carlo/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/mason.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/neoformat",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-autopairs",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-cmp",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-r",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-surround",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-texlabconfig",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
"/home/carlo/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
"/home/carlo/.local/share/nvim/site/pack/packer/start/packer.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/plenary.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/rust-tools.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/schemastore.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/telescope.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/typescript.nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/vim-fugitive",
"/home/carlo/.local/share/nvim/site/pack/packer/start/vim-kitty",
"/home/carlo/.local/share/nvim/site/pack/packer/opt/nvim-treesitter-context",
"/home/carlo/.local/share/nvim/site/pack/packer/opt/nvim-ts-autotag",
"/usr/share/nvim/runtime",
"/usr/share/nvim/runtime/pack/dist/opt/matchit",
"/usr/lib/nvim",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-buffer/after",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp/after",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp-signature-help/after",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp-path/after",
"/home/carlo/.local/share/nvim/site/pack/packer/start/cmp_luasnip/after",
"/home/carlo/.config/nvim/after",
"/usr/share/vim/vimfiles",
"${3rd}/luassert/library"
]
}
If I start lua with
{
"workspace.library": []
}
then it doesn't get updated. If any other key is set, then workspace.library is appended as expected. The issue is to not update the array present in workspace.library. These are the logs: file_home_carlo_Documents_dev_dotfiles.log
What confusing me is that in design, if the values of workspace/library are different between .luarc.json and client config, the value in .luarc.json should be applied and the value in client config should be dismiss.
Please move the parameter --loglevel=trace into your command line instead of misc.parameters (it is used for VSCode only)
If I start lua with
{ "workspace.library": [] }then it doesn't get updated. If any other key is set, then workspace.library is appended as expected. The issue is to not update the array present in workspace.library.
In this case, the real value of workspace.library is an empty list. (The value from your clien config should be coverred by .luarc.json)
After you apply luassert, it should be modified to:
{
"workspace.library": [
"${3rd}/luassert/library"
]
}