Add argon ale linter and allow local linters
This commit is contained in:
		
							parent
							
								
									6b6c3628bb
								
							
						
					
					
						commit
						901d336d82
					
				
							
								
								
									
										64
									
								
								ale_linters/haskell/argon.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								ale_linters/haskell/argon.vim
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,64 @@
 | 
				
			|||||||
 | 
					" Author: Julian Ospald <hasufell@hasufell.de>
 | 
				
			||||||
 | 
					" Description: argon for Haskell files
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					call ale#Set('haskell_argon_executable', 'argon')
 | 
				
			||||||
 | 
					call ale#Set('haskell_argon_options', '')
 | 
				
			||||||
 | 
					call ale#Set('haskell_argon_error_level', 12)
 | 
				
			||||||
 | 
					call ale#Set('haskell_argon_warn_level', 8)
 | 
				
			||||||
 | 
					call ale#Set('haskell_argon_info_level', 4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function! ale_linters#haskell#argon#GetExecutable(buffer) abort
 | 
				
			||||||
 | 
					    return ale#Var(a:buffer, 'haskell_argon_executable')
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function! ale_linters#haskell#argon#GetCommand(buffer) abort
 | 
				
			||||||
 | 
					    return ale#Escape(ale_linters#haskell#argon#GetExecutable(a:buffer))
 | 
				
			||||||
 | 
					    \   . ' '
 | 
				
			||||||
 | 
					    \   . ale#Var(a:buffer, 'haskell_argon_options')
 | 
				
			||||||
 | 
					    \   . ' -m ' . ale#Var(a:buffer, 'haskell_argon_info_level')
 | 
				
			||||||
 | 
					    \   . ' -j'
 | 
				
			||||||
 | 
					    \   . ' %t'
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function! ale_linters#haskell#argon#Handle(buffer, lines) abort
 | 
				
			||||||
 | 
					    let l:output = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
 | 
				
			||||||
 | 
					        for l:block in l:error.blocks
 | 
				
			||||||
 | 
					            let l:complexity = l:block.complexity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if l:complexity >= ale#Var(a:buffer, 'haskell_argon_error_level')
 | 
				
			||||||
 | 
					                let l:type = 'E'
 | 
				
			||||||
 | 
					                let l:max_c = ale#Var(a:buffer, 'haskell_argon_error_level')
 | 
				
			||||||
 | 
					            elseif l:complexity >= ale#Var(a:buffer, 'haskell_argon_warn_level')
 | 
				
			||||||
 | 
					                let l:type = 'W'
 | 
				
			||||||
 | 
					                let l:max_c = ale#Var(a:buffer, 'haskell_argon_warn_level')
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					                let l:type = 'I'
 | 
				
			||||||
 | 
					                let l:max_c = ale#Var(a:buffer, 'haskell_argon_info_level')
 | 
				
			||||||
 | 
					            endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            call add(l:output, {
 | 
				
			||||||
 | 
					            \   'filename': l:error.path,
 | 
				
			||||||
 | 
					            \   'lnum': str2nr(l:block.lineno),
 | 
				
			||||||
 | 
					            \   'col': str2nr(l:block.col),
 | 
				
			||||||
 | 
					            \   'text': l:block.name . ': cyclomatic complexity of '  . l:complexity,
 | 
				
			||||||
 | 
					            \   'type': l:type,
 | 
				
			||||||
 | 
					            \})
 | 
				
			||||||
 | 
					        endfor
 | 
				
			||||||
 | 
					    endfor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return l:output
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					call ale#linter#Define('haskell', {
 | 
				
			||||||
 | 
					\   'name': 'argon',
 | 
				
			||||||
 | 
					\   'executable_callback': 'ale_linters#haskell#argon#GetExecutable',
 | 
				
			||||||
 | 
					\   'command_callback': 'ale_linters#haskell#argon#GetCommand',
 | 
				
			||||||
 | 
					\   'callback': 'ale_linters#haskell#argon#Handle',
 | 
				
			||||||
 | 
					\})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								vimrc
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								vimrc
									
									
									
									
									
								
							@ -80,7 +80,9 @@ Plug 'autozimu/LanguageClient-neovim', {
 | 
				
			|||||||
Plug 'junegunn/fzf', { 'for': 'haskell' }
 | 
					Plug 'junegunn/fzf', { 'for': 'haskell' }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" linting/compilation
 | 
					" linting/compilation
 | 
				
			||||||
Plug 'w0rp/ale'
 | 
					Plug 'w0rp/ale', {
 | 
				
			||||||
 | 
						\ 'do': 'bash -c \"cp -R ~/.vim/ale_linters .\"',
 | 
				
			||||||
 | 
						\ }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" haskell
 | 
					" haskell
 | 
				
			||||||
" if has("nvim")
 | 
					" if has("nvim")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user