1
0
mirror of https://github.com/amix/vimrc synced 2025-06-30 20:05:01 +08:00

Updated plugins

This commit is contained in:
Amir
2021-10-28 21:48:21 +02:00
parent e13b2a10a7
commit b39d6ca807
27 changed files with 348 additions and 120 deletions

View File

@ -16,7 +16,7 @@ endfunction
function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort
" output format
" <filename>:<line>:<column>: <issue type>: <message>
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Exception|error|warning): ?(.+))$'
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+)?:(\d+)?:? ((Exception|error|warning): ?(.+))$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)

View File

@ -55,13 +55,19 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
let l:detail = 'hadolint could not parse the file because of a syntax error.'
endif
call add(l:output, {
let l:line_output = {
\ 'lnum': l:lnum,
\ 'col': l:colnum,
\ 'type': l:type,
\ 'text': l:text,
\ 'detail': l:detail
\})
\}
if l:code isnot# ''
let l:line_output['code'] = l:code
endif
call add(l:output, l:line_output)
endfor
return l:output

View File

@ -6,7 +6,7 @@ call ale#Set('ruby_ruby_executable', 'ruby')
call ale#linter#Define('ruby', {
\ 'name': 'ruby',
\ 'executable': {b -> ale#Var(b, 'ruby_ruby_executable')},
\ 'command': '%e -w -c -T1 %t',
\ 'command': '%e -w -c %t',
\ 'output_stream': 'stderr',
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})

View File

@ -0,0 +1,22 @@
" Author: Benjamin Bannier <bbannier@gmail.com>
" Description: Support for checking Zeek files.
"
call ale#Set('zeek_zeek_executable', 'zeek')
function! ale_linters#zeek#zeek#HandleErrors(buffer, lines) abort
let l:pattern = 'error in \v.*, line (\d+): (.*)$'
return map(ale#util#GetMatches(a:lines, l:pattern), "{
\ 'lnum': str2nr(v:val[1]),
\ 'text': v:val[2],
\}")
endfunction
call ale#linter#Define('zeek', {
\ 'name': 'zeek',
\ 'executable': {b -> ale#Var(b, 'zeek_zeek_executable')},
\ 'output_stream': 'stderr',
\ 'command': {-> '%e --parse-only %s'},
\ 'callback': 'ale_linters#zeek#zeek#HandleErrors',
\ 'lint_file': 1,
\})

View File

@ -100,6 +100,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['nim'],
\ 'description': 'Apply nimpretty to a file.',
\ },
\ 'erblint': {
\ 'function': 'ale#fixers#erblint#Fix',
\ 'suggested_filetypes': ['eruby'],
\ 'description': 'Apply erblint --autocorrect to a file.',
\ },
\ 'eslint': {
\ 'function': 'ale#fixers#eslint#Fix',
\ 'suggested_filetypes': ['javascript', 'typescript'],

View File

@ -0,0 +1,40 @@
" Author: Roeland Moors - https://github.com/roelandmoors
" Description: ERB Lint, support for https://github.com/Shopify/erb-lint
call ale#Set('eruby_erblint_executable', 'erblint')
call ale#Set('eruby_erblint_options', '')
" Erblint fixer outputs diagnostics first and then the fixed
" output. These are delimited by something like this:
" ================ /path/to/demo.html.erb ==================
" We only need the output after this
function! ale#fixers#erblint#PostProcess(buffer, output) abort
let l:line = 0
for l:output in a:output
let l:line = l:line + 1
if l:output =~# "^=\\+.*=\\+$"
break
endif
endfor
return a:output[l:line :]
endfunction
function! ale#fixers#erblint#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable')
let l:options = ale#Var(a:buffer, 'eruby_erblint_options')
return ale#ruby#EscapeExecutable(l:executable, 'erblint')
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --autocorrect --stdin %s'
endfunction
function! ale#fixers#erblint#Fix(buffer) abort
return {
\ 'command': ale#fixers#erblint#GetCommand(a:buffer),
\ 'process_with': 'ale#fixers#erblint#PostProcess'
\}
endfunction

View File

@ -21,7 +21,7 @@ function! ale#fixers#isort#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort'])
endfunction
function! ale#fixers#isort#Fix(buffer) abort
function! ale#fixers#isort#GetCmd(buffer) abort
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
let l:cmd = [ale#Escape(l:executable)]
@ -29,7 +29,20 @@ function! ale#fixers#isort#Fix(buffer) abort
call extend(l:cmd, ['run', 'isort'])
endif
call add(l:cmd, '--filename %s')
return join(l:cmd, ' ')
endfunction
function! ale#fixers#isort#FixForVersion(buffer, version) abort
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
let l:cmd = [ale#Escape(l:executable)]
if l:executable =~? 'pipenv\|poetry$'
call extend(l:cmd, ['run', 'isort'])
endif
if ale#semver#GTE(a:version, [5, 7, 0])
call add(l:cmd, '--filename %s')
endif
let l:options = ale#Var(a:buffer, 'python_isort_options')
@ -41,6 +54,18 @@ function! ale#fixers#isort#Fix(buffer) abort
return {
\ 'cwd': '%s:h',
\ 'command': join(l:cmd, ' ')
\ 'command': join(l:cmd, ' '),
\}
endfunction
function! ale#fixers#isort#Fix(buffer) abort
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
let l:command = ale#fixers#isort#GetCmd(a:buffer) . ale#Pad('--version')
return ale#semver#RunWithVersionCheck(
\ a:buffer,
\ l:executable,
\ l:command,
\ function('ale#fixers#isort#FixForVersion'),
\)
endfunction

View File

@ -45,6 +45,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort
\ 'typeDefinition': 0,
\ 'symbol_search': 0,
\ 'code_actions': 0,
\ 'did_save': 0,
\ 'includeText': 0,
\ },
\}
@ -265,15 +266,19 @@ function! s:UpdateCapabilities(conn, capabilities) abort
let a:conn.capabilities.symbol_search = 1
endif
if has_key(a:capabilities, 'textDocumentSync')
if type(a:capabilities.textDocumentSync) is v:t_dict
let l:save = get(a:capabilities.textDocumentSync, 'save', v:false)
if type(get(a:capabilities, 'textDocumentSync')) is v:t_dict
let l:syncOptions = get(a:capabilities, 'textDocumentSync')
if type(l:save) is v:true
let a:conn.capabilities.includeText = 1
endif
if get(l:syncOptions, 'save') is v:true
let a:conn.capabilities.did_save = 1
endif
if type(l:save) is v:t_dict && get(a:capabilities.textDocumentSync.save, 'includeText', v:false) is v:true
if type(get(l:syncOptions, 'save')) is v:t_dict
let a:conn.capabilities.did_save = 1
let l:saveOptions = get(l:syncOptions, 'save')
if get(l:saveOptions, 'includeText') is v:true
let a:conn.capabilities.includeText = 1
endif
endif

View File

@ -466,6 +466,7 @@ function! s:CheckWithLSP(linter, details) abort
" If this was a file save event, also notify the server of that.
if a:linter.lsp isnot# 'tsserver'
\&& getbufvar(l:buffer, 'ale_save_event_fired', 0)
\&& ale#lsp#HasCapability(l:buffer, 'did_save')
let l:include_text = ale#lsp#HasCapability(l:buffer, 'includeText')
let l:save_message = ale#lsp#message#DidSave(l:buffer, l:include_text)
let l:notified = ale#lsp#Send(l:id, l:save_message) != 0

View File

@ -64,15 +64,16 @@ function! ale#virtualtext#ShowMessage(message, hl_group) abort
let l:line = line('.')
let l:buffer = bufnr('')
let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ')
let l:msg = l:prefix.trim(substitute(a:message, '\n', ' ', 'g'))
if has('nvim')
call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, a:hl_group]], {})
call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:msg, a:hl_group]], {})
else
let l:left_pad = col('$')
call prop_add(l:line, l:left_pad, {
\ 'type': 'ale',
\})
let s:last_popup = popup_create(l:prefix.a:message, {
let s:last_popup = popup_create(l:msg, {
\ 'line': -1,
\ 'padding': [0, 0, 0, 1],
\ 'mask': [[1, 1, 1, 1]],

View File

@ -601,6 +601,8 @@ Notes:
* `yamllint`
* YANG
* `yang-lsp`
* Zeek
* `zeek`!!
* Zig
* `zls`

View File

@ -0,0 +1,23 @@
===============================================================================
ALE Zeek Integration *ale-zeek-options*
*ale-integration-zeek*
===============================================================================
Integration Information
Currently, the only supported linter for Zeek is zeek.
===============================================================================
zeek *ale-zeek-zeek*
g:ale_zeek_zeek_executable *g:ale_zeek_zeek_executable*
*b:ale_zeek_zeek_executable*
Type: |String|
Default: `'zeek'`
This variable can be modified to change the executable path for `zeek`.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -3114,6 +3114,8 @@ documented in additional help files.
yamllint..............................|ale-yaml-yamllint|
yang....................................|ale-yang-options|
yang-lsp..............................|ale-yang-lsp|
zeek....................................|ale-zeek-options|
zeek..................................|ale-zeek-zeek|
zig.....................................|ale-zig-options|
zls...................................|ale-zig-zls|

View File

@ -610,5 +610,7 @@ formatting.
* [yamllint](https://yamllint.readthedocs.io/)
* YANG
* [yang-lsp](https://github.com/theia-ide/yang-lsp)
* Zeek
* [zeek](http://zeek.org) :floppy_disk:
* Zig
* [zls](https://github.com/zigtools/zls)