mirror of
https://github.com/amix/vimrc
synced 2025-07-12 14:15:00 +08:00
Updated plugins
This commit is contained in:
@ -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'],
|
||||
|
40
sources_non_forked/ale/autoload/ale/fixers/erblint.vim
Normal file
40
sources_non_forked/ale/autoload/ale/fixers/erblint.vim
Normal 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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]],
|
||||
|
Reference in New Issue
Block a user