mirror of https://github.com/dense-analysis/ale
Update dart analysis_server command (#4761)
* Update dart analysis_server command
In 2021 the dart team added a new sub-command `language-server` to
replace the original `./snapshots/analysis_server.dart.snapshot --lsp`
convention for starting the language server.
c224cc2e0d
* Add ale_dart_analysis_server_enable_language_server option
This allows users to opt-in to the new `dart language-server` command.
* Enable ale_dart_analysis_server_enable_language_server option by default
* Update doc/ale-dart.txt
Include the dart version number where the `dart language-server` command
was added.
This commit is contained in:
parent
70eeae54fb
commit
c88bddfa83
|
@ -1,6 +1,7 @@
|
||||||
" Author: Nelson Yeung <nelsyeung@gmail.com>
|
" Author: Nelson Yeung <nelsyeung@gmail.com>
|
||||||
" Description: Check Dart files with dart analysis server LSP
|
" Description: Check Dart files with dart analysis server LSP
|
||||||
|
|
||||||
|
call ale#Set('dart_analysis_server_enable_language_server', 1)
|
||||||
call ale#Set('dart_analysis_server_executable', 'dart')
|
call ale#Set('dart_analysis_server_executable', 'dart')
|
||||||
|
|
||||||
function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort
|
function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort
|
||||||
|
@ -12,12 +13,19 @@ function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#dart#analysis_server#GetCommand(buffer) abort
|
function! ale_linters#dart#analysis_server#GetCommand(buffer) abort
|
||||||
|
let l:language_server = ale#Var(a:buffer, 'dart_analysis_server_enable_language_server')
|
||||||
let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable')
|
let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable')
|
||||||
let l:dart = resolve(exepath(l:executable))
|
let l:dart = resolve(exepath(l:executable))
|
||||||
|
let l:output = '%e '
|
||||||
return '%e '
|
|
||||||
\ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot'
|
\ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot'
|
||||||
\ . ' --lsp'
|
\ . ' --lsp'
|
||||||
|
|
||||||
|
" Enable new language-server command
|
||||||
|
if l:language_server == 1
|
||||||
|
let l:output = '%e language-server --protocol=lsp'
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('dart', {
|
call ale#linter#Define('dart', {
|
||||||
|
|
|
@ -27,6 +27,19 @@ g:ale_dart_analysis_server_executable *g:ale_dart_analysis_server_executable*
|
||||||
This variable can be set to change the path of dart.
|
This variable can be set to change the path of dart.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_dart_analysis_server_enable_language_server
|
||||||
|
*g:ale_dart_analysis_server_enable_language_server*
|
||||||
|
*b:ale_dart_analysis_server_enable_language_server*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `1`
|
||||||
|
|
||||||
|
When set to `1`, ALE will use the new `dart language-server` command,
|
||||||
|
available from Dart version 2.16.0, to launch the language server. When set
|
||||||
|
to `0`, ALE will instead use the deprecated
|
||||||
|
`./snapshots/analysis_server.dart.snapshot --lsp` command used by older
|
||||||
|
versions of Dart.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
dart-analyze *ale-dart-analyze*
|
dart-analyze *ale-dart-analyze*
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,16 @@ After:
|
||||||
|
|
||||||
Execute(The default command should be correct):
|
Execute(The default command should be correct):
|
||||||
AssertLinter 'dart', ale#Escape('dart')
|
AssertLinter 'dart', ale#Escape('dart')
|
||||||
\ . ' ./snapshots/analysis_server.dart.snapshot --lsp'
|
\ . ' language-server --protocol=lsp'
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
Execute(The executable should be configurable):
|
||||||
let g:ale_dart_analysis_server_executable = 'foobar'
|
let g:ale_dart_analysis_server_executable = 'foobar'
|
||||||
|
|
||||||
AssertLinter 'foobar', ale#Escape('foobar')
|
AssertLinter 'foobar', ale#Escape('foobar')
|
||||||
|
\ . ' language-server --protocol=lsp'
|
||||||
|
|
||||||
|
Execute(Should be able to disable new language-server command):
|
||||||
|
let g:ale_dart_analysis_server_enable_language_server = 0
|
||||||
|
|
||||||
|
AssertLinter 'dart', ale#Escape('dart')
|
||||||
\ . ' ./snapshots/analysis_server.dart.snapshot --lsp'
|
\ . ' ./snapshots/analysis_server.dart.snapshot --lsp'
|
||||||
|
|
Loading…
Reference in New Issue