]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/lua.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / lua.vim
1 " Author: w0rp <dev@w0rp.com>
2 " Description: Functions for integrating with Lua linters.
3
4 " Find project root for a Lua language server.
5 function! ale#lua#FindProjectRoot(buffer) abort
6     let l:possible_project_roots = [
7     \   '.luarc.json',
8     \   '.git',
9     \   bufname(a:buffer),
10     \]
11
12     for l:possible_root in l:possible_project_roots
13         let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root)
14
15         if empty(l:project_root)
16             let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root)
17         endif
18
19         if !empty(l:project_root)
20             " dir:p expands to /full/path/to/dir/ whereas
21             " file:p expands to /full/path/to/file (no trailing slash)
22             " Appending '/' ensures that :h:h removes the path's last segment
23             " regardless of whether it is a directory or not.
24             return fnamemodify(l:project_root . '/', ':p:h:h')
25         endif
26     endfor
27
28     return ''
29 endfunction