summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-07-20 21:05:24 +0100
committerGitHub <noreply@github.com>2018-07-20 21:05:24 +0100
commit04fbea6e80e010ffc242cc13daed6279f5d5aadf (patch)
tree244df0f15ce16a73259e98dbb4d54fec56277195
parent0d37aaac7a6f2a6291d7db1032fe08196164fc73 (diff)
parentad986a8d821c343cafa363ebb4399fe589a373e1 (diff)
downloadale-04fbea6e80e010ffc242cc13daed6279f5d5aadf.zip
Merge pull request #1736 from unpairedbracket/master
Add support for Fortran language server by @hansec
-rw-r--r--README.md2
-rw-r--r--ale_linters/fortran/language_server.vim27
-rw-r--r--doc/ale-fortran.txt19
-rw-r--r--doc/ale.txt3
-rw-r--r--test/command_callback/fortran-fortls-project/.fortls2
-rw-r--r--test/command_callback/test_fortran_fortls_callback.vader18
6 files changed, 69 insertions, 2 deletions
diff --git a/README.md b/README.md
index dea58fd9..6196512d 100644
--- a/README.md
+++ b/README.md
@@ -119,7 +119,7 @@ formatting.
| Erb | [erb](https://apidock.com/ruby/ERB), [erubi](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
| Fish | fish [-n flag](https://linux.die.net/man/1/fish)
-| Fortran | [gcc](https://gcc.gnu.org/) |
+| Fortran | [gcc](https://gcc.gnu.org/), [language_server](https://github.com/hansec/fortran-language-server) |
| Fountain | [proselint](http://proselint.com/) |
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
| Git Commit Messages | [gitlint](https://github.com/jorisroovers/gitlint) |
diff --git a/ale_linters/fortran/language_server.vim b/ale_linters/fortran/language_server.vim
new file mode 100644
index 00000000..fd763fcf
--- /dev/null
+++ b/ale_linters/fortran/language_server.vim
@@ -0,0 +1,27 @@
+" Author: unpairedbracket ben.spiers22@gmail.com
+" Description: A language server for fortran
+
+call ale#Set('fortran_language_server_executable', 'fortls')
+call ale#Set('fortran_language_server_use_global', get(g:, 'ale_use_global_executables', 0))
+
+function! ale_linters#fortran#language_server#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'fortran_language_server_executable')
+endfunction
+
+function! ale_linters#fortran#language_server#GetCommand(buffer) abort
+ return ale#Escape(ale_linters#fortran#language_server#GetExecutable(a:buffer))
+endfunction
+
+function! ale_linters#fortran#language_server#GetProjectRoot(buffer) abort
+ let l:fortls_file = ale#path#FindNearestFile(a:buffer, '.fortls')
+
+ return !empty(l:fortls_file) ? fnamemodify(l:fortls_file, ':h') : ''
+endfunction
+
+call ale#linter#Define('fortran', {
+\ 'name': 'language_server',
+\ 'lsp': 'stdio',
+\ 'executable_callback': 'ale_linters#fortran#language_server#GetExecutable',
+\ 'command_callback': 'ale_linters#fortran#language_server#GetCommand',
+\ 'project_root_callback': 'ale_linters#fortran#language_server#GetProjectRoot',
+\})
diff --git a/doc/ale-fortran.txt b/doc/ale-fortran.txt
index ed6bc724..c9b7e8e2 100644
--- a/doc/ale-fortran.txt
+++ b/doc/ale-fortran.txt
@@ -33,4 +33,23 @@ g:ale_fortran_gcc_use_free_form *g:ale_fortran_gcc_use_free_form*
===============================================================================
+language_server *ale-fortran-language-server*
+
+g:ale_fortran_language_server_executable *g:ale_fortran_language_server_executable*
+ *b:ale_fortran_language_server_executable*
+ Type: |String|
+ Default: `'fortls'`
+
+ This variable can be changed to modify the executable used for the Fortran
+ Language Server.
+
+g:ale_fortran_language_server_use_global *g:ale_fortran_language_server_use_global*
+ *b:ale_fortran_language_server_use_global*
+ Type: |Number|
+ Default: `get(g:, 'ale_use_global_executables', 0)`
+
+ See |ale-integrations-local-executables|
+
+
+===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 96bbc89b..589b58f9 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -76,6 +76,7 @@ CONTENTS *ale-contents*
fish..................................|ale-fish-options|
fortran...............................|ale-fortran-options|
gcc.................................|ale-fortran-gcc|
+ language_server.....................|ale-fortran-language-server|
fountain..............................|ale-fountain-options|
fusionscript..........................|ale-fuse-options|
fusion-lint.........................|ale-fuse-fusionlint|
@@ -355,7 +356,7 @@ Notes:
* Erb: `erb`, `erubi`, `erubis`
* Erlang: `erlc`, `SyntaxErl`
* Fish: `fish` (-n flag)
-* Fortran: `gcc`
+* Fortran: `gcc`, `language_server`
* Fountain: `proselint`
* FusionScript: `fusion-lint`
* Git Commit Messages: `gitlint`
diff --git a/test/command_callback/fortran-fortls-project/.fortls b/test/command_callback/fortran-fortls-project/.fortls
new file mode 100644
index 00000000..2c63c085
--- /dev/null
+++ b/test/command_callback/fortran-fortls-project/.fortls
@@ -0,0 +1,2 @@
+{
+}
diff --git a/test/command_callback/test_fortran_fortls_callback.vader b/test/command_callback/test_fortran_fortls_callback.vader
new file mode 100644
index 00000000..3be7ff4f
--- /dev/null
+++ b/test/command_callback/test_fortran_fortls_callback.vader
@@ -0,0 +1,18 @@
+Before:
+ call ale#assert#SetUpLinterTest('fortran', 'language_server')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default executable path should be correct):
+ AssertLinter 'fortls', ale#Escape('fortls')
+
+Execute(The project root should be detected correctly):
+ AssertLSPProject ''
+
+ call ale#test#SetFilename('fortran-fortls-project/test.F90')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/fortran-fortls-project')
+
+Execute(The language should be correct):
+ AssertLSPLanguage 'fortran'