Skip to content

Commit

Permalink
fix(elixirls): smarter detection of root_dir for umbrella apps (#2911)
Browse files Browse the repository at this point in the history
  • Loading branch information
giddie authored Dec 12, 2023
1 parent bd405e4 commit d29be37
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lua/lspconfig/server_configurations/elixirls.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
local util = require 'lspconfig.util'

return {
default_config = {
filetypes = { 'elixir', 'eelixir', 'heex', 'surface' },
root_dir = function(fname)
return util.root_pattern 'mix.exs'(fname) or util.find_git_ancestor(fname) or vim.loop.os_homedir()
local matches = vim.fs.find({ 'mix.exs' }, { upward = true, limit = 2, path = fname })
local child_or_root_path, maybe_umbrella_path = unpack(matches)
local root_dir = vim.fs.dirname(maybe_umbrella_path or child_or_root_path)

return root_dir
end,
single_file_support = true,
},
docs = {
description = [[
Expand All @@ -31,9 +34,11 @@ require'lspconfig'.elixirls.setup{
...
}
```
'root_dir' is chosen like this: if two or more directories containing `mix.exs` were found when searching directories upward, the second one (higher up) is chosen, with the assumption that it is the root of an umbrella app. Otherwise the directory containing the single mix.exs that was found is chosen.
]],
default_config = {
root_dir = [[util.find_git_ancestor(fname) or util.root_pattern 'mix.exs'(fname) or vim.loop.os_homedir()]],
root_dir = '{{see description above}}',
},
},
}

0 comments on commit d29be37

Please sign in to comment.