summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Olson <drew@drewolson.org>2019-06-17 06:54:43 -0500
committerw0rp <w0rp@users.noreply.github.com>2019-06-17 12:54:43 +0100
commit1c71da5624fc46107cda4852add08fe34385dfd9 (patch)
tree4dc0c856be3798f7bfe1539fb33a2bea5496fca7
parent701c1e4f170a665ec2873a828297bb0afad6719b (diff)
downloadale-1c71da5624fc46107cda4852add08fe34385dfd9.zip
Add support for purescript language server (#2572)
* Add support for purescript language server * Update naming * Add purescript language server tests
-rw-r--r--ale_linters/purescript/ls.vim49
-rw-r--r--doc/ale-purescript.txt33
-rw-r--r--doc/ale-supported-languages-and-tools.txt2
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md2
-rw-r--r--test/command_callback/purescript_paths/bower/Foo.purs0
-rw-r--r--test/command_callback/purescript_paths/bower/bower.json0
-rw-r--r--test/command_callback/purescript_paths/psc-package/Foo.purs0
-rw-r--r--test/command_callback/purescript_paths/psc-package/psc-package.json0
-rw-r--r--test/command_callback/purescript_paths/spago/Foo.purs0
-rw-r--r--test/command_callback/purescript_paths/spago/spago.dhall0
-rw-r--r--test/command_callback/test_purescript_ls_command_callbacks.vader31
12 files changed, 119 insertions, 0 deletions
diff --git a/ale_linters/purescript/ls.vim b/ale_linters/purescript/ls.vim
new file mode 100644
index 00000000..1c5f937f
--- /dev/null
+++ b/ale_linters/purescript/ls.vim
@@ -0,0 +1,49 @@
+" Author: Drew Olson <drew@drewolson.org>
+" Description: Integrate ALE with purescript-language-server.
+
+call ale#Set('purescript_ls_executable', 'purescript-language-server')
+call ale#Set('purescript_ls_use_global', get(g:, 'ale_use_global_executables', 0))
+call ale#Set('purescript_ls_config', {})
+
+function! ale_linters#purescript#ls#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'purescript_ls', [
+ \ 'node_modules/.bin/purescript-language-server',
+ \])
+endfunction
+
+function! ale_linters#purescript#ls#GetCommand(buffer) abort
+ let l:executable = ale_linters#purescript#ls#GetExecutable(a:buffer)
+
+ return ale#Escape(l:executable) . ' --stdio'
+endfunction
+
+function! ale_linters#purescript#ls#FindProjectRoot(buffer) abort
+ let l:config = ale#path#FindNearestFile(a:buffer, 'bower.json')
+
+ if !empty(l:config)
+ return fnamemodify(l:config, ':h')
+ endif
+
+ let l:config = ale#path#FindNearestFile(a:buffer, 'psc-package.json')
+
+ if !empty(l:config)
+ return fnamemodify(l:config, ':h')
+ endif
+
+ let l:config = ale#path#FindNearestFile(a:buffer, 'spago.dhall')
+
+ if !empty(l:config)
+ return fnamemodify(l:config, ':h')
+ endif
+
+ return ''
+endfunction
+
+call ale#linter#Define('purescript', {
+\ 'name': 'purescript-language-server',
+\ 'lsp': 'stdio',
+\ 'executable': function('ale_linters#purescript#ls#GetExecutable'),
+\ 'command': function('ale_linters#purescript#ls#GetCommand'),
+\ 'project_root': function('ale_linters#purescript#ls#FindProjectRoot'),
+\ 'lsp_config': {b -> ale#Var(b, 'purescript_ls_config')},
+\})
diff --git a/doc/ale-purescript.txt b/doc/ale-purescript.txt
new file mode 100644
index 00000000..33fd2429
--- /dev/null
+++ b/doc/ale-purescript.txt
@@ -0,0 +1,33 @@
+===============================================================================
+ALE PureScript Integration *ale-purescript-options*
+
+
+===============================================================================
+purescript-language-server *ale-purescript-language-server*
+
+PureScript Language Server
+ (https://github.com/nwolverson/purescript-language-server)
+
+g:ale_purescript_ls_executable g:ale_purescript_ls_executable
+ b:ale_purescript_ls_executable
+ Type: |String|
+ Default: `'purescript-language-server'`
+
+ PureScript language server executable.
+
+g:ale_purescript_ls_config g:ale_purescript_ls_config
+ b:ale_purescript_ls_config
+ Type: |Dictionary|
+ Default: `{}`
+
+ Dictionary containing configuration settings that will be passed to the
+ language server. For example, with a spago project:
+ {
+ \ 'purescript': {
+ \ 'addSpagoSources': v:true,
+ \ 'addNpmPath': v:true,
+ \ 'buildCommand': 'spago build -- --json-errors'
+ \ }
+ \}
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index f1087c2d..87e1ecde 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -338,6 +338,8 @@ Notes:
* `languageserver`
* `puppet`
* `puppet-lint`
+* PureScript
+ * `purescript-language-server`
* Python
* `autopep8`
* `bandit`
diff --git a/doc/ale.txt b/doc/ale.txt
index 40ebe594..599ac2c3 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2176,6 +2176,8 @@ documented in additional help files.
puppet................................|ale-puppet-puppet|
puppetlint............................|ale-puppet-puppetlint|
puppet-languageserver.................|ale-puppet-languageserver|
+ purescript..............................|ale-purescript-options|
+ purescript-language-server............|ale-purescript-language-server|
pyrex (cython)..........................|ale-pyrex-options|
cython................................|ale-pyrex-cython|
python..................................|ale-python-options|
diff --git a/supported-tools.md b/supported-tools.md
index e1c6d412..f96f49a3 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -347,6 +347,8 @@ formatting.
* [languageserver](https://github.com/lingua-pupuli/puppet-editor-services)
* [puppet](https://puppet.com)
* [puppet-lint](https://puppet-lint.com)
+* PureScript
+ * [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
* Python
* [autopep8](https://github.com/hhatto/autopep8)
* [bandit](https://github.com/PyCQA/bandit) :warning:
diff --git a/test/command_callback/purescript_paths/bower/Foo.purs b/test/command_callback/purescript_paths/bower/Foo.purs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/purescript_paths/bower/Foo.purs
diff --git a/test/command_callback/purescript_paths/bower/bower.json b/test/command_callback/purescript_paths/bower/bower.json
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/purescript_paths/bower/bower.json
diff --git a/test/command_callback/purescript_paths/psc-package/Foo.purs b/test/command_callback/purescript_paths/psc-package/Foo.purs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/purescript_paths/psc-package/Foo.purs
diff --git a/test/command_callback/purescript_paths/psc-package/psc-package.json b/test/command_callback/purescript_paths/psc-package/psc-package.json
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/purescript_paths/psc-package/psc-package.json
diff --git a/test/command_callback/purescript_paths/spago/Foo.purs b/test/command_callback/purescript_paths/spago/Foo.purs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/purescript_paths/spago/Foo.purs
diff --git a/test/command_callback/purescript_paths/spago/spago.dhall b/test/command_callback/purescript_paths/spago/spago.dhall
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/purescript_paths/spago/spago.dhall
diff --git a/test/command_callback/test_purescript_ls_command_callbacks.vader b/test/command_callback/test_purescript_ls_command_callbacks.vader
new file mode 100644
index 00000000..da63f7f1
--- /dev/null
+++ b/test/command_callback/test_purescript_ls_command_callbacks.vader
@@ -0,0 +1,31 @@
+Before:
+ call ale#assert#SetUpLinterTest('purescript', 'ls')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(should set correct defaults):
+ AssertLinter 'purescript-language-server', ale#Escape('purescript-language-server') . ' --stdio'
+
+Execute(should set correct LSP values):
+ call ale#test#SetFilename('purescript_paths/spago/Foo.purs')
+
+ AssertLSPLanguage 'purescript'
+ AssertLSPOptions {}
+ AssertLSPConfig {}
+ AssertLSPProject ale#path#Simplify(g:dir . '/purescript_paths/spago')
+
+Execute(should set correct project for bower):
+ call ale#test#SetFilename('purescript_paths/bower/Foo.purs')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/purescript_paths/bower')
+
+Execute(should set correct project for psc-package):
+ call ale#test#SetFilename('purescript_paths/psc-package/Foo.purs')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/purescript_paths/psc-package')
+
+Execute(should accept configuration settings):
+ AssertLSPConfig {}
+ let b:ale_purescript_ls_config = {'purescript': {'addSpagoSources': v:true}}
+ AssertLSPConfig {'purescript': {'addSpagoSources': v:true}}