From 35b8bb8a554741e9cd132ae82e9cc4a82f8f361d Mon Sep 17 00:00:00 2001 From: Nelson Yeung Date: Sun, 22 Mar 2020 20:39:40 +0000 Subject: [PATCH 1/7] Add dart analysis server linter --- ale_linters/dart/analysis_server.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ale_linters/dart/analysis_server.vim diff --git a/ale_linters/dart/analysis_server.vim b/ale_linters/dart/analysis_server.vim new file mode 100644 index 00000000..4a0ea4f2 --- /dev/null +++ b/ale_linters/dart/analysis_server.vim @@ -0,0 +1,28 @@ +" Author: Nelson Yeung +" 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'), +\}) From 075c3e0ad02456db17d28f1b04a14e015c63c11b Mon Sep 17 00:00:00 2001 From: Nelson Yeung Date: Sun, 22 Mar 2020 20:48:39 +0000 Subject: [PATCH 2/7] Add dart analysis_server to supported tools --- supported-tools.md | 1 + 1 file changed, 1 insertion(+) 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) From 847f729cd4e608e6feb81a342bec6cb3745c9845 Mon Sep 17 00:00:00 2001 From: Nelson Yeung Date: Sun, 22 Mar 2020 21:02:47 +0000 Subject: [PATCH 3/7] Add dart analysis_server doc --- doc/ale-dart.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/ale-dart.txt b/doc/ale-dart.txt index a6d88dd8..fe5ccbcd 100644 --- a/doc/ale-dart.txt +++ b/doc/ale-dart.txt @@ -2,6 +2,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 no 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 to dart. + + =============================================================================== dartanalyzer *ale-dart-dartanalyzer* From 850c41b2a9556254a883a94f3f3c74374109a77b Mon Sep 17 00:00:00 2001 From: Nelson Yeung Date: Wed, 25 Mar 2020 20:36:57 +0000 Subject: [PATCH 4/7] Fix linting errors --- ale_linters/dart/analysis_server.vim | 1 + doc/ale-supported-languages-and-tools.txt | 1 + doc/ale.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/ale_linters/dart/analysis_server.vim b/ale_linters/dart/analysis_server.vim index 4a0ea4f2..82d91334 100644 --- a/ale_linters/dart/analysis_server.vim +++ b/ale_linters/dart/analysis_server.vim @@ -14,6 +14,7 @@ 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' 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| From a8acac1f4aea5fbe5bc856da6ce63881332d28d4 Mon Sep 17 00:00:00 2001 From: Nelson Yeung Date: Tue, 8 Dec 2020 21:17:31 +0000 Subject: [PATCH 5/7] Add support for standalone files --- ale_linters/dart/analysis_server.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/dart/analysis_server.vim b/ale_linters/dart/analysis_server.vim index 82d91334..ba8839bd 100644 --- a/ale_linters/dart/analysis_server.vim +++ b/ale_linters/dart/analysis_server.vim @@ -8,7 +8,7 @@ function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort " support for pubspec.yml let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml') - return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '' + return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.' endfunction function! ale_linters#dart#analysis_server#GetCommand(buffer) abort From efe65f347719a34e5d60e056f2cc3dc0356af10e Mon Sep 17 00:00:00 2001 From: Nelson Yeung Date: Wed, 20 Jan 2021 19:29:30 +0000 Subject: [PATCH 6/7] Add command callback tests --- ...st_dart_analysis_server_command_callback.vader | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/command_callback/test_dart_analysis_server_command_callback.vader 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' From 985a5295a9eaa4451ccf5616efd8262adbd06b39 Mon Sep 17 00:00:00 2001 From: Nelson Yeung Date: Wed, 20 Jan 2021 19:32:37 +0000 Subject: [PATCH 7/7] Fix typos --- ale_linters/dart/analysis_server.vim | 2 +- doc/ale-dart.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ale_linters/dart/analysis_server.vim b/ale_linters/dart/analysis_server.vim index ba8839bd..a6870da9 100644 --- a/ale_linters/dart/analysis_server.vim +++ b/ale_linters/dart/analysis_server.vim @@ -1,4 +1,4 @@ -" Author: Nelson Yeung +" Author: Nelson Yeung " Description: Check Dart files with dart analysis server LSP call ale#Set('dart_analysis_server_executable', 'dart') diff --git a/doc/ale-dart.txt b/doc/ale-dart.txt index fe5ccbcd..01089252 100644 --- a/doc/ale-dart.txt +++ b/doc/ale-dart.txt @@ -10,7 +10,7 @@ Installation Install Dart via whatever means. `analysis_server` will be included in the SDK. -In case that `dart` is no in your path, try to set the executable option to +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' @@ -24,7 +24,7 @@ g:ale_dart_analysis_server_executable *g:ale_dart_analysis_server_executable* Type: |String| Default: `'dart'` - This variable can be set to change the path to dart. + This variable can be set to change the path of dart. ===============================================================================