diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | ale_linters/julia/languageserver.vim | 21 | ||||
-rw-r--r-- | autoload/ale/julia.vim | 19 | ||||
-rw-r--r-- | doc/ale-julia.txt | 20 | ||||
-rw-r--r-- | doc/ale.txt | 3 | ||||
-rw-r--r-- | test/command_callback/julia-languageserver-project/REQUIRE | 0 | ||||
-rw-r--r-- | test/command_callback/julia-languageserver-project/test.jl | 0 | ||||
-rw-r--r-- | test/command_callback/test_julia_languageserver_callbacks.vader | 26 |
8 files changed, 90 insertions, 0 deletions
@@ -135,6 +135,7 @@ formatting. | Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html), [google-java-format](https://github.com/google/google-java-format), [PMD](https://pmd.github.io/), [javalsp](https://github.com/georgewfraser/vscode-javac), [uncrustify](https://github.com/uncrustify/uncrustify) | | JavaScript | [eslint](http://eslint.org/), [flow](https://flowtype.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [prettier](https://github.com/prettier/prettier), [prettier-eslint](https://github.com/prettier/prettier-eslint-cli), [prettier-standard](https://github.com/sheerun/prettier-standard), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo) | JSON | [fixjson](https://github.com/rhysd/fixjson), [jsonlint](http://zaa.ch/jsonlint/), [jq](https://stedolan.github.io/jq/), [prettier](https://github.com/prettier/prettier) | +| Julia | [languageserver](https://github.com/JuliaEditorSupport/LanguageServer.jl) | | Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !!, [languageserver](https://github.com/fwcd/KotlinLanguageServer) see `:help ale-integration-kotlin` for configuration instructions | | LaTeX | [alex](https://github.com/wooorm/alex) !!, [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) | | Less | [lessc](https://www.npmjs.com/package/less), [prettier](https://github.com/prettier/prettier), [stylelint](https://github.com/stylelint/stylelint) | diff --git a/ale_linters/julia/languageserver.vim b/ale_linters/julia/languageserver.vim new file mode 100644 index 00000000..b6bf8e73 --- /dev/null +++ b/ale_linters/julia/languageserver.vim @@ -0,0 +1,21 @@ +" Author: Bartolomeo Stellato <bartolomeo.stellato@gmail.com> +" Description: A language server for Julia + +" Set julia executable variable +call ale#Set('julia_executable', 'julia') + +function! ale_linters#julia#languageserver#GetCommand(buffer) abort + let l:julia_executable = ale#Var(a:buffer, 'julia_executable') + let l:cmd_string = 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);' + + return ale#Escape(l:julia_executable) . ' --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string) +endfunction + +call ale#linter#Define('julia', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('julia_executable'), +\ 'command_callback': 'ale_linters#julia#languageserver#GetCommand', +\ 'language': 'julia', +\ 'project_root_callback': 'ale#julia#FindProjectRoot', +\}) diff --git a/autoload/ale/julia.vim b/autoload/ale/julia.vim new file mode 100644 index 00000000..18dd9ad7 --- /dev/null +++ b/autoload/ale/julia.vim @@ -0,0 +1,19 @@ +" Author: Bartolomeo Stellato bartolomeo.stellato@gmail.com +" Description: Functions for integrating with Julia tools + +" Find the nearest dir containing a julia project +let s:__ale_julia_project_filenames = ['REQUIRE', 'Manifest.toml', 'Project.toml'] + +function! ale#julia#FindProjectRoot(buffer) abort + for l:project_filename in s:__ale_julia_project_filenames + let l:full_path = ale#path#FindNearestFile(a:buffer, l:project_filename) + + if !empty(l:full_path) + let l:path = fnamemodify(l:full_path, ':p:h') + + return l:path + endif + endfor + + return '' +endfunction diff --git a/doc/ale-julia.txt b/doc/ale-julia.txt new file mode 100644 index 00000000..51532419 --- /dev/null +++ b/doc/ale-julia.txt @@ -0,0 +1,20 @@ +=============================================================================== +ALE Julia Integration *ale-julia-options* + +=============================================================================== +languageserver *ale-julia-languageserver* + +To enable Julia LSP linter you need to install the LanguageServer.jl package +within julia. + +g:ale_julia_executable *g:ale_julia_executable* + *b:ale_julia_executable* + + Type: |String| + Default: 'julia' + + Path to the julia exetuable. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/doc/ale.txt b/doc/ale.txt index 1799f413..ac8925f7 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -152,6 +152,8 @@ CONTENTS *ale-contents* jsonlint............................|ale-json-jsonlint| jq..................................|ale-json-jq| prettier............................|ale-json-prettier| + julia.................................|ale-julia-options| + languageserver......................|ale-julia-languageserver| kotlin................................|ale-kotlin-options| kotlinc.............................|ale-kotlin-kotlinc| ktlint..............................|ale-kotlin-ktlint| @@ -411,6 +413,7 @@ Notes: * Java: `checkstyle`, `javac`, `google-java-format`, `PMD`, `javalsp`, `uncrustify` * JavaScript: `eslint`, `flow`, `jscs`, `jshint`, `prettier`, `prettier-eslint`, `prettier-standard`, `standard`, `xo` * JSON: `fixjson`, `jsonlint`, `jq`, `prettier` +* Julia: `languageserver` * Kotlin: `kotlinc`!!, `ktlint`!!, `languageserver` * LaTeX (tex): `alex`!!, `chktex`, `lacheck`, `proselint`, `redpen`, `vale`, `write-good` * Less: `lessc`, `prettier`, `stylelint` diff --git a/test/command_callback/julia-languageserver-project/REQUIRE b/test/command_callback/julia-languageserver-project/REQUIRE new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/julia-languageserver-project/REQUIRE diff --git a/test/command_callback/julia-languageserver-project/test.jl b/test/command_callback/julia-languageserver-project/test.jl new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/julia-languageserver-project/test.jl diff --git a/test/command_callback/test_julia_languageserver_callbacks.vader b/test/command_callback/test_julia_languageserver_callbacks.vader new file mode 100644 index 00000000..a1f3a1ae --- /dev/null +++ b/test/command_callback/test_julia_languageserver_callbacks.vader @@ -0,0 +1,26 @@ +Before: + call ale#assert#SetUpLinterTest('julia', 'languageserver') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default executable path should be correct): + AssertLinter 'julia', + \ ale#Escape('julia') . + \' --startup-file=no --history-file=no -e ' . + \ ale#Escape('using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);') + +Execute(The executable should be configurable): + let g:ale_julia_executable = 'julia-new' + + AssertLinter 'julia-new', + \ ale#Escape('julia-new') . + \' --startup-file=no --history-file=no -e ' . + \ ale#Escape('using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);') + +Execute(The project root should be detected correctly): + AssertLSPProject '' + + call ale#test#SetFilename('julia-languageserver-project/test.jl') + + AssertLSPProject ale#path#Simplify(g:dir . '/julia-languageserver-project') |