summaryrefslogtreecommitdiff
path: root/autoload
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 /autoload
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 'autoload')
-rw-r--r--autoload/ale/go.vim27
1 files changed, 27 insertions, 0 deletions
diff --git a/autoload/ale/go.vim b/autoload/ale/go.vim
new file mode 100644
index 00000000..a166480a
--- /dev/null
+++ b/autoload/ale/go.vim
@@ -0,0 +1,27 @@
+" Author: Horacio Sanson https://github.com/hsanson
+" Description: Functions for integrating with Go tools
+
+" Find the nearest dir listed in GOPATH and assume it the root of the go
+" project.
+function! ale#go#FindProjectRoot(buffer) abort
+ let l:sep = has('win32') ? ';' : ':'
+
+ let l:filename = ale#path#Simplify(expand('#' . a:buffer . ':p'))
+
+ for l:name in split($GOPATH, l:sep)
+ let l:path_dir = ale#path#Simplify(l:name)
+
+ " Use the directory from GOPATH if the current filename starts with it.
+ if l:filename[: len(l:path_dir) - 1] is? l:path_dir
+ return l:path_dir
+ endif
+ endfor
+
+ let l:default_go_path = ale#path#Simplify(expand('~/go'))
+
+ if isdirectory(l:default_go_path)
+ return l:default_go_path
+ endif
+
+ return ''
+endfunction