Closed AlexChalk closed 4 months ago
I think I have an idea what is going on. The plugin contains a symlink to itself in test/xdg/local/share/nvim/site/pack/testing/start/rainbow-delimiters
. This symlink is used in testing, but it looks like your language server searches all directories of the plugin, which includes test
, and ends up running in circles.
You can blacklist this particular directory (test/xdg
) in your language server settings (workspace.ignoreDir
). I don't know if it is possible to blacklist this directory in the repo itself so people don't have to do it in their own settings. Here are my Neovim settings:
-- Directory prefix of all package directories
local package_prefix = vim.fn.expand(vim.fn.stdpath('data') .. '/site/')
---Predicate which is only true for paths that belong to a package and have Lua
---modules.
---
---@param path string
---@return boolean
local function is_package_path(path)
if package_prefix ~= string.sub(path, 1, #package_prefix) then
return false
end
return vim.fn.isdirectory(path .. '/lua') ~= 0
end
local M = {
Lua = {
runtime = {
-- When using `require`, how to find the file based on the input
-- name.Setting this config to `?/init.lua` means that when you enter
-- `require 'myfile'`, `${workspace}/myfile/init.lua` will be searched from
-- the loaded files. if `runtime.pathStrict` is `false`,
-- `${workspace}/**/myfile/init.lua` will also be searched. If you want to
-- load files outside the workspace, you need to set `Lua.workspace.library`
-- first.
path = {
'lua/?.lua',
'lua/?/init.lua',
},
-- When enabled, `runtime.path` will only search the first level of
-- directories, see the description of `runtime.path`.
pathStrict = true,
},
workspace = {
-- In addition to the current workspace, which directories will
-- load files from. The files in these directories will be treated
-- as externally provided code libraries, and some features (such
-- as renaming fields) will not modify these files.
--
-- Very important: do not include the '/lua' subdirectory in the
-- above paths! The runtime.path entry takes care of that.
library = vim.tbl_filter(is_package_path, vim.api.nvim_get_runtime_file('', true)),
-- Ignore the fake user directory structure in plugins. This
-- should be part of the `.luarc.json` of the plugin, but for some
-- reason that does not work, so I define it here instead.
ignoreDir = {'test/xdg'},
},
}
}
Thanks for this, adding ignoreDir = { "test" }
works for me 🎊.
I think this behaviour will happen for anyone using the default settings for lua_ls at https://github.com/neovim/nvim-lspconfig, so I suggest adding this info to the README. FWIW, as a user I'm fine with being asked to blocklist "test" dirs in my lua_ls config 🙏.
I don't think that it's appropriate to tell users to adjust their LSP configuration for this plugin. This plugin has nothing to do with LSP, so why should I force a particular configuration onto users?
I have gone ahead and removed the symlink, it will now be created on the fly during a test session and removed again afterwards. Can you please remove the ignoreDir
setting and test whether it still works for you?
It still works, thank you 🙌.
Closing this as done.
Neovim version
0.9.4
Language affected
Lua
Query
No response
Strategy
No response
Description
When I enable rainbow-delimiters, lua_ls stalls at 0%. This is true even if I set the policy to 'noop' or blocklist lua in the plugin settings:
lua_ls config: