diff --git a/README.md b/README.md index cd69280..ec9499d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,18 @@ require("lspconfig").lua_ls.setup(...) -- set the filetype to jsonc for settings files, so you can use comments -- make sure you have the jsonc treesitter parser installed! filetype_jsonc = true, + --- Returns which root_dir to pick when two are available + ---@param a? string First potential root_dir + ---@param b? string Second potential root_dir + ---@return string? + root_dir_picker = function(a, b) + if a and b then + -- return longest + return (#a > #b) and a or b + end + + return a or b + end, plugins = { -- configures lsp clients with settings in the following order: -- - lua settings passed in lspconfig setup diff --git a/doc/neoconf.nvim.txt b/doc/neoconf.nvim.txt index 7b9dc01..8f56aeb 100644 --- a/doc/neoconf.nvim.txt +++ b/doc/neoconf.nvim.txt @@ -92,6 +92,18 @@ CONFIGURATION *neoconf.nvim-neoconf.nvim-configuration* -- set the filetype to jsonc for settings files, so you can use comments -- make sure you have the jsonc treesitter parser installed! filetype_jsonc = true, + --- Returns which root_dir to pick when two are available + ---@param a? string First potential root_dir + ---@param b? string Second potential root_dir + ---@return string? + root_dir_picker = function(a, b) + if a and b then + -- return longest + return (#a > #b) and a or b + end + + return a or b + end, plugins = { -- configures lsp clients with settings in the following order: -- - lua settings passed in lspconfig setup diff --git a/lua/neoconf/config.lua b/lua/neoconf/config.lua index 37edcc8..de03e12 100644 --- a/lua/neoconf/config.lua +++ b/lua/neoconf/config.lua @@ -17,6 +17,18 @@ M.defaults = { -- set the filetype to jsonc for settings files, so you can use comments -- make sure you have the jsonc treesitter parser installed! filetype_jsonc = true, + --- Returns which root_dir to pick when two are available + ---@param a? string First potential root_dir + ---@param b? string Second potential root_dir + ---@return string? + root_dir_picker = function(a, b) + if a and b then + -- return longest + return (#a > #b) and a or b + end + + return a or b + end, plugins = { -- configures lsp clients with settings in the following order: -- - lua settings passed in lspconfig setup diff --git a/lua/neoconf/util.lua b/lua/neoconf/util.lua index 96ca3d0..629f0cb 100644 --- a/lua/neoconf/util.lua +++ b/lua/neoconf/util.lua @@ -57,11 +57,7 @@ function M.on_config(opts) end local a = opts.root_dir(...) - if a and b then - -- return longest - return #a > #b and a or b - end - return a or b + return Config.options.root_dir_picker(a, b) end end end)