summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorBartek thindil Jasicki <thindil@laeran.pl>2019-10-18 18:15:05 +0200
committerBartek thindil Jasicki <thindil@laeran.pl>2019-10-18 18:15:05 +0200
commit8239b76c5a4c765ffa04cb5c6ad0ad94cd1d0dea (patch)
treea06e6d34aad2fea419ae92109fc6319dadda2758 /ale_linters
parent6d5d3fa4dd1cc18a5b90c587502ad37323df08a3 (diff)
parentc06467438dff38b939fd81b32395296d01a59df6 (diff)
downloadale-8239b76c5a4c765ffa04cb5c6ad0ad94cd1d0dea.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/c/clangd.vim7
-rw-r--r--ale_linters/cpp/clangd.vim7
-rw-r--r--ale_linters/nim/nimlsp.vim33
3 files changed, 45 insertions, 2 deletions
diff --git a/ale_linters/c/clangd.vim b/ale_linters/c/clangd.vim
index 79b600fa..ab8a0259 100644
--- a/ale_linters/c/clangd.vim
+++ b/ale_linters/c/clangd.vim
@@ -3,9 +3,14 @@
call ale#Set('c_clangd_executable', 'clangd')
call ale#Set('c_clangd_options', '')
+call ale#Set('c_build_dir', '')
function! ale_linters#c#clangd#GetCommand(buffer) abort
- return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
+ let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
+
+ return '%e -x c'
+ \ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
+ \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
endfunction
call ale#linter#Define('c', {
diff --git a/ale_linters/cpp/clangd.vim b/ale_linters/cpp/clangd.vim
index fab605f4..14f3fe55 100644
--- a/ale_linters/cpp/clangd.vim
+++ b/ale_linters/cpp/clangd.vim
@@ -3,9 +3,14 @@
call ale#Set('cpp_clangd_executable', 'clangd')
call ale#Set('cpp_clangd_options', '')
+call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangd#GetCommand(buffer) abort
- return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
+ let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
+
+ return '%e'
+ \ . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
+ \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
endfunction
call ale#linter#Define('cpp', {
diff --git a/ale_linters/nim/nimlsp.vim b/ale_linters/nim/nimlsp.vim
new file mode 100644
index 00000000..5d041043
--- /dev/null
+++ b/ale_linters/nim/nimlsp.vim
@@ -0,0 +1,33 @@
+" Author: jeremija <https://github.com/jeremija>
+" Description: Support for nimlsp (language server for nim)
+
+call ale#Set('nim_nimlsp_nim_sources', '')
+
+function! ale_linters#nim#nimlsp#GetProjectRoot(buffer) abort
+ let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git')
+
+ if !empty(l:project_root)
+ return fnamemodify(l:project_root, ':h:h')
+ endif
+
+ return ''
+endfunction
+
+function! ale_linters#nim#nimlsp#GetCommand(buffer) abort
+ let l:nim_sources = ale#Var(a:buffer, 'nim_nimlsp_nim_sources')
+
+ if !empty(l:nim_sources)
+ let l:nim_sources = ale#Escape(l:nim_sources)
+ endif
+
+ return '%e' . ale#Pad(l:nim_sources)
+endfunction
+
+call ale#linter#Define('nim', {
+\ 'name': 'nimlsp',
+\ 'lsp': 'stdio',
+\ 'executable': 'nimlsp',
+\ 'command': function('ale_linters#nim#nimlsp#GetCommand'),
+\ 'language': 'nim',
+\ 'project_root': function('ale_linters#nim#nimlsp#GetProjectRoot'),
+\})