mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-31 00:24:31 +08:00
elixir-ls now recognizes umbrella projects
Previously, elixir-ls would treat each sub-project within an umbrella as standalone, which isn't desirable from a language server perspective. Added ale#handlers#elixir#FindMixUmbrellaRoot, which locates the current project's root and then continues searching upwards for a potential umbrella project root. This literally looks just two levels up to keep things simple while keeping in line with Elixir project conventions. Use this new function to determine elixir-ls's LSP project root.
This commit is contained in:
@@ -1,13 +1,28 @@
|
||||
" Author: Matteo Centenaro (bugant) - https://github.com/bugant
|
||||
"
|
||||
" Description: find the root directory for an elixir project that uses mix
|
||||
" Author: Jon Parise <jon@indelible.org>
|
||||
" Description: Functions for working with Elixir projects
|
||||
|
||||
" Find the root directory for an elixir project that uses mix.
|
||||
function! ale#handlers#elixir#FindMixProjectRoot(buffer) abort
|
||||
let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs')
|
||||
|
||||
if !empty(l:mix_file)
|
||||
return fnamemodify(l:mix_file, ':p:h')
|
||||
return fnamemodify(l:mix_file, ':p:h')
|
||||
endif
|
||||
|
||||
return '.'
|
||||
endfunction
|
||||
|
||||
" Similar to ale#handlers#elixir#FindMixProjectRoot but also continue the
|
||||
" search upward for a potential umbrella project root. If an umbrella root
|
||||
" does not exist, the initial project root will be returned.
|
||||
function! ale#handlers#elixir#FindMixUmbrellaRoot(buffer) abort
|
||||
let l:app_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
|
||||
let l:umbrella_root = fnamemodify(l:app_root, ':h:h')
|
||||
|
||||
if filereadable(l:umbrella_root . '/mix.exs')
|
||||
return l:umbrella_root
|
||||
endif
|
||||
|
||||
return l:app_root
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user