]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/dart/analysis_server.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / dart / analysis_server.vim
1 " Author: Nelson Yeung <nelsyeung@gmail.com>
2 " Description: Check Dart files with dart analysis server LSP
3
4 call ale#Set('dart_analysis_server_enable_language_server', 1)
5 call ale#Set('dart_analysis_server_executable', 'dart')
6
7 function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort
8     " Note: pub only looks for pubspec.yaml, there's no point in adding
9     " support for pubspec.yml
10     let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml')
11
12     return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.'
13 endfunction
14
15 function! ale_linters#dart#analysis_server#GetCommand(buffer) abort
16     let l:language_server = ale#Var(a:buffer, 'dart_analysis_server_enable_language_server')
17     let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable')
18     let l:dart = resolve(exepath(l:executable))
19     let l:output = '%e '
20     \   . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot'
21     \   . ' --lsp'
22
23     " Enable new language-server command
24     if l:language_server == 1
25         let l:output = '%e language-server --protocol=lsp'
26     endif
27
28     return l:output
29 endfunction
30
31 call ale#linter#Define('dart', {
32 \   'name': 'analysis_server',
33 \   'lsp': 'stdio',
34 \   'executable': {b -> ale#Var(b, 'dart_analysis_server_executable')},
35 \   'command': function('ale_linters#dart#analysis_server#GetCommand'),
36 \   'project_root': function('ale_linters#dart#analysis_server#GetProjectRoot'),
37 \})