Skip to content

Commit

Permalink
feat: allow root_dir conflict resolution in config
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeLagrange committed Sep 10, 2023
1 parent 4a34446 commit aeb9bee
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions doc/neoconf.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions lua/neoconf/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions lua/neoconf/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aeb9bee

Please sign in to comment.