diff options
author | Nelson Yeung <nelsyeung@icloud.com> | 2020-03-22 20:39:40 +0000 |
---|---|---|
committer | Nelson Yeung <nelsyeung@gmail.com> | 2021-01-22 16:37:38 +0000 |
commit | 35b8bb8a554741e9cd132ae82e9cc4a82f8f361d (patch) | |
tree | 26e4246d0cc2a6a31f83477483d9e9977d651cf4 /ale_linters/dart | |
parent | 9a1e91e075abf386e8c6fd620ec0835e566a7db1 (diff) | |
download | ale-35b8bb8a554741e9cd132ae82e9cc4a82f8f361d.zip |
Add dart analysis server linter
Diffstat (limited to 'ale_linters/dart')
-rw-r--r-- | ale_linters/dart/analysis_server.vim | 28 |
1 files changed, 28 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..4a0ea4f2 --- /dev/null +++ b/ale_linters/dart/analysis_server.vim @@ -0,0 +1,28 @@ +" Author: Nelson Yeung <nelsyeung@icloud.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'), +\}) |