mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Add support for lua-language-server
This commit is contained in:
28
autoload/ale/lua.vim
Normal file
28
autoload/ale/lua.vim
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user