diff options
author | Horacio Sanson <hsanson@gmail.com> | 2021-01-23 01:47:38 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-23 01:47:38 +0900 |
commit | 1b010bbabb5b28cc2746ca967941ffdc9240960e (patch) | |
tree | 154566b2a760d5d0e2c57c7756a50c4dbd369358 | |
parent | 9a1e91e075abf386e8c6fd620ec0835e566a7db1 (diff) | |
parent | 985a5295a9eaa4451ccf5616efd8262adbd06b39 (diff) | |
download | ale-1b010bbabb5b28cc2746ca967941ffdc9240960e.zip |
Merge pull request #3069 from nelsyeung/feature/dart-analysis-server
Add dart analysis server to linter
-rw-r--r-- | ale_linters/dart/analysis_server.vim | 29 | ||||
-rw-r--r-- | doc/ale-dart.txt | 25 | ||||
-rw-r--r-- | doc/ale-supported-languages-and-tools.txt | 1 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | supported-tools.md | 1 | ||||
-rw-r--r-- | test/command_callback/test_dart_analysis_server_command_callback.vader | 15 |
6 files changed, 72 insertions, 0 deletions
diff --git a/ale_linters/dart/analysis_server.vim b/ale_linters/dart/analysis_server.vim new file mode 100644 index 00000000..a6870da9 --- /dev/null +++ b/ale_linters/dart/analysis_server.vim @@ -0,0 +1,29 @@ +" Author: Nelson Yeung <nelsyeung@gmail.com> +" Description: Check Dart files with dart analysis server LSP + +call ale#Set('dart_analysis_server_executable', 'dart') + +function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort + " Note: pub only looks for pubspec.yaml, there's no point in adding + " support for pubspec.yml + let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml') + + return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.' +endfunction + +function! ale_linters#dart#analysis_server#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable') + let l:dart = resolve(exepath(l:executable)) + + return '%e ' + \ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot' + \ . ' --lsp' +endfunction + +call ale#linter#Define('dart', { +\ 'name': 'analysis_server', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'dart_analysis_server_executable')}, +\ 'command': function('ale_linters#dart#analysis_server#GetCommand'), +\ 'project_root': function('ale_linters#dart#analysis_server#GetProjectRoot'), +\}) diff --git a/doc/ale-dart.txt b/doc/ale-dart.txt index a6d88dd8..01089252 100644 --- a/doc/ale-dart.txt +++ b/doc/ale-dart.txt @@ -3,6 +3,31 @@ ALE Dart Integration *ale-dart-options* =============================================================================== +analysis_server *ale-dart-analysis_server* + +Installation +------------------------------------------------------------------------------- + +Install Dart via whatever means. `analysis_server` will be included in the SDK. + +In case that `dart` is not in your path, try to set the executable option to +its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_analysis_server_executable = '/usr/local/bin/dart' +< + +Options +------------------------------------------------------------------------------- + +g:ale_dart_analysis_server_executable *g:ale_dart_analysis_server_executable* + *b:ale_dart_analysis_server_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to change the path of dart. + + +=============================================================================== dartanalyzer *ale-dart-dartanalyzer* Installation diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 239927be..a44ad75b 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -116,6 +116,7 @@ Notes: * Dafny * `dafny`!! * Dart + * `analysis_server` * `dartanalyzer`!! * `dartfmt`!! * `language_server` diff --git a/doc/ale.txt b/doc/ale.txt index 817201c4..d73987a9 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2664,6 +2664,7 @@ documented in additional help files. dafny...................................|ale-dafny-options| dafny.................................|ale-dafny-dafny| dart....................................|ale-dart-options| + analysis_server.......................|ale-dart-analysis_server| dartanalyzer..........................|ale-dart-dartanalyzer| dartfmt...............................|ale-dart-dartfmt| dhall...................................|ale-dhall-options| diff --git a/supported-tools.md b/supported-tools.md index ff4a78d8..8ed83d6c 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -125,6 +125,7 @@ formatting. * Dafny * [dafny](https://rise4fun.com/Dafny) :floppy_disk: * Dart + * [analysis_server](https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server) * [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk: * [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt) * [language_server](https://github.com/natebosch/dart_language_server) diff --git a/test/command_callback/test_dart_analysis_server_command_callback.vader b/test/command_callback/test_dart_analysis_server_command_callback.vader new file mode 100644 index 00000000..1754109a --- /dev/null +++ b/test/command_callback/test_dart_analysis_server_command_callback.vader @@ -0,0 +1,15 @@ +Before: + call ale#assert#SetUpLinterTest('dart', 'analysis_server') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'dart', ale#Escape('dart') + \ . ' ./snapshots/analysis_server.dart.snapshot --lsp' + +Execute(The executable should be configurable): + let g:ale_dart_analysis_server_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') + \ . ' ./snapshots/analysis_server.dart.snapshot --lsp' |