summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2019-09-22 13:07:19 +0100
committerGitHub <noreply@github.com>2019-09-22 13:07:19 +0100
commit6746eaeaa0a02fbd101c7ae367aaa2fb62378368 (patch)
tree68c4c254e57a0ec9216c4a1b49c8f541d0d55d8a /ale_linters
parentd7dbc8f2cf2da04158af8d1c49f71c10b24cff1c (diff)
parentab0bf615123da5f5f7eb30d18ee34b0b317aa795 (diff)
downloadale-6746eaeaa0a02fbd101c7ae367aaa2fb62378368.zip
Merge pull request #2683 from ahayworth/ahayworth-add-ink-lsp
Add support for ink-language-server
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/ink/ls.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/ale_linters/ink/ls.vim b/ale_linters/ink/ls.vim
new file mode 100644
index 00000000..1cc93583
--- /dev/null
+++ b/ale_linters/ink/ls.vim
@@ -0,0 +1,35 @@
+" Author: Andreww Hayworth <ahayworth@gmail.com>
+" Description: Integrate ALE with ink-language-server
+
+call ale#Set('ink_ls_executable', 'ink-language-server')
+call ale#Set('ink_ls_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('ink_ls_initialization_options', {})
+
+function! ale_linters#ink#ls#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'ink_ls', [
+ \ 'ink-language-server',
+ \ 'node_modules/.bin/ink-language-server',
+ \])
+endfunction
+
+function! ale_linters#ink#ls#GetCommand(buffer) abort
+ let l:executable = ale_linters#ink#ls#GetExecutable(a:buffer)
+
+ return ale#Escape(l:executable) . ' --stdio'
+endfunction
+
+function! ale_linters#ink#ls#FindProjectRoot(buffer) abort
+ let l:main_file = get(ale#Var(a:buffer, 'ink_ls_initialization_options'), 'mainStoryPath', 'main.ink')
+ let l:config = ale#path#ResolveLocalPath(a:buffer, l:main_file, expand('#' . a:buffer . ':p'))
+
+ return ale#path#Dirname(l:config)
+endfunction
+
+call ale#linter#Define('ink', {
+\ 'name': 'ink-language-server',
+\ 'lsp': 'stdio',
+\ 'executable': function('ale_linters#ink#ls#GetExecutable'),
+\ 'command': function('ale_linters#ink#ls#GetCommand'),
+\ 'project_root': function('ale_linters#ink#ls#FindProjectRoot'),
+\ 'initialization_options': {b -> ale#Var(b, 'ink_ls_initialization_options')},
+\})