Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ink-language-server #2683

Merged
merged 1 commit into from
Sep 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions ale_linters/ink/ls.vim
Original file line number Diff line number Diff line change
@@ -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')},
\})
40 changes: 40 additions & 0 deletions doc/ale-ink.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
===============================================================================
ALE Ink Integration *ale-ink-options*


===============================================================================
ink-language-server *ale-ink-language-server*

Ink Language Server
(https://github.com/ephraim/ink-language-server)

g:ale_ink_ls_executable g:ale_ink_ls_executable
b:ale_ink_ls_executable
Type: |String|
Default: `'ink-language-server'`

Ink language server executable.

g:ale_ink_ls_initialization_options
g:ale_ink_ls_initialization_options
b:ale_ink_ls_initialization_options
Type: |Dictionary|
Default: `{}`

Dictionary containing configuration settings that will be passed to the
language server at startup. For certain platforms and certain story
structures, the defaults will suffice. However, many projects will need to
change these settings - see the ink-language-server website for more
information.

An example of setting non-default options:
{
\ 'ink': {
\ 'mainStoryPath': 'init.ink',
\ 'inklecateExecutablePath': '/usr/local/bin/inklecate',
\ 'runThroughMono': v:false
\ }
\}

===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
2 changes: 2 additions & 0 deletions doc/ale-supported-languages-and-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ Notes:
* `write-good`
* Idris
* `idris`
* Ink
* `ink-language-server`
* ISPC
* `ispc`!!
* Java
Expand Down
2 changes: 2 additions & 0 deletions doc/ale.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,8 @@ documented in additional help files.
write-good............................|ale-html-write-good|
idris...................................|ale-idris-options|
idris.................................|ale-idris-idris|
ink.....................................|ale-ink-options|
ink-language-server...................|ale-ink-language-server|
ispc....................................|ale-ispc-options|
ispc..................................|ale-ispc-ispc|
java....................................|ale-java-options|
Expand Down
2 changes: 2 additions & 0 deletions supported-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ formatting.
* [write-good](https://github.com/btford/write-good)
* Idris
* [idris](http://www.idris-lang.org/)
* Ink
* [ink-language-server](https://github.com/ephread/ink-language-server)
* ISPC
* [ispc](https://ispc.github.io/) :floppy_disk:
* Java
Expand Down
Empty file.
22 changes: 22 additions & 0 deletions test/command_callback/test_ink_ls_command_callbacks.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Before:
call ale#assert#SetUpLinterTest('ink', 'ls')
set ft=ink

After:
call ale#assert#TearDownLinterTest()

Execute(should set correct defaults):
AssertLinter 'ink-language-server', ale#Escape('ink-language-server') . ' --stdio'

Execute(should set correct LSP values):
call ale#test#SetFilename('ink_paths/story/main.ink')

AssertLSPLanguage 'ink'
AssertLSPOptions {}
AssertLSPConfig {}
AssertLSPProject ale#path#Simplify(g:dir . '/ink_paths/story')

Execute(should accept configuration settings):
AssertLSPConfig {}
let b:ale_ink_ls_initialization_options = {'ink': {'runThroughMono': v:true}}
AssertLSPOptions {'ink': {'runThroughMono': v:true}}