mirror of
https://github.com/amix/vimrc
synced 2025-07-12 14:15:00 +08:00
Updated plugins
This commit is contained in:
@ -80,7 +80,6 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
endif
|
||||
|
||||
let l:obj = {
|
||||
\ 'add_newline': get(a:linter, 'add_newline', 0),
|
||||
\ 'name': get(a:linter, 'name'),
|
||||
\ 'lsp': get(a:linter, 'lsp', ''),
|
||||
\}
|
||||
@ -121,7 +120,8 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
let l:obj.executable = a:linter.executable
|
||||
|
||||
if type(l:obj.executable) isnot v:t_string
|
||||
throw '`executable` must be a string if defined'
|
||||
\&& type(l:obj.executable) isnot v:t_func
|
||||
throw '`executable` must be a String or Function if defined'
|
||||
endif
|
||||
else
|
||||
throw 'Either `executable` or `executable_callback` must be defined'
|
||||
@ -177,7 +177,8 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
let l:obj.command = a:linter.command
|
||||
|
||||
if type(l:obj.command) isnot v:t_string
|
||||
throw '`command` must be a string if defined'
|
||||
\&& type(l:obj.command) isnot v:t_func
|
||||
throw '`command` must be a String or Function if defined'
|
||||
endif
|
||||
else
|
||||
throw 'Either `command`, `executable_callback`, `command_chain` '
|
||||
@ -194,9 +195,16 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
endif
|
||||
|
||||
if !l:needs_address
|
||||
if has_key(a:linter, 'address_callback')
|
||||
throw '`address_callback` cannot be used when lsp != ''socket'''
|
||||
if has_key(a:linter, 'address') || has_key(a:linter, 'address_callback')
|
||||
throw '`address` or `address_callback` cannot be used when lsp != ''socket'''
|
||||
endif
|
||||
elseif has_key(a:linter, 'address')
|
||||
if type(a:linter.address) isnot v:t_string
|
||||
\&& type(a:linter.address) isnot v:t_func
|
||||
throw '`address` must be a String or Function if defined'
|
||||
endif
|
||||
|
||||
let l:obj.address = a:linter.address
|
||||
elseif has_key(a:linter, 'address_callback')
|
||||
let l:obj.address_callback = a:linter.address_callback
|
||||
|
||||
@ -204,7 +212,7 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
throw '`address_callback` must be a callback if defined'
|
||||
endif
|
||||
else
|
||||
throw '`address_callback` must be defined for getting the LSP address'
|
||||
throw '`address` or `address_callback` must be defined for getting the LSP address'
|
||||
endif
|
||||
|
||||
if l:needs_lsp_details
|
||||
@ -221,20 +229,34 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
endif
|
||||
else
|
||||
" Default to using the filetype as the language.
|
||||
let l:obj.language = get(a:linter, 'language', a:filetype)
|
||||
let l:Language = get(a:linter, 'language', a:filetype)
|
||||
|
||||
if type(l:obj.language) isnot v:t_string
|
||||
throw '`language` must be a string'
|
||||
if type(l:Language) is v:t_string
|
||||
" Make 'language_callback' return the 'language' value.
|
||||
let l:obj.language = l:Language
|
||||
let l:obj.language_callback = function('s:LanguageGetter')
|
||||
elseif type(l:Language) is v:t_func
|
||||
let l:obj.language_callback = l:Language
|
||||
else
|
||||
throw '`language` must be a String or Funcref'
|
||||
endif
|
||||
|
||||
" Make 'language_callback' return the 'language' value.
|
||||
let l:obj.language_callback = function('s:LanguageGetter')
|
||||
endif
|
||||
|
||||
let l:obj.project_root_callback = get(a:linter, 'project_root_callback')
|
||||
if has_key(a:linter, 'project_root')
|
||||
let l:obj.project_root = a:linter.project_root
|
||||
|
||||
if !s:IsCallback(l:obj.project_root_callback)
|
||||
throw '`project_root_callback` must be a callback for LSP linters'
|
||||
if type(l:obj.project_root) isnot v:t_string
|
||||
\&& type(l:obj.project_root) isnot v:t_func
|
||||
throw '`project_root` must be a String or Function if defined'
|
||||
endif
|
||||
elseif has_key(a:linter, 'project_root_callback')
|
||||
let l:obj.project_root_callback = a:linter.project_root_callback
|
||||
|
||||
if !s:IsCallback(l:obj.project_root_callback)
|
||||
throw '`project_root_callback` must be a callback if defined'
|
||||
endif
|
||||
else
|
||||
throw '`project_root` or `project_root_callback` must be defined for LSP linters'
|
||||
endif
|
||||
|
||||
if has_key(a:linter, 'completion_filter')
|
||||
@ -258,6 +280,11 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
endif
|
||||
elseif has_key(a:linter, 'initialization_options')
|
||||
let l:obj.initialization_options = a:linter.initialization_options
|
||||
|
||||
if type(l:obj.initialization_options) isnot v:t_dict
|
||||
\&& type(l:obj.initialization_options) isnot v:t_func
|
||||
throw '`initialization_options` must be a String or Function if defined'
|
||||
endif
|
||||
endif
|
||||
|
||||
if has_key(a:linter, 'lsp_config_callback')
|
||||
@ -272,7 +299,8 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
endif
|
||||
elseif has_key(a:linter, 'lsp_config')
|
||||
if type(a:linter.lsp_config) isnot v:t_dict
|
||||
throw '`lsp_config` must be a Dictionary'
|
||||
\&& type(a:linter.lsp_config) isnot v:t_func
|
||||
throw '`lsp_config` must be a Dictionary or Function if defined'
|
||||
endif
|
||||
|
||||
let l:obj.lsp_config = a:linter.lsp_config
|
||||
@ -312,6 +340,8 @@ function! ale#linter#PreProcess(filetype, linter) abort
|
||||
throw '`aliases` must be a List of String values'
|
||||
endif
|
||||
|
||||
" TODO: Emit deprecation warnings for deprecated options later.
|
||||
|
||||
return l:obj
|
||||
endfunction
|
||||
|
||||
@ -477,22 +507,34 @@ endfunction
|
||||
|
||||
" Given a buffer and linter, get the executable String for the linter.
|
||||
function! ale#linter#GetExecutable(buffer, linter) abort
|
||||
return has_key(a:linter, 'executable_callback')
|
||||
\ ? ale#util#GetFunction(a:linter.executable_callback)(a:buffer)
|
||||
let l:Executable = has_key(a:linter, 'executable_callback')
|
||||
\ ? function(a:linter.executable_callback)
|
||||
\ : a:linter.executable
|
||||
|
||||
return type(l:Executable) is v:t_func
|
||||
\ ? l:Executable(a:buffer)
|
||||
\ : l:Executable
|
||||
endfunction
|
||||
|
||||
" Given a buffer and linter, get the command String for the linter.
|
||||
" The command_chain key is not supported.
|
||||
function! ale#linter#GetCommand(buffer, linter) abort
|
||||
return has_key(a:linter, 'command_callback')
|
||||
\ ? ale#util#GetFunction(a:linter.command_callback)(a:buffer)
|
||||
let l:Command = has_key(a:linter, 'command_callback')
|
||||
\ ? function(a:linter.command_callback)
|
||||
\ : a:linter.command
|
||||
|
||||
return type(l:Command) is v:t_func
|
||||
\ ? l:Command(a:buffer)
|
||||
\ : l:Command
|
||||
endfunction
|
||||
|
||||
" Given a buffer and linter, get the address for connecting to the server.
|
||||
function! ale#linter#GetAddress(buffer, linter) abort
|
||||
return has_key(a:linter, 'address_callback')
|
||||
\ ? ale#util#GetFunction(a:linter.address_callback)(a:buffer)
|
||||
let l:Address = has_key(a:linter, 'address_callback')
|
||||
\ ? function(a:linter.address_callback)
|
||||
\ : a:linter.address
|
||||
|
||||
return type(l:Address) is v:t_func
|
||||
\ ? l:Address(a:buffer)
|
||||
\ : l:Address
|
||||
endfunction
|
||||
|
Reference in New Issue
Block a user