This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/ale_linters/dart/analysis_server.vim

30 lines
1.1 KiB
VimL
Raw Normal View History

2021-01-20 19:32:37 +00:00
" Author: Nelson Yeung <nelsyeung@gmail.com>
2020-03-22 20:39:40 +00:00
" 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')
2020-12-08 21:17:31 +00:00
return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.'
2020-03-22 20:39:40 +00:00
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))
2020-03-25 20:36:57 +00:00
2020-03-22 20:39:40 +00:00
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'),
\})