mirror of https://github.com/amix/vimrc.git
parent
993ed55304
commit
2f164fee9b
@ -0,0 +1,35 @@ |
||||
" Author: Yasuhiro Kiyota <yasuhiroki.duck@gmail.com> |
||||
" Description: Support cfn-python-lint for AWS Cloudformation template file |
||||
|
||||
function! ale_linters#cloudformation#cfn_python_lint#Handle(buffer, lines) abort |
||||
" Matches patterns line the following: |
||||
" |
||||
" sample.template.yaml:96:7:96:15:E3012:Property Resources/Sample/Properties/FromPort should be of type Integer |
||||
let l:pattern = '\v^(.*):(\d+):(\d+):(\d+):(\d+):([[:alnum:]]+):(.*)$' |
||||
let l:output = [] |
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern) |
||||
let l:code = l:match[6] |
||||
|
||||
if ale#path#IsBufferPath(a:buffer, l:match[1]) |
||||
call add(l:output, { |
||||
\ 'lnum': l:match[2], |
||||
\ 'col': l:match[3], |
||||
\ 'end_lnum': l:match[4], |
||||
\ 'end_col': l:match[5], |
||||
\ 'code': l:code, |
||||
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W', |
||||
\ 'text': l:match[7] |
||||
\}) |
||||
endif |
||||
endfor |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
call ale#linter#Define('cloudformation', { |
||||
\ 'name': 'cloudformation', |
||||
\ 'executable': 'cfn-lint', |
||||
\ 'command': 'cfn-lint --template %t --format parseable', |
||||
\ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle', |
||||
\}) |
@ -0,0 +1,61 @@ |
||||
" Author: evnu - https://github.com/evnu |
||||
" Author: colbydehart - https://github.com/colbydehart |
||||
" Description: Mix compile checking for Elixir files |
||||
|
||||
function! ale_linters#elixir#mix#Handle(buffer, lines) abort |
||||
" Matches patterns like the following: |
||||
" |
||||
" Error format |
||||
" ** (CompileError) apps/sim/lib/sim/server.ex:87: undefined function update_in/4 |
||||
" |
||||
" TODO: Warning format |
||||
" warning: variable "foobar" does not exist and is being expanded to "foobar()", please use parentheses to remove the ambiguity or change the variable name |
||||
|
||||
let l:pattern = '\v\(([^\)]+Error)\) ([^:]+):([^:]+): (.+)$' |
||||
let l:output = [] |
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern) |
||||
let l:type = 'E' |
||||
let l:text = l:match[4] |
||||
|
||||
call add(l:output, { |
||||
\ 'bufnr': a:buffer, |
||||
\ 'lnum': l:match[3] + 0, |
||||
\ 'col': 0, |
||||
\ 'type': l:type, |
||||
\ 'text': l:text, |
||||
\}) |
||||
endfor |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
function! ale_linters#elixir#mix#FindProjectRoot(buffer) abort |
||||
let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs') |
||||
if !empty(l:mix_file) |
||||
return fnamemodify(l:mix_file, ':p:h') |
||||
endif |
||||
return '.' |
||||
endfunction |
||||
|
||||
function! ale_linters#elixir#mix#GetCommand(buffer) abort |
||||
let l:project_root = ale_linters#elixir#mix#FindProjectRoot(a:buffer) |
||||
|
||||
let l:temp_dir = ale#engine#CreateDirectory(a:buffer) |
||||
|
||||
let l:mix_build_path = has('win32') |
||||
\ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' &&' |
||||
\ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) |
||||
|
||||
return ale#path#CdString(l:project_root) |
||||
\ . l:mix_build_path |
||||
\ . ' mix compile %s' |
||||
endfunction |
||||
|
||||
call ale#linter#Define('elixir', { |
||||
\ 'name': 'mix', |
||||
\ 'executable': 'mix', |
||||
\ 'command_callback': 'ale_linters#elixir#mix#GetCommand', |
||||
\ 'callback': 'ale_linters#elixir#mix#Handle', |
||||
\ 'lint_file': 1, |
||||
\}) |
@ -0,0 +1,26 @@ |
||||
" Author: Chaucerbao, w0rp <devw0rp@gmail.com> |
||||
" Description: tsserver integration for ALE |
||||
|
||||
call ale#Set('javascript_tsserver_executable', 'tsserver') |
||||
call ale#Set('javascript_tsserver_config_path', '') |
||||
call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
|
||||
" These functions need to be defined just to comply with the API for LSP. |
||||
function! ale_linters#javascript#tsserver#GetProjectRoot(buffer) abort |
||||
return '' |
||||
endfunction |
||||
|
||||
function! ale_linters#javascript#tsserver#GetExecutable(buffer) abort |
||||
return ale#node#FindExecutable(a:buffer, 'javascript_tsserver', [ |
||||
\ 'node_modules/.bin/tsserver', |
||||
\]) |
||||
endfunction |
||||
|
||||
call ale#linter#Define('javascript', { |
||||
\ 'name': 'tsserver', |
||||
\ 'lsp': 'tsserver', |
||||
\ 'executable_callback': 'ale_linters#javascript#tsserver#GetExecutable', |
||||
\ 'command_callback': 'ale_linters#javascript#tsserver#GetExecutable', |
||||
\ 'project_root_callback': 'ale_linters#javascript#tsserver#GetProjectRoot', |
||||
\ 'language': '', |
||||
\}) |
@ -1,10 +1,43 @@ |
||||
" Author: w0rp <devw0rp@gmail.com> |
||||
" Author: w0rp <devw0rp@gmail.com>, |
||||
" Nicolas Pauss <https://github.com/nicopauss> |
||||
" Description: cython syntax checking for cython files. |
||||
|
||||
call ale#Set('pyrex_cython_executable', 'cython') |
||||
call ale#Set('pyrex_cython_options', '--warning-extra') |
||||
|
||||
function! ale_linters#pyrex#cython#GetExecutable(buffer) abort |
||||
return ale#Var(a:buffer, 'pyrex_cython_executable') |
||||
endfunction |
||||
|
||||
function! ale_linters#pyrex#cython#GetCommand(buffer) abort |
||||
let l:local_dir = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) |
||||
|
||||
return ale#Escape(ale_linters#pyrex#cython#GetExecutable(a:buffer)) |
||||
\ . ' --working ' . l:local_dir . ' --include-dir ' . l:local_dir |
||||
\ . ' ' . ale#Var(a:buffer, 'pyrex_cython_options') |
||||
\ . ' --output-file ' . g:ale#util#nul_file . ' %t' |
||||
endfunction |
||||
|
||||
function! ale_linters#pyrex#cython#Handle(buffer, lines) abort |
||||
let l:pattern = '\v^(\w+: )?[^:]+:(\d+):?(\d+)?:? ?(.+)$' |
||||
let l:output = [] |
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern) |
||||
call add(l:output, { |
||||
\ 'lnum': l:match[2] + 0, |
||||
\ 'col': l:match[3] + 0, |
||||
\ 'text': l:match[4], |
||||
\ 'type': l:match[1][0] is# 'w' ? 'W' : 'E', |
||||
\}) |
||||
endfor |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
call ale#linter#Define('pyrex', { |
||||
\ 'name': 'cython', |
||||
\ 'output_stream': 'stderr', |
||||
\ 'executable': 'cython', |
||||
\ 'command': 'cython --warning-extra -o ' . g:ale#util#nul_file . ' %t', |
||||
\ 'callback': 'ale#handlers#unix#HandleAsError', |
||||
\ 'executable_callback': 'ale_linters#pyrex#cython#GetExecutable', |
||||
\ 'command_callback': 'ale_linters#pyrex#cython#GetCommand', |
||||
\ 'callback': 'ale_linters#pyrex#cython#Handle', |
||||
\}) |
||||
|
@ -0,0 +1,29 @@ |
||||
" Author: dsifford <dereksifford@gmail.com> |
||||
" Description: A performant type-checker supporting LSP for Python 3 created by Facebook |
||||
|
||||
call ale#Set('python_pyre_executable', 'pyre') |
||||
call ale#Set('python_pyre_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
|
||||
function! ale_linters#python#pyre#GetExecutable(buffer) abort |
||||
return ale#python#FindExecutable(a:buffer, 'python_pyre', ['pyre']) |
||||
endfunction |
||||
|
||||
function! ale_linters#python#pyre#GetCommand(buffer) abort |
||||
let l:executable = ale_linters#python#pyre#GetExecutable(a:buffer) |
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv$' |
||||
\ ? ' run pyre persistent' |
||||
\ : ' persistent' |
||||
|
||||
return ale#Escape(l:executable) . l:exec_args |
||||
endfunction |
||||
|
||||
call ale#linter#Define('python', { |
||||
\ 'name': 'pyre', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable_callback': 'ale_linters#python#pyre#GetExecutable', |
||||
\ 'command_callback': 'ale_linters#python#pyre#GetCommand', |
||||
\ 'language': 'python', |
||||
\ 'project_root_callback': 'ale#python#FindProjectRoot', |
||||
\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', |
||||
\}) |
@ -0,0 +1,33 @@ |
||||
" Author: Christian Hรถltje (https://docwhat.org/) |
||||
" Description: BASH Language server integration for ALE |
||||
scriptencoding utf-8 |
||||
|
||||
call ale#Set('sh_language_server_executable', 'bash-language-server') |
||||
call ale#Set('sh_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
|
||||
function! ale_linters#sh#language_server#GetExecutable(buffer) abort |
||||
return ale#node#FindExecutable(a:buffer, 'sh_language_server', [ |
||||
\ 'node_modules/.bin/bash-language-server', |
||||
\]) |
||||
endfunction |
||||
|
||||
function! ale_linters#sh#language_server#GetCommand(buffer) abort |
||||
let l:exe = ale#Escape(ale_linters#sh#language_server#GetExecutable(a:buffer)) |
||||
|
||||
return l:exe . ' start' |
||||
endfunction |
||||
|
||||
function! ale_linters#sh#language_server#GetProjectRoot(buffer) abort |
||||
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') |
||||
|
||||
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' |
||||
endfunction |
||||
|
||||
call ale#linter#Define('sh', { |
||||
\ 'name': 'language_server', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable_callback': 'ale_linters#sh#language_server#GetExecutable', |
||||
\ 'command_callback': 'ale_linters#sh#language_server#GetCommand', |
||||
\ 'language': 'sh', |
||||
\ 'project_root_callback': 'ale_linters#sh#language_server#GetProjectRoot', |
||||
\}) |
@ -1,77 +0,0 @@ |
||||
function! ale#autocmd#InitAuGroups() abort |
||||
" This value used to be a Boolean as a Number, and is now a String. |
||||
let l:text_changed = '' . g:ale_lint_on_text_changed |
||||
|
||||
augroup ALEPatternOptionsGroup |
||||
autocmd! |
||||
autocmd BufEnter,BufRead * call ale#pattern_options#SetOptions(str2nr(expand('<abuf>'))) |
||||
augroup END |
||||
|
||||
augroup ALERunOnTextChangedGroup |
||||
autocmd! |
||||
if g:ale_enabled |
||||
if l:text_changed is? 'always' || l:text_changed is# '1' |
||||
autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay) |
||||
elseif l:text_changed is? 'normal' |
||||
autocmd TextChanged * call ale#Queue(g:ale_lint_delay) |
||||
elseif l:text_changed is? 'insert' |
||||
autocmd TextChangedI * call ale#Queue(g:ale_lint_delay) |
||||
endif |
||||
endif |
||||
augroup END |
||||
|
||||
augroup ALERunOnEnterGroup |
||||
autocmd! |
||||
if g:ale_enabled |
||||
" Handle everything that needs to happen when buffers are entered. |
||||
autocmd BufEnter * call ale#events#EnterEvent(str2nr(expand('<abuf>'))) |
||||
endif |
||||
if g:ale_enabled && g:ale_lint_on_enter |
||||
autocmd BufWinEnter,BufRead * call ale#Queue(0, 'lint_file', str2nr(expand('<abuf>'))) |
||||
" Track when the file is changed outside of Vim. |
||||
autocmd FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand('<abuf>'))) |
||||
endif |
||||
augroup END |
||||
|
||||
augroup ALERunOnFiletypeChangeGroup |
||||
autocmd! |
||||
if g:ale_enabled && g:ale_lint_on_filetype_changed |
||||
" Only start linting if the FileType actually changes after |
||||
" opening a buffer. The FileType will fire when buffers are opened. |
||||
autocmd FileType * call ale#events#FileTypeEvent( |
||||
\ str2nr(expand('<abuf>')), |
||||
\ expand('<amatch>') |
||||
\) |
||||
endif |
||||
augroup END |
||||
|
||||
augroup ALERunOnSaveGroup |
||||
autocmd! |
||||
autocmd BufWritePost * call ale#events#SaveEvent(str2nr(expand('<abuf>'))) |
||||
augroup END |
||||
|
||||
augroup ALERunOnInsertLeave |
||||
autocmd! |
||||
if g:ale_enabled && g:ale_lint_on_insert_leave |
||||
autocmd InsertLeave * call ale#Queue(0) |
||||
endif |
||||
augroup END |
||||
|
||||
augroup ALECursorGroup |
||||
autocmd! |
||||
if g:ale_enabled && g:ale_echo_cursor |
||||
autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay() |
||||
" Look for a warning to echo as soon as we leave Insert mode. |
||||
" The script's position variable used when moving the cursor will |
||||
" not be changed here. |
||||
autocmd InsertLeave * call ale#cursor#EchoCursorWarning() |
||||
endif |
||||
augroup END |
||||
|
||||
if !g:ale_enabled |
||||
augroup! ALERunOnTextChangedGroup |
||||
augroup! ALERunOnEnterGroup |
||||
augroup! ALERunOnInsertLeave |
||||
augroup! ALECursorGroup |
||||
endif |
||||
endfunction |
@ -0,0 +1,46 @@ |
||||
" Author: w0rp <devw0rp@gmail.com> |
||||
" Description: Code for ignoring linters. Only loaded and if configured. |
||||
|
||||
" Given a filetype and a configuration for ignoring linters, return a List of |
||||
" Strings for linter names to ignore. |
||||
function! ale#engine#ignore#GetList(filetype, config) abort |
||||
if type(a:config) is type([]) |
||||
return a:config |
||||
endif |
||||
|
||||
if type(a:config) is type({}) |
||||
let l:names_to_remove = [] |
||||
|
||||
for l:part in split(a:filetype , '\.') |
||||
call extend(l:names_to_remove, get(a:config, l:part, [])) |
||||
endfor |
||||
|
||||
return l:names_to_remove |
||||
endif |
||||
|
||||
return [] |
||||
endfunction |
||||
|
||||
" Given a List of linter descriptions, exclude the linters to be ignored. |
||||
function! ale#engine#ignore#Exclude(filetype, all_linters, config) abort |
||||
let l:names_to_remove = ale#engine#ignore#GetList(a:filetype, a:config) |
||||
let l:filtered_linters = [] |
||||
|
||||
for l:linter in a:all_linters |
||||
let l:name_list = [l:linter.name] + l:linter.aliases |
||||
let l:should_include = 1 |
||||
|
||||
for l:name in l:name_list |
||||
if index(l:names_to_remove, l:name) >= 0 |
||||
let l:should_include = 0 |
||||
break |
||||
endif |
||||
endfor |
||||
|
||||
if l:should_include |
||||
call add(l:filtered_linters, l:linter) |
||||
endif |
||||
endfor |
||||
|
||||
return l:filtered_linters |
||||
endfunction |