mirror of
https://github.com/amix/vimrc
synced 2025-07-12 06:05:01 +08:00
Updated plugins
This commit is contained in:
@ -201,6 +201,14 @@ function! ale#codefix#ApplyLSPCodeAction(data, item) abort
|
||||
\ l:command.arguments,
|
||||
\)
|
||||
|
||||
let l:request_id = ale#lsp#Send(a:data.connection_id, l:message)
|
||||
elseif has_key(a:item, 'command') && has_key(a:item, 'arguments')
|
||||
\&& type(a:item.command) == v:t_string
|
||||
let l:message = ale#lsp#message#ExecuteCommand(
|
||||
\ a:item.command,
|
||||
\ a:item.arguments,
|
||||
\)
|
||||
|
||||
let l:request_id = ale#lsp#Send(a:data.connection_id, l:message)
|
||||
elseif has_key(a:item, 'edit') || has_key(a:item, 'arguments')
|
||||
if has_key(a:item, 'edit')
|
||||
@ -299,7 +307,7 @@ function! ale#codefix#HandleLSPResponse(conn_id, response) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:FindError(buffer, line, column, end_line, end_column) abort
|
||||
function! s:FindError(buffer, line, column, end_line, end_column, linter_name) abort
|
||||
let l:nearest_error = v:null
|
||||
|
||||
if a:line == a:end_line
|
||||
@ -308,7 +316,9 @@ function! s:FindError(buffer, line, column, end_line, end_column) abort
|
||||
let l:nearest_error_diff = -1
|
||||
|
||||
for l:error in get(g:ale_buffer_info[a:buffer], 'loclist', [])
|
||||
if has_key(l:error, 'code') && l:error.lnum == a:line
|
||||
if has_key(l:error, 'code')
|
||||
\ && (a:linter_name is v:null || l:error.linter_name is# a:linter_name)
|
||||
\ && l:error.lnum == a:line
|
||||
let l:diff = abs(l:error.col - a:column)
|
||||
|
||||
if l:nearest_error_diff == -1 || l:diff < l:nearest_error_diff
|
||||
@ -341,7 +351,7 @@ function! s:OnReady(
|
||||
|
||||
if a:linter.lsp is# 'tsserver'
|
||||
let l:nearest_error =
|
||||
\ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column)
|
||||
\ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column, a:linter.lsp)
|
||||
|
||||
if l:nearest_error isnot v:null
|
||||
let l:message = ale#lsp#tsserver_message#GetCodeFixes(
|
||||
@ -368,7 +378,7 @@ function! s:OnReady(
|
||||
|
||||
let l:diagnostics = []
|
||||
let l:nearest_error =
|
||||
\ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column)
|
||||
\ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column, v:null)
|
||||
|
||||
if l:nearest_error isnot v:null
|
||||
let l:diagnostics = [
|
||||
|
@ -1001,12 +1001,11 @@ endfunction
|
||||
|
||||
function! ale#completion#HandleUserData(completed_item) abort
|
||||
let l:user_data_json = get(a:completed_item, 'user_data', '')
|
||||
let l:user_data = !empty(l:user_data_json)
|
||||
\ ? ale#util#FuzzyJSONDecode(l:user_data_json, v:null)
|
||||
\ : v:null
|
||||
let l:user_data = type(l:user_data_json) is v:t_dict
|
||||
\ ? l:user_data_json
|
||||
\ : ale#util#FuzzyJSONDecode(l:user_data_json, {})
|
||||
|
||||
if type(l:user_data) isnot v:t_dict
|
||||
\|| get(l:user_data, '_ale_completion_item', 0) isnot 1
|
||||
if !has_key(l:user_data, '_ale_completion_item')
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -246,6 +246,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
\ 'description': 'Fix Go files imports with goimports.',
|
||||
\ },
|
||||
\ 'golines': {
|
||||
\ 'function': 'ale#fixers#golines#Fix',
|
||||
\ 'suggested_filetypes': ['go'],
|
||||
\ 'description': 'Fix Go file long lines with golines',
|
||||
\ },
|
||||
\ 'gomod': {
|
||||
\ 'function': 'ale#fixers#gomod#Fix',
|
||||
\ 'suggested_filetypes': ['gomod'],
|
||||
@ -301,6 +306,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['haskell'],
|
||||
\ 'description': 'Refactor Haskell files with stylish-haskell.',
|
||||
\ },
|
||||
\ 'purs-tidy': {
|
||||
\ 'function': 'ale#fixers#purs_tidy#Fix',
|
||||
\ 'suggested_filetypes': ['purescript'],
|
||||
\ 'description': 'Format PureScript files with purs-tidy.',
|
||||
\ },
|
||||
\ 'purty': {
|
||||
\ 'function': 'ale#fixers#purty#Fix',
|
||||
\ 'suggested_filetypes': ['purescript'],
|
||||
@ -386,6 +396,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['dart'],
|
||||
\ 'description': 'Fix Dart files with dart format.',
|
||||
\ },
|
||||
\ 'dotnet-format': {
|
||||
\ 'function': 'ale#fixers#dotnet_format#Fix',
|
||||
\ 'suggested_filetypes': ['cs'],
|
||||
\ 'description': 'Fix C# files with dotnet format.',
|
||||
\ },
|
||||
\ 'xmllint': {
|
||||
\ 'function': 'ale#fixers#xmllint#Fix',
|
||||
\ 'suggested_filetypes': ['xml'],
|
||||
@ -471,6 +486,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['haskell'],
|
||||
\ 'description': 'A formatter for Haskell source code.',
|
||||
\ },
|
||||
\ 'jsonnetfmt': {
|
||||
\ 'function': 'ale#fixers#jsonnetfmt#Fix',
|
||||
\ 'suggested_filetypes': ['jsonnet'],
|
||||
\ 'description': 'Fix jsonnet files with jsonnetfmt',
|
||||
\ },
|
||||
\ 'ptop': {
|
||||
\ 'function': 'ale#fixers#ptop#Fix',
|
||||
\ 'suggested_filetypes': ['pascal'],
|
||||
|
@ -1,14 +1,11 @@
|
||||
" Author: toastal <toastal@protonmail.com>
|
||||
" Author: toastal <toastal@posteo.net>
|
||||
" Description: Dhall’s built-in formatter
|
||||
"
|
||||
function! ale#fixers#dhall_format#Fix(buffer) abort
|
||||
let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
|
||||
let l:command = l:executable
|
||||
\ . ' format'
|
||||
\ . ' --inplace %t'
|
||||
|
||||
return {
|
||||
\ 'command': l:command,
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': l:executable
|
||||
\ . ' format'
|
||||
\}
|
||||
endfunction
|
||||
|
@ -1,18 +1,14 @@
|
||||
" Author: toastal <toastal@protonmail.com>
|
||||
" Author: toastal <toastal@posteo.net>
|
||||
" Description: Dhall’s package freezing
|
||||
|
||||
call ale#Set('dhall_freeze_options', '')
|
||||
|
||||
function! ale#fixers#dhall_freeze#Freeze(buffer) abort
|
||||
let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
|
||||
let l:command = l:executable
|
||||
\ . ' freeze'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'dhall_freeze_options'))
|
||||
\ . ' --inplace %t'
|
||||
|
||||
|
||||
return {
|
||||
\ 'command': l:command,
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': l:executable
|
||||
\ . ' freeze'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'dhall_freeze_options'))
|
||||
\}
|
||||
endfunction
|
||||
|
@ -1,14 +1,11 @@
|
||||
" Author: toastal <toastal@protonmail.com>
|
||||
" Author: toastal <toastal@posteo.net>
|
||||
" Description: Dhall’s built-in linter/formatter
|
||||
|
||||
function! ale#fixers#dhall_lint#Fix(buffer) abort
|
||||
let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer)
|
||||
let l:command = l:executable
|
||||
\ . ' lint'
|
||||
\ . ' --inplace %t'
|
||||
|
||||
return {
|
||||
\ 'command': l:command,
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': l:executable
|
||||
\ . ' lint'
|
||||
\}
|
||||
endfunction
|
||||
|
18
sources_non_forked/ale/autoload/ale/fixers/dotnet_format.vim
Normal file
18
sources_non_forked/ale/autoload/ale/fixers/dotnet_format.vim
Normal file
@ -0,0 +1,18 @@
|
||||
" Author: ghsang <gwonhyuksang@gmail.com>
|
||||
" Description: Integration of dotnet format with ALE.
|
||||
|
||||
call ale#Set('cs_dotnet_format_executable', 'dotnet')
|
||||
call ale#Set('cs_dotnet_format_options', '')
|
||||
|
||||
function! ale#fixers#dotnet_format#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'cs_dotnet_format_executable')
|
||||
let l:options = ale#Var(a:buffer, 'cs_dotnet_format_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' format'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' --folder --include %t "$(dirname %t)"',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
21
sources_non_forked/ale/autoload/ale/fixers/golines.vim
Normal file
21
sources_non_forked/ale/autoload/ale/fixers/golines.vim
Normal file
@ -0,0 +1,21 @@
|
||||
" Author Pig Frown <pigfrown@protonmail.com>
|
||||
" Description: Fix Go files long lines with golines"
|
||||
|
||||
call ale#Set('go_golines_executable', 'golines')
|
||||
|
||||
call ale#Set('go_golines_options', '')
|
||||
|
||||
function! ale#fixers#golines#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_golines_executable')
|
||||
let l:options = ale#Var(a:buffer, 'go_golines_options')
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:env . ale#Escape(l:executable)
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\}
|
||||
endfunction
|
@ -5,6 +5,7 @@ call ale#Set('python_isort_executable', 'isort')
|
||||
call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('python_isort_options', '')
|
||||
call ale#Set('python_isort_auto_pipenv', 0)
|
||||
call ale#Set('python_isort_auto_poetry', 0)
|
||||
|
||||
function! ale#fixers#isort#GetExecutable(buffer) abort
|
||||
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv'))
|
||||
@ -12,24 +13,34 @@ function! ale#fixers#isort#GetExecutable(buffer) abort
|
||||
return 'pipenv'
|
||||
endif
|
||||
|
||||
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_isort_auto_poetry'))
|
||||
\ && ale#python#PoetryPresent(a:buffer)
|
||||
return 'poetry'
|
||||
endif
|
||||
|
||||
return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort'])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#isort#Fix(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'python_isort_options')
|
||||
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
\ ? ' run isort'
|
||||
\ : ''
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if !executable(l:executable) && l:executable isnot# 'pipenv'
|
||||
return 0
|
||||
if l:executable =~? 'pipenv\|poetry$'
|
||||
call extend(l:cmd, ['run', 'isort'])
|
||||
endif
|
||||
|
||||
call add(l:cmd, '--filename %s')
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'python_isort_options')
|
||||
|
||||
if !empty(l:options)
|
||||
call add(l:cmd, l:options)
|
||||
endif
|
||||
|
||||
call add(l:cmd, '-')
|
||||
|
||||
return {
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(l:executable) . l:exec_args
|
||||
\ . ale#Pad('--filename %s')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' -',
|
||||
\ 'command': join(l:cmd, ' ')
|
||||
\}
|
||||
endfunction
|
||||
|
18
sources_non_forked/ale/autoload/ale/fixers/jsonnetfmt.vim
Normal file
18
sources_non_forked/ale/autoload/ale/fixers/jsonnetfmt.vim
Normal file
@ -0,0 +1,18 @@
|
||||
" Authors: Trevor Whitney <trevorjwhitney@gmail.com> and Takuya Kosugiyama <re@itkq.jp>
|
||||
" Description: Integration of jsonnetfmt with ALE.
|
||||
|
||||
call ale#Set('jsonnet_jsonnetfmt_executable', 'jsonnetfmt')
|
||||
call ale#Set('jsonnet_jsonnetfmt_options', '')
|
||||
|
||||
function! ale#fixers#jsonnetfmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'jsonnet_jsonnetfmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'jsonnet_jsonnetfmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' -i'
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
24
sources_non_forked/ale/autoload/ale/fixers/purs_tidy.vim
Normal file
24
sources_non_forked/ale/autoload/ale/fixers/purs_tidy.vim
Normal file
@ -0,0 +1,24 @@
|
||||
" Author: toastal <toastal@posteo.net>
|
||||
" Description: Integration of purs-tidy with ALE.
|
||||
|
||||
call ale#Set('purescript_tidy_executable', 'purs-tidy')
|
||||
call ale#Set('purescript_tidy_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('purescript_tidy_options', '')
|
||||
|
||||
function! ale#fixers#purs_tidy#GetExecutable(buffer) abort
|
||||
return ale#path#FindExecutable(a:buffer, 'purescript_tidy', [
|
||||
\ 'node_modules/purescript-tidy/bin/index.js',
|
||||
\ 'node_modules/.bin/purs-tidy',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#purs_tidy#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#purs_tidy#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'purescript_tidy_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' format'
|
||||
\ . ale#Pad(l:options)
|
||||
\}
|
||||
endfunction
|
@ -21,12 +21,10 @@ endfunction
|
||||
|
||||
function! ale#fixers#rubocop#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable')
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
|
||||
let l:options = ale#Var(a:buffer, 'ruby_rubocop_options')
|
||||
let l:auto_correct_all = ale#Var(a:buffer, 'ruby_rubocop_auto_correct_all')
|
||||
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'rubocop')
|
||||
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . (l:auto_correct_all ? ' --auto-correct-all' : ' --auto-correct')
|
||||
\ . ' --force-exclusion --stdin %s'
|
||||
|
@ -43,21 +43,25 @@ endfunction
|
||||
function! ale#handlers#cppcheck#HandleCppCheckFormat(buffer, lines) abort
|
||||
" Look for lines like the following.
|
||||
"
|
||||
"test.cpp:974:6: error: Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\
|
||||
"test.cpp:974:6: error:inconclusive Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\
|
||||
" n[3]=3;
|
||||
" ^
|
||||
let l:pattern = '\v^(\f+):(\d+):(\d+): (\w+): (.*) \[(\w+)\]\'
|
||||
"" OR if cppcheck doesn't support {column} or {inconclusive:text}:
|
||||
"test.cpp:974:{column}: error:{inconclusive:inconclusive} Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\
|
||||
" n[3]=3;
|
||||
" ^
|
||||
let l:pattern = '\v(\f+):(\d+):(\d+|\{column\}): (\w+):(\{inconclusive:inconclusive\})? ?(.*) \[(\w+)\]\'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
if ale#path#IsBufferPath(a:buffer, l:match[1])
|
||||
call add(l:output, {
|
||||
\ 'lnum': str2nr(l:match[2]),
|
||||
\ 'col': str2nr(l:match[3]),
|
||||
\ 'col': match(l:match[3],'{column}') >= 0 ? 1 : str2nr(l:match[3]),
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
\ 'sub_type': l:match[4] is# 'style' ? 'style' : '',
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:match[6]
|
||||
\ 'text': l:match[6],
|
||||
\ 'code': l:match[7]
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
|
@ -56,19 +56,19 @@ function! ale#handlers#sml#Handle(buffer, lines) abort
|
||||
" Try to match basic sml errors
|
||||
" TODO(jez) We can get better errorfmt strings from Syntastic
|
||||
let l:out = []
|
||||
let l:pattern = '^.*\:\([0-9\.]\+\)\ \(\w\+\)\:\ \(.*\)'
|
||||
let l:pattern2 = '^.*\:\([0-9]\+\)\.\?\([0-9]\+\).* \(\(Warning\|Error\): .*\)'
|
||||
let l:pattern = '^\(.*\)\:\([0-9\.]\+\)\ \(\w\+\)\:\ \(.*\)'
|
||||
let l:pattern2 = '^\(.*\)\:\([0-9]\+\)\.\?\([0-9]\+\).* \(\(Warning\|Error\): .*\)'
|
||||
|
||||
for l:line in a:lines
|
||||
let l:match2 = matchlist(l:line, l:pattern2)
|
||||
|
||||
if len(l:match2) != 0
|
||||
call add(l:out, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:match2[1] + 0,
|
||||
\ 'col' : l:match2[2] - 1,
|
||||
\ 'text': l:match2[3],
|
||||
\ 'type': l:match2[3] =~# '^Warning' ? 'W' : 'E',
|
||||
\ 'filename': l:match2[1],
|
||||
\ 'lnum': l:match2[2] + 0,
|
||||
\ 'col' : l:match2[3] - 1,
|
||||
\ 'text': l:match2[4],
|
||||
\ 'type': l:match2[4] =~# '^Warning' ? 'W' : 'E',
|
||||
\})
|
||||
|
||||
continue
|
||||
@ -78,10 +78,10 @@ function! ale#handlers#sml#Handle(buffer, lines) abort
|
||||
|
||||
if len(l:match) != 0
|
||||
call add(l:out, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[2] . ': ' . l:match[3],
|
||||
\ 'type': l:match[2] is# 'error' ? 'E' : 'W',
|
||||
\ 'filename': l:match[1],
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[3] . ': ' . l:match[4],
|
||||
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||
\})
|
||||
continue
|
||||
endif
|
||||
|
@ -45,7 +45,9 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort
|
||||
\&& (l:set_balloons is 1 || l:set_balloons is# 'hover')
|
||||
call balloon_show(a:response.body.displayString)
|
||||
elseif get(l:options, 'truncated_echo', 0)
|
||||
call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0])
|
||||
if !empty(a:response.body.displayString)
|
||||
call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0])
|
||||
endif
|
||||
elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
|
||||
call ale#floating_preview#Show(split(a:response.body.displayString, "\n"), {
|
||||
\ 'filetype': 'ale-preview.message',
|
||||
|
@ -45,6 +45,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort
|
||||
\ 'typeDefinition': 0,
|
||||
\ 'symbol_search': 0,
|
||||
\ 'code_actions': 0,
|
||||
\ 'includeText': 0,
|
||||
\ },
|
||||
\}
|
||||
endif
|
||||
@ -263,6 +264,20 @@ function! s:UpdateCapabilities(conn, capabilities) abort
|
||||
if type(get(a:capabilities, 'workspaceSymbolProvider')) is v:t_dict
|
||||
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(l:save) is v:true
|
||||
let a:conn.capabilities.includeText = 1
|
||||
endif
|
||||
|
||||
if type(l:save) is v:t_dict && get(a:capabilities.textDocumentSync.save, 'includeText', v:false) is v:true
|
||||
let a:conn.capabilities.includeText = 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Update a connection's configuration dictionary and notify LSP servers
|
||||
|
@ -77,12 +77,19 @@ function! ale#lsp#message#DidChange(buffer) abort
|
||||
\}]
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#message#DidSave(buffer) abort
|
||||
return [1, 'textDocument/didSave', {
|
||||
function! ale#lsp#message#DidSave(buffer, includeText) abort
|
||||
let l:response = [1, 'textDocument/didSave', {
|
||||
\ 'textDocument': {
|
||||
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
|
||||
\ },
|
||||
\}]
|
||||
|
||||
if a:includeText
|
||||
let l:response[2].textDocument.version = ale#lsp#message#GetNextVersionID()
|
||||
let l:response[2].text = ale#util#GetBufferContents(a:buffer)
|
||||
endif
|
||||
|
||||
return l:response
|
||||
endfunction
|
||||
|
||||
function! ale#lsp#message#DidClose(buffer) abort
|
||||
|
@ -271,6 +271,30 @@ function! ale#lsp_linter#OnInit(linter, details, Callback) abort
|
||||
call ale#lsp#NotifyForChanges(l:conn_id, l:buffer)
|
||||
endif
|
||||
|
||||
" Tell the relevant buffer that the LSP has started via an autocmd.
|
||||
if l:buffer > 0
|
||||
if l:buffer == bufnr('')
|
||||
silent doautocmd <nomodeline> User ALELSPStarted
|
||||
else
|
||||
execute 'augroup ALELSPStartedGroup' . l:buffer
|
||||
autocmd!
|
||||
|
||||
execute printf(
|
||||
\ 'autocmd BufEnter <buffer=%d>'
|
||||
\ . ' doautocmd <nomodeline> User ALELSPStarted',
|
||||
\ l:buffer
|
||||
\)
|
||||
|
||||
" Replicate ++once behavior for backwards compatibility.
|
||||
execute printf(
|
||||
\ 'autocmd BufEnter <buffer=%d>'
|
||||
\ . ' autocmd! ALELSPStartedGroup%d',
|
||||
\ l:buffer, l:buffer
|
||||
\)
|
||||
augroup END
|
||||
endif
|
||||
endif
|
||||
|
||||
call a:Callback(a:linter, a:details)
|
||||
endfunction
|
||||
|
||||
@ -442,7 +466,8 @@ 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)
|
||||
let l:save_message = ale#lsp#message#DidSave(l:buffer)
|
||||
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
|
||||
endif
|
||||
endfunction
|
||||
|
@ -24,6 +24,7 @@ function! ale#python#FindProjectRootIni(buffer) abort
|
||||
\|| filereadable(l:path . '/setup.cfg')
|
||||
\|| filereadable(l:path . '/pytest.ini')
|
||||
\|| filereadable(l:path . '/tox.ini')
|
||||
\|| filereadable(l:path . '/.pyre_configuration.local')
|
||||
\|| filereadable(l:path . '/mypy.ini')
|
||||
\|| filereadable(l:path . '/pycodestyle.cfg')
|
||||
\|| filereadable(l:path . '/.flake8')
|
||||
|
@ -535,3 +535,7 @@ function! ale#util#SetBufferContents(buffer, lines) abort
|
||||
|
||||
return l:new_lines
|
||||
endfunction
|
||||
|
||||
function! ale#util#GetBufferContents(buffer) abort
|
||||
return join(getbufline(a:buffer, 1, '$'), '\n') . '\n'
|
||||
endfunction
|
||||
|
@ -7,9 +7,15 @@ scriptencoding utf-8
|
||||
let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10)
|
||||
let s:cursor_timer = -1
|
||||
let s:last_pos = [0, 0, 0]
|
||||
let s:has_virt_text = 0
|
||||
|
||||
if has('nvim-0.3.2')
|
||||
let s:ns_id = nvim_create_namespace('ale')
|
||||
let s:has_virt_text = 1
|
||||
elseif has('textprop') && has('popupwin')
|
||||
call prop_type_add('ale', {})
|
||||
let s:last_popup = -1
|
||||
let s:has_virt_text = 1
|
||||
endif
|
||||
|
||||
if !hlexists('ALEVirtualTextError')
|
||||
@ -33,17 +39,25 @@ if !hlexists('ALEVirtualTextInfo')
|
||||
endif
|
||||
|
||||
function! ale#virtualtext#Clear() abort
|
||||
if !has('nvim-0.3.2')
|
||||
if !s:has_virt_text
|
||||
return
|
||||
endif
|
||||
|
||||
let l:buffer = bufnr('')
|
||||
|
||||
call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1)
|
||||
if has('nvim')
|
||||
call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1)
|
||||
else
|
||||
if s:last_popup != -1
|
||||
call prop_remove({'type': 'ale'})
|
||||
call popup_close(s:last_popup)
|
||||
let s:last_popup = -1
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#virtualtext#ShowMessage(message, hl_group) abort
|
||||
if !has('nvim-0.3.2')
|
||||
if !s:has_virt_text
|
||||
return
|
||||
endif
|
||||
|
||||
@ -51,7 +65,24 @@ function! ale#virtualtext#ShowMessage(message, hl_group) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ')
|
||||
|
||||
call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, a:hl_group]], {})
|
||||
if has('nvim')
|
||||
call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, 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, {
|
||||
\ 'line': -1,
|
||||
\ 'padding': [0, 0, 0, 1],
|
||||
\ 'mask': [[1, 1, 1, 1]],
|
||||
\ 'textprop': 'ale',
|
||||
\ 'highlight': a:hl_group,
|
||||
\ 'fixed': 1,
|
||||
\ 'wrap': 0,
|
||||
\ 'zindex': 2
|
||||
\})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:StopCursorTimer() abort
|
||||
|
Reference in New Issue
Block a user