neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
9.98k stars 2.04k forks source link

Recommended configuration for lua_ls causes issues #3189

Open jecaro opened 1 month ago

jecaro commented 1 month ago

Description

One of the options recommended for lua_ls causes issues when working on one own neovim configuration.

https://github.com/neovim/nvim-lspconfig/blob/74e14808cdb15e625449027019406e1ff6dda020/doc/server_configurations.md?plain=1#L6361-L6362

The problem is that nvim_get_runtime_file returns all neovim runtime directories, including the user config itself. Then when working on one own neovim config, lua_ls sees it kind of twice and outputs a lot of wrong duplicated fields warnings ([duplicate-doc-field]). I suspect this is this issue.

Removing those two directories from the runtime path, makes the issue disappear:

-- lua language server is super confused when editing lua files in the config
-- and raises a lot of [duplicate-doc-field] warnings
local runtime_files = vim.api.nvim_get_runtime_file("", true)
for k, v in ipairs(runtime_files) do
  if v == "/home/my-login/.config/nvim/after" or v == "/home/my-login/.config/nvim" then
    table.remove(runtime_files, k)
  end
end

...

-- library = vim.api.nvim_get_runtime_file("", true) 
library = runtime_files