lua-language-server
lua-language-server copied to clipboard
Diagnostic warn about duplicates from symlinked workspace
How are you using the lua-language-server?
NeoVim
Which OS are you using?
MacOS
What is the issue affecting?
Diagnostics/Syntax Checking
Expected Behaviour
I expected ignoring symlinks.
Actual Behaviour
I have a plugin I'm developing on my machine and I'm using Packer (plugin manager) to install the plugin in a plugins directory. Local plugins are just symlinked. This causes the diagnostics to warn about duplicates in every single annotation.
If I remove the symlink diagnostic stop spamming warnings.
Reproduction steps
- Install latest stable neovim
- Install Packer or, I think, any other plugin manager
- Install local plugin via plugin manager
use("~/path_to_plugin") - Open any file which contains annotations
- See warnings
Additional Notes
No response
Log File
No response
This is my settings for the server.
local runtime_path = vim.split(package.path, ";")
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
nvim_lsp.lua_ls.setup({
on_attach = map.set_lsp_map,
capabilities = capabilities,
flags = flags,
settings = {
Lua = {
completion = {
callSnippet = "Both",
},
diagnostics = {
globals = { "vim" },
},
runtime = {
version = "LuaJIT",
path = runtime_path,
},
telemetry = {
enable = false,
},
window = {
progressBar = false,
statusBar = false,
},
workspace = {
-- if I remove this line, then the problem is solved
-- but then I can't get neovim api to work
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
},
},
})
I did some hacking and removed the symlink from the runtime path. It works but it is still a hack.
local runtime_path = vim.split(package.path, ";")
local runtime_file = vim.api.nvim_get_runtime_file("", true)
-- HACK start
local idxs = {}
for i, v in ipairs(runtime_file) do
if v:find("everybody-wants-that-line.nvim", 0, true) or v:match(".local/share/nvim/site$") then
table.insert(idxs, i)
end
end
for i = #idxs, 1, -1 do
table.remove(runtime_file, idxs[i])
end
-- HACK end
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
nvim_lsp.lua_ls.setup({
on_attach = map.set_lsp_map,
capabilities = capabilities,
flags = flags,
settings = {
Lua = {
...
workspace = {
library = runtime_file,
checkThirdParty = false,
},
},
},
})
I think this is the function of the symbol link
Simple case:
I want to distribute a directory vector with a file vector.lua inside of it in order to follow the convention (look at middleclass.lua, fun.lua, argparse.lua and other popular Lua libraries).
However I also want to allow for people with the default package.path of ?.lua;?/init.lua to import the entire vector directory, without having to extract the vector.lua itself. To do this, I simply made a relative symlink init.lua pointing to vector.lua.
This is why the duplicate annotations problem is annoying.
It would be nice if the annotations automatically ignored a file that has already been read.
I have encountered this same issue in my library lua-stream.
My file structure looks like this:
> tree
.
├── doc
│ └── examples.lua
├── LICENSE
├── lua
│ └── stream
│ └── init.lua
├── README.md
├── stream -> lua/stream/
├── stylua.toml
└── test
└── init.lua
having /stream be a symlink to /lua/stream/ allows the default package.path to import it as require "stream", while also /lua/stream/ allows NeoVim plugins to import it as well.