diff options
author | w0rp <devw0rp@gmail.com> | 2023-02-08 01:14:47 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2023-02-08 01:14:47 +0000 |
commit | f2a21c960aba61d4ab0a0b50051b29ab8c893249 (patch) | |
tree | b2e338dc61f0e3da1e43a3cd1eb121e441eecc60 /autoload | |
parent | da5fa17df1182c3a4a30cc537b21df981f9bf93c (diff) | |
download | ale-f2a21c960aba61d4ab0a0b50051b29ab8c893249.zip |
Add support for lua-language-server
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/lua.vim | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/autoload/ale/lua.vim b/autoload/ale/lua.vim new file mode 100644 index 00000000..cda81aac --- /dev/null +++ b/autoload/ale/lua.vim @@ -0,0 +1,28 @@ +" Author: w0rp <dev@w0rp.com> +" Description: Functions for integrating with Lua linters. + +" Find project root for a Lua language server. +function! ale#lua#FindProjectRoot(buffer) abort + let l:possible_project_roots = [ + \ '.git', + \ bufname(a:buffer), + \] + + for l:possible_root in l:possible_project_roots + let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root) + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root) + endif + + if !empty(l:project_root) + " dir:p expands to /full/path/to/dir/ whereas + " file:p expands to /full/path/to/file (no trailing slash) + " Appending '/' ensures that :h:h removes the path's last segment + " regardless of whether it is a directory or not. + return fnamemodify(l:project_root . '/', ':p:h:h') + endif + endfor + + return '' +endfunction |