mirror of
				https://github.com/amix/vimrc
				synced 2025-11-01 07:33:34 +08:00 
			
		
		
		
	Removed syntastic and replaced it with ale
Read more here: https://github.com/w0rp/ale
This commit is contained in:
		
							
								
								
									
										41
									
								
								sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | ||||
| " Author: w0rp <devw0rp@gmail.com> | ||||
| " Description: Check Dart files with dartanalyzer | ||||
|  | ||||
| call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer') | ||||
|  | ||||
| function! ale_linters#dart#dartanalyzer#GetExecutable(buffer) abort | ||||
|     return ale#Var(a:buffer, 'dart_dartanalyzer_executable') | ||||
| endfunction | ||||
|  | ||||
| function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort | ||||
|     let l:executable = ale_linters#dart#dartanalyzer#GetExecutable(a:buffer) | ||||
|     let l:path = ale#path#FindNearestFile(a:buffer, '.packages') | ||||
|  | ||||
|     return ale#Escape(l:executable) | ||||
|     \   . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '') | ||||
|     \   . ' %s' | ||||
| endfunction | ||||
|  | ||||
| function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort | ||||
|     let l:pattern = '\v^  ([a-z]+) . (.+) at (.+):(\d+):(\d+) . (.+)$' | ||||
|     let l:output = [] | ||||
|  | ||||
|     for l:match in ale#util#GetMatches(a:lines, l:pattern) | ||||
|         call add(l:output, { | ||||
|         \   'type': l:match[1] is# 'error' ? 'E' : 'W', | ||||
|         \   'text': l:match[6] . ': ' . l:match[2], | ||||
|         \   'lnum': str2nr(l:match[4]), | ||||
|         \   'col': str2nr(l:match[5]), | ||||
|         \}) | ||||
|     endfor | ||||
|  | ||||
|     return l:output | ||||
| endfunction | ||||
|  | ||||
| call ale#linter#Define('dart', { | ||||
| \   'name': 'dartanalyzer', | ||||
| \   'executable_callback': 'ale_linters#dart#dartanalyzer#GetExecutable', | ||||
| \   'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand', | ||||
| \   'callback': 'ale_linters#dart#dartanalyzer#Handle', | ||||
| \   'lint_file': 1, | ||||
| \}) | ||||
							
								
								
									
										30
									
								
								sources_non_forked/ale/ale_linters/dart/language_server.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								sources_non_forked/ale/ale_linters/dart/language_server.vim
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| " Author: aurieh <me@aurieh.me> | ||||
| " Description: A language server for dart | ||||
|  | ||||
| call ale#Set('dart_language_server_executable', 'dart_language_server') | ||||
|  | ||||
| function! ale_linters#dart#language_server#GetExecutable(buffer) abort | ||||
|     return ale#Var(a:buffer, 'dart_language_server_executable') | ||||
| endfunction | ||||
|  | ||||
| function! ale_linters#dart#language_server#GetLanguage(buffer) abort | ||||
|     return 'dart' | ||||
| endfunction | ||||
|  | ||||
| function! ale_linters#dart#language_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 | ||||
|  | ||||
| call ale#linter#Define('dart', { | ||||
| \   'name': 'language_server', | ||||
| \   'lsp': 'stdio', | ||||
| \   'executable_callback': 'ale_linters#dart#language_server#GetExecutable', | ||||
| \   'command_callback': 'ale_linters#dart#language_server#GetExecutable', | ||||
| \   'language_callback': 'ale_linters#dart#language_server#GetLanguage', | ||||
| \   'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot', | ||||
| \}) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Amir Salihefendic
					Amir Salihefendic