summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorAndrew Hayworth <ahayworth@gmail.com>2019-07-22 08:06:55 -0500
committerAndrew Hayworth <ahayworth@gmail.com>2019-08-07 16:35:12 -0500
commitab0bf615123da5f5f7eb30d18ee34b0b317aa795 (patch)
tree5d7e7d41ebe204e05b4da21200a2b19b0bc1843f /ale_linters
parentdd1e1025b8a9b13cb7966bf2baa3e6b42a862857 (diff)
downloadale-ab0bf615123da5f5f7eb30d18ee34b0b317aa795.zip
Add support for ink-language-server
This commit add support for ink-language-server, which it does by largely copying and pasting from the pure-language-server PR that was merged recently. The most interesting things to note are: - ink-language-server is distributed upstream via npm, which is why we search through node_modules - With some coaxing, it can be installed globally - which is why we search for a global binary. - Ink is a funky language, and users will likely need to add initialization options. - I am not incredibly familiar with vimscript; and I may not have done some of the buffer searching correctly.
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')},
+\})