]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/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:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / autoload / ale / lua.vim
diff --git a/.vim/bundle/ale/autoload/ale/lua.vim b/.vim/bundle/ale/autoload/ale/lua.vim
new file mode 100644 (file)
index 0000000..f4a5d05
--- /dev/null
@@ -0,0 +1,29 @@
+" 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 = [
+    \   '.luarc.json',
+    \   '.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