diff options
| author | Rasheed Atanda <atandarash@gmail.com> | 2025-09-04 01:40:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-03 17:40:55 -0700 |
| commit | 013db63f3e28d780964745c402e34952c8048fd5 (patch) | |
| tree | 5a920c3a663e109ba0528b5d466e470bf9222edc /lsp/expert.lua | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-013db63f3e28d780964745c402e34952c8048fd5.tar nvim-lspconfig-013db63f3e28d780964745c402e34952c8048fd5.tar.gz nvim-lspconfig-013db63f3e28d780964745c402e34952c8048fd5.tar.bz2 nvim-lspconfig-013db63f3e28d780964745c402e34952c8048fd5.tar.lz nvim-lspconfig-013db63f3e28d780964745c402e34952c8048fd5.tar.xz nvim-lspconfig-013db63f3e28d780964745c402e34952c8048fd5.tar.zst nvim-lspconfig-013db63f3e28d780964745c402e34952c8048fd5.zip | |
fix(expert): implement root_dir instead #4054
Copy the approach from `lsp/elixirls.lua` to support monorepos.
fix #4052
Diffstat (limited to 'lsp/expert.lua')
| -rw-r--r-- | lsp/expert.lua | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lsp/expert.lua b/lsp/expert.lua index e30afd4b..971e3de4 100644 --- a/lsp/expert.lua +++ b/lsp/expert.lua @@ -3,10 +3,24 @@ --- https://github.com/elixir-lang/expert --- --- Expert is the official language server implementation for the Elixir programming language. +--- +--- '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. ---@type vim.lsp.Config return { filetypes = { 'elixir', 'eelixir', 'heex', 'surface' }, - root_markers = { '.git', 'mix.exs' }, cmd = { 'expert' }, + root_dir = function(bufnr, on_dir) + local fname = vim.api.nvim_buf_get_name(bufnr) + --- Elixir workspaces may have `mix.exs` files, e.g. for an "umbrella" layout or monorepo. So we + --- specify `limit=2` and treat the highest one (if any) as the root of an umbrella app. + 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) + + on_dir(root_dir) + end, } |
