summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-09-06 14:50:00 +0100
committerGitHub <noreply@github.com>2018-09-06 14:50:00 +0100
commitf1d5bcbf988d2fff1ce396537534e55611c8b8d6 (patch)
tree3f47a5fcb577c2adc221426f3959dcc4343fb18a /ale_linters
parentf8beaa9e3e5e6a723ce33deba8b71acb2c9dd1a1 (diff)
parenta9333c2866ad604ef5b8523af7fb1fce10057833 (diff)
downloadale-f1d5bcbf988d2fff1ce396537534e55611c8b8d6.zip
Merge pull request #1870 from hsanson/1822-add-go-langserver-support
Fix #1822 - support go-langserver lsp.
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/go/golangserver.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/ale_linters/go/golangserver.vim b/ale_linters/go/golangserver.vim
new file mode 100644
index 00000000..c80b096d
--- /dev/null
+++ b/ale_linters/go/golangserver.vim
@@ -0,0 +1,28 @@
+" Author: Horacio Sanson <https://github.com/hsanson>
+" Description: Support for go-langserver https://github.com/sourcegraph/go-langserver
+
+call ale#Set('go_langserver_executable', 'go-langserver')
+call ale#Set('go_langserver_options', '')
+
+function! ale_linters#go#golangserver#GetCommand(buffer) abort
+ let l:executable = [ale#Escape(ale#Var(a:buffer, 'go_langserver_executable'))]
+ let l:options = ale#Var(a:buffer, 'go_langserver_options')
+ let l:options = substitute(l:options, '-gocodecompletion', '', 'g')
+ let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1')
+
+ if(ale#Var(a:buffer, 'completion_enabled') == 1)
+ call add(l:options, '-gocodecompletion')
+ endif
+
+ let l:options = uniq(sort(l:options))
+
+ return join(extend(l:executable, l:options), ' ')
+endfunction
+
+call ale#linter#Define('go', {
+\ 'name': 'golangserver',
+\ 'lsp': 'stdio',
+\ 'executable_callback': ale#VarFunc('go_langserver_executable'),
+\ 'command_callback': 'ale_linters#go#golangserver#GetCommand',
+\ 'project_root_callback': 'ale#go#FindProjectRoot',
+\})