mirror of https://github.com/amix/vimrc.git
parent
a8f0b6f678
commit
65de68fa88
@ -0,0 +1,28 @@ |
||||
" Author: ghsang <gwonhyuksang@gmail.com> |
||||
" Description: Check Dart files with dart analyze |
||||
|
||||
call ale#Set('dart_analyze_executable', 'dart') |
||||
|
||||
function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort |
||||
let l:pattern = '\v^ ([a-z]+) - (.+):(\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[5], |
||||
\ 'lnum': str2nr(l:match[3]), |
||||
\ 'col': str2nr(l:match[4]), |
||||
\}) |
||||
endfor |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
call ale#linter#Define('dart', { |
||||
\ 'name': 'dart_analyze', |
||||
\ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')}, |
||||
\ 'command': '%e analyze %s', |
||||
\ 'callback': 'ale_linters#dart#dart_analyze#Handle', |
||||
\ 'lint_file': 1, |
||||
\}) |
@ -1,37 +0,0 @@ |
||||
" Author: aurieh <me@aurieh.me> |
||||
" Description: A language server for Python |
||||
|
||||
call ale#Set('python_pyls_executable', 'pyls') |
||||
call ale#Set('python_pyls_options', '') |
||||
call ale#Set('python_pyls_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
call ale#Set('python_pyls_auto_pipenv', 0) |
||||
call ale#Set('python_pyls_config', {}) |
||||
|
||||
function! ale_linters#python#pyls#GetExecutable(buffer) abort |
||||
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyls_auto_pipenv')) |
||||
\ && ale#python#PipenvPresent(a:buffer) |
||||
return 'pipenv' |
||||
endif |
||||
|
||||
return ale#python#FindExecutable(a:buffer, 'python_pyls', ['pyls']) |
||||
endfunction |
||||
|
||||
function! ale_linters#python#pyls#GetCommand(buffer) abort |
||||
let l:executable = ale_linters#python#pyls#GetExecutable(a:buffer) |
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv$' |
||||
\ ? ' run pyls' |
||||
\ : '' |
||||
|
||||
return ale#Escape(l:executable) . l:exec_args . ale#Pad(ale#Var(a:buffer, 'python_pyls_options')) |
||||
endfunction |
||||
|
||||
call ale#linter#Define('python', { |
||||
\ 'name': 'pyls', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable': function('ale_linters#python#pyls#GetExecutable'), |
||||
\ 'command': function('ale_linters#python#pyls#GetCommand'), |
||||
\ 'project_root': function('ale#python#FindProjectRoot'), |
||||
\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', |
||||
\ 'lsp_config': {b -> ale#Var(b, 'python_pyls_config')}, |
||||
\}) |
@ -0,0 +1,43 @@ |
||||
" Author: aurieh <me@aurieh.me> |
||||
" Description: A language server for Python |
||||
|
||||
call ale#Set('python_pylsp_executable', 'pylsp') |
||||
call ale#Set('python_pylsp_options', '') |
||||
call ale#Set('python_pylsp_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
call ale#Set('python_pylsp_auto_pipenv', 0) |
||||
call ale#Set('python_pylsp_auto_poetry', 0) |
||||
call ale#Set('python_pylsp_config', {}) |
||||
|
||||
function! ale_linters#python#pylsp#GetExecutable(buffer) abort |
||||
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylsp_auto_pipenv')) |
||||
\ && ale#python#PipenvPresent(a:buffer) |
||||
return 'pipenv' |
||||
endif |
||||
|
||||
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylsp_auto_poetry')) |
||||
\ && ale#python#PoetryPresent(a:buffer) |
||||
return 'poetry' |
||||
endif |
||||
|
||||
return ale#python#FindExecutable(a:buffer, 'python_pylsp', ['pylsp']) |
||||
endfunction |
||||
|
||||
function! ale_linters#python#pylsp#GetCommand(buffer) abort |
||||
let l:executable = ale_linters#python#pylsp#GetExecutable(a:buffer) |
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry$' |
||||
\ ? ' run pylsp' |
||||
\ : '' |
||||
|
||||
return ale#Escape(l:executable) . l:exec_args . ale#Pad(ale#Var(a:buffer, 'python_pylsp_options')) |
||||
endfunction |
||||
|
||||
call ale#linter#Define('python', { |
||||
\ 'name': 'pylsp', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable': function('ale_linters#python#pylsp#GetExecutable'), |
||||
\ 'command': function('ale_linters#python#pylsp#GetCommand'), |
||||
\ 'project_root': function('ale#python#FindProjectRoot'), |
||||
\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', |
||||
\ 'lsp_config': {b -> ale#Var(b, 'python_pylsp_config')}, |
||||
\}) |
@ -0,0 +1,7 @@ |
||||
call ale#linter#Define('racket', { |
||||
\ 'name': 'racket_langserver', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable': 'racket', |
||||
\ 'command': '%e -l racket-langserver', |
||||
\ 'project_root': function('ale#racket#FindProjectRoot'), |
||||
\}) |
@ -0,0 +1,42 @@ |
||||
" Author: Nathan Sharp <nwsharp+eda@live.com> |
||||
" Description: Yosys for Verilog files |
||||
|
||||
call ale#Set('verilog_yosys_executable', 'yosys') |
||||
call ale#Set('verilog_yosys_options', '-Q -T -p ''read_verilog %s''') |
||||
|
||||
function! ale_linters#verilog#yosys#GetCommand(buffer) abort |
||||
return '%e ' . ale#Var(a:buffer, 'verilog_yosys_options') . ' 2>&1' |
||||
endfunction |
||||
|
||||
function! ale_linters#verilog#yosys#Handle(buffer, lines) abort |
||||
let l:output = [] |
||||
let l:path = fnamemodify(bufname(a:buffer), ':p') |
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, '^\([^:]\+\):\(\d\+\): \(WARNING\|ERROR\): \(.\+\)$') |
||||
call add(l:output, { |
||||
\ 'lnum': str2nr(l:match[2]), |
||||
\ 'text': l:match[4], |
||||
\ 'type': l:match[3][0], |
||||
\ 'filename': l:match[1], |
||||
\}) |
||||
endfor |
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, '^\(Warning\|ERROR\): \(.\+\)$') |
||||
call add(l:output, { |
||||
\ 'lnum': 1, |
||||
\ 'text': l:match[2], |
||||
\ 'type': l:match[1][0], |
||||
\}) |
||||
endfor |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
call ale#linter#Define('verilog', { |
||||
\ 'name': 'yosys', |
||||
\ 'output_stream': 'stdout', |
||||
\ 'executable': {b -> ale#Var(b, 'verilog_yosys_executable')}, |
||||
\ 'command': function('ale_linters#verilog#yosys#GetCommand'), |
||||
\ 'callback': 'ale_linters#verilog#yosys#Handle', |
||||
\ 'lint_file': 1, |
||||
\}) |
@ -0,0 +1,28 @@ |
||||
" Author: circld <circld1@gmail.com> |
||||
" Description: Fixing files with autoflake. |
||||
|
||||
call ale#Set('python_autoflake_executable', 'autoflake') |
||||
call ale#Set('python_autoflake_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
call ale#Set('python_autoflake_options', '') |
||||
|
||||
function! ale#fixers#autoflake#Fix(buffer) abort |
||||
let l:executable = ale#python#FindExecutable( |
||||
\ a:buffer, |
||||
\ 'python_autoflake', |
||||
\ ['autoflake'], |
||||
\) |
||||
|
||||
if !executable(l:executable) |
||||
return 0 |
||||
endif |
||||
|
||||
let l:options = ale#Var(a:buffer, 'python_autoflake_options') |
||||
|
||||
return { |
||||
\ 'command': ale#Escape(l:executable) |
||||
\ . (!empty(l:options) ? ' ' . l:options : '') |
||||
\ . ' --in-place ' |
||||
\ . ' %t', |
||||
\ 'read_temporary_file': 1, |
||||
\} |
||||
endfunction |
@ -0,0 +1,18 @@ |
||||
" Author: ghsang <gwonhyuksang@gmail.com> |
||||
" Description: Integration of dart format with ALE. |
||||
|
||||
call ale#Set('dart_format_executable', 'dart') |
||||
call ale#Set('dart_format_options', '') |
||||
|
||||
function! ale#fixers#dart_format#Fix(buffer) abort |
||||
let l:executable = ale#Var(a:buffer, 'dart_format_executable') |
||||
let l:options = ale#Var(a:buffer, 'dart_format_options') |
||||
|
||||
return { |
||||
\ 'command': ale#Escape(l:executable) |
||||
\ . ' format' |
||||
\ . (empty(l:options) ? '' : ' ' . l:options) |
||||
\ . ' %t', |
||||
\ 'read_temporary_file': 1, |
||||
\} |
||||
endfunction |
@ -0,0 +1,16 @@ |
||||
" Author: Mathias Jean Johansen <mathias@mjj.io> |
||||
" Description: Integration of LuaFormatter with ALE. |
||||
|
||||
call ale#Set('lua_lua_format_executable', 'lua-format') |
||||
call ale#Set('lua_lua_format_options', '') |
||||
|
||||
function! ale#fixers#lua_format#Fix(buffer) abort |
||||
let l:executable = ale#Var(a:buffer, 'lua_lua_format_executable') |
||||
let l:options = ale#Var(a:buffer, 'lua_lua_format_options') |
||||
|
||||
return { |
||||
\ 'command': ale#Escape(l:executable) |
||||
\ . ale#Pad(l:options) |
||||
\ . ' -i', |
||||
\} |
||||
endfunction |
@ -0,0 +1,12 @@ |
||||
function! ale#racket#FindProjectRoot(buffer) abort |
||||
let l:cwd = expand('#' . a:buffer . ':p:h') |
||||
let l:highest_init = l:cwd |
||||
|
||||
for l:path in ale#path#Upwards(l:cwd) |
||||
if filereadable(l:path.'/init.rkt') |
||||
let l:highest_init = l:path |
||||
endif |
||||
endfor |
||||
|
||||
return l:highest_init |
||||
endfunction |
@ -1,6 +1,24 @@ |
||||
=============================================================================== |
||||
ALE Lua Integration *ale-lua-options* |
||||
|
||||
=============================================================================== |
||||
lua-format *ale-lua-lua-format* |
||||
|
||||
g:ale_lua_lua_format_executable *g:ale_lua_lua_format_executable* |
||||
*b:ale_lua_lua_format_executable* |
||||
Type: |String| |
||||
Default: `'lua-format'` |
||||
|
||||
This variable can be changed to change the path to lua-format. |
||||
|
||||
g:ale_lua_lua_format_options *g:ale_lua_lua_format_options* |
||||
*b:ale_lua_lua_format_options* |
||||
Type: |String| |
||||
Default: `''` |
||||
|
||||
This variable can be set to pass additional options to lua-format. |
||||
|
||||
|
||||
=============================================================================== |
||||