mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 06:33:35 +08:00 
			
		
		
		
	Updated plugins
This commit is contained in:
		| @ -39,6 +39,9 @@ let s:LSP_COMPLETION_COLOR_KIND = 16 | ||||
| let s:LSP_COMPLETION_FILE_KIND = 17 | ||||
| let s:LSP_COMPLETION_REFERENCE_KIND = 18 | ||||
|  | ||||
| let s:LSP_INSERT_TEXT_FORMAT_PLAIN = 1 | ||||
| let s:LSP_INSERT_TEXT_FORMAT_SNIPPET = 2 | ||||
|  | ||||
| let s:lisp_regex = '\v[a-zA-Z_\-][a-zA-Z_\-0-9]*$' | ||||
|  | ||||
| " Regular expressions for checking the characters in the line before where | ||||
| @ -165,14 +168,18 @@ function! s:ReplaceCompletionOptions() abort | ||||
|  | ||||
|     let &l:omnifunc = 'ale#completion#OmniFunc' | ||||
|  | ||||
|     if !exists('b:ale_old_completopt') | ||||
|         let b:ale_old_completopt = &l:completeopt | ||||
|     endif | ||||
|     let l:info = get(b:, 'ale_completion_info', {}) | ||||
|  | ||||
|     if &l:completeopt =~# 'preview' | ||||
|         let &l:completeopt = 'menu,menuone,preview,noselect,noinsert' | ||||
|     else | ||||
|         let &l:completeopt = 'menu,menuone,noselect,noinsert' | ||||
|     if !get(l:info, 'manual') | ||||
|         if !exists('b:ale_old_completeopt') | ||||
|             let b:ale_old_completeopt = &l:completeopt | ||||
|         endif | ||||
|  | ||||
|         if &l:completeopt =~# 'preview' | ||||
|             let &l:completeopt = 'menu,menuone,preview,noselect,noinsert' | ||||
|         else | ||||
|             let &l:completeopt = 'menu,menuone,noselect,noinsert' | ||||
|         endif | ||||
|     endif | ||||
| endfunction | ||||
|  | ||||
| @ -186,9 +193,9 @@ function! ale#completion#RestoreCompletionOptions() abort | ||||
|         unlet b:ale_old_omnifunc | ||||
|     endif | ||||
|  | ||||
|     if exists('b:ale_old_completopt') | ||||
|         let &l:completeopt = b:ale_old_completopt | ||||
|         unlet b:ale_old_completopt | ||||
|     if exists('b:ale_old_completeopt') | ||||
|         let &l:completeopt = b:ale_old_completeopt | ||||
|         unlet b:ale_old_completeopt | ||||
|     endif | ||||
| endfunction | ||||
|  | ||||
| @ -346,7 +353,14 @@ function! ale#completion#ParseLSPCompletions(response) abort | ||||
|             continue | ||||
|         endif | ||||
|  | ||||
|         let l:word = matchstr(l:item.label, '\v^[^(]+') | ||||
|         if get(l:item, 'insertTextFormat') is s:LSP_INSERT_TEXT_FORMAT_PLAIN | ||||
|         \&& type(get(l:item, 'textEdit')) is v:t_dict | ||||
|             let l:text = l:item.textEdit.newText | ||||
|         else | ||||
|             let l:text = l:item.label | ||||
|         endif | ||||
|  | ||||
|         let l:word = matchstr(l:text, '\v^[^(]+') | ||||
|  | ||||
|         if empty(l:word) | ||||
|             continue | ||||
| @ -385,10 +399,10 @@ function! ale#completion#ParseLSPCompletions(response) abort | ||||
|     endfor | ||||
|  | ||||
|     if has_key(l:info, 'prefix') | ||||
|         return ale#completion#Filter(l:buffer, &filetype, l:results, l:info.prefix) | ||||
|         let l:results = ale#completion#Filter(l:buffer, &filetype, l:results, l:info.prefix) | ||||
|     endif | ||||
|  | ||||
|     return l:results | ||||
|     return l:results[: g:ale_completion_max_suggestions - 1] | ||||
| endfunction | ||||
|  | ||||
| function! ale#completion#HandleTSServerResponse(conn_id, response) abort | ||||
| @ -503,22 +517,14 @@ function! s:OnReady(linter, lsp_details) abort | ||||
|     endif | ||||
| endfunction | ||||
|  | ||||
| function! ale#completion#GetCompletions() abort | ||||
|     if !g:ale_completion_enabled | ||||
|         return | ||||
|     endif | ||||
|  | ||||
|     call ale#completion#AlwaysGetCompletions(1) | ||||
| endfunction | ||||
|  | ||||
| " This function can be used to manually trigger autocomplete, even when | ||||
| " g:ale_completion_enabled is set to false | ||||
| function! ale#completion#AlwaysGetCompletions(need_prefix) abort | ||||
| function! ale#completion#GetCompletions(manual) abort | ||||
|     let [l:line, l:column] = getpos('.')[1:2] | ||||
|  | ||||
|     let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) | ||||
|  | ||||
|     if a:need_prefix && empty(l:prefix) | ||||
|     if !a:manual && empty(l:prefix) | ||||
|         return | ||||
|     endif | ||||
|  | ||||
| @ -531,6 +537,7 @@ function! ale#completion#AlwaysGetCompletions(need_prefix) abort | ||||
|     \   'prefix': l:prefix, | ||||
|     \   'conn_id': 0, | ||||
|     \   'request_id': 0, | ||||
|     \   'manual': a:manual, | ||||
|     \} | ||||
|  | ||||
|     let l:buffer = bufnr('') | ||||
| @ -544,6 +551,10 @@ function! ale#completion#AlwaysGetCompletions(need_prefix) abort | ||||
| endfunction | ||||
|  | ||||
| function! s:TimerHandler(...) abort | ||||
|     if !g:ale_completion_enabled | ||||
|         return | ||||
|     endif | ||||
|  | ||||
|     let s:timer_id = -1 | ||||
|  | ||||
|     let [l:line, l:column] = getpos('.')[1:2] | ||||
| @ -551,7 +562,7 @@ function! s:TimerHandler(...) abort | ||||
|     " When running the timer callback, we have to be sure that the cursor | ||||
|     " hasn't moved from where it was when we requested completions by typing. | ||||
|     if s:timer_pos == [l:line, l:column] && ale#util#Mode() is# 'i' | ||||
|         call ale#completion#GetCompletions() | ||||
|         call ale#completion#GetCompletions(0) | ||||
|     endif | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| @ -142,8 +142,8 @@ let s:default_registry = { | ||||
| \   }, | ||||
| \   'clang-format': { | ||||
| \       'function': 'ale#fixers#clangformat#Fix', | ||||
| \       'suggested_filetypes': ['c', 'cpp'], | ||||
| \       'description': 'Fix C/C++ files with clang-format.', | ||||
| \       'suggested_filetypes': ['c', 'cpp', 'cuda'], | ||||
| \       'description': 'Fix C/C++ and cuda files with clang-format.', | ||||
| \   }, | ||||
| \   'cmakeformat': { | ||||
| \       'function': 'ale#fixers#cmakeformat#Fix', | ||||
|  | ||||
| @ -1,3 +1,4 @@ | ||||
| scriptencoding utf-8 | ||||
| " Author: Johannes Wienke <languitar@semipol.de> | ||||
| " Description: Error handling for errors in alex output format | ||||
|  | ||||
| @ -44,8 +45,8 @@ function! ale#handlers#alex#DefineLinter(filetype, flags) abort | ||||
|  | ||||
|     call ale#linter#Define(a:filetype, { | ||||
|     \   'name': 'alex', | ||||
|     \   'executable_callback': 'ale#handlers#alex#GetExecutable', | ||||
|     \   'command_callback': ale#handlers#alex#CreateCommandCallback(a:flags), | ||||
|     \   'executable': function('ale#handlers#alex#GetExecutable'), | ||||
|     \   'command': ale#handlers#alex#CreateCommandCallback(a:flags), | ||||
|     \   'output_stream': 'stderr', | ||||
|     \   'callback': 'ale#handlers#alex#Handle', | ||||
|     \   'lint_file': 1, | ||||
|  | ||||
| @ -0,0 +1,74 @@ | ||||
| " Author: Vincent (wahrwolf [at] wolfpit.net) | ||||
| " Description: languagetool for markdown files | ||||
| " | ||||
| call ale#Set('languagetool_executable', 'languagetool') | ||||
|  | ||||
| function! ale#handlers#languagetool#GetExecutable(buffer) abort | ||||
|     return ale#Var(a:buffer, 'languagetool_executable') | ||||
| endfunction | ||||
|  | ||||
| function! ale#handlers#languagetool#GetCommand(buffer) abort | ||||
|     let l:executable = ale#handlers#languagetool#GetExecutable(a:buffer) | ||||
|  | ||||
|     return ale#Escape(l:executable) . ' --autoDetect %s' | ||||
| endfunction | ||||
|  | ||||
| function! ale#handlers#languagetool#HandleOutput(buffer, lines) abort | ||||
|     " Match lines like: | ||||
|     " 1.) Line 5, column 1, Rule ID: | ||||
|     let l:head_pattern = '^\v.+.\) Line (\d+), column (\d+), Rule ID. (.+)$' | ||||
|     let l:head_matches = ale#util#GetMatches(a:lines, l:head_pattern) | ||||
|  | ||||
|     " Match lines like: | ||||
|     " Message: Did you forget a comma after a conjunctive/linking adverb? | ||||
|     let l:message_pattern = '^\vMessage. (.+)$' | ||||
|     let l:message_matches = ale#util#GetMatches(a:lines, l:message_pattern) | ||||
|  | ||||
|     " Match lines like: | ||||
|     "   ^^^^^ " | ||||
|     let l:markers_pattern = '^\v *(\^+) *$' | ||||
|     let l:markers_matches = ale#util#GetMatches(a:lines, l:markers_pattern) | ||||
|  | ||||
|     let l:output = [] | ||||
|  | ||||
|  | ||||
|     " Okay tbh I was to lazy to figure out a smarter solution here | ||||
|     " We just check that the arrays are same sized and merge everything | ||||
|     " together | ||||
|     let l:i = 0 | ||||
|  | ||||
|     while l:i < len(l:head_matches) | ||||
|     \   && ( | ||||
|     \       (len(l:head_matches) == len(l:markers_matches)) | ||||
|     \       && (len(l:head_matches) == len(l:message_matches)) | ||||
|     \   ) | ||||
|         let l:item = { | ||||
|         \   'lnum'    : str2nr(l:head_matches[l:i][1]), | ||||
|         \   'col'     : str2nr(l:head_matches[l:i][2]), | ||||
|         \   'end_col' : str2nr(l:head_matches[l:i][2]) + len(l:markers_matches[l:i][1])-1, | ||||
|         \   'type'    : 'W', | ||||
|         \   'code'    : l:head_matches[l:i][3], | ||||
|         \   'text'    : l:message_matches[l:i][1] | ||||
|         \} | ||||
|         call add(l:output, l:item) | ||||
|         let l:i+=1 | ||||
|     endwhile | ||||
|  | ||||
|     return l:output | ||||
| endfunction | ||||
|  | ||||
| " Define the languagetool linter for a given filetype. | ||||
| " TODO: | ||||
| " - Add language detection settings based on user env (for mothertongue) | ||||
| " - Add fixer | ||||
| " - Add config options for rules | ||||
| function! ale#handlers#languagetool#DefineLinter(filetype) abort | ||||
|     call ale#linter#Define(a:filetype, { | ||||
|     \   'name': 'languagetool', | ||||
|     \   'executable': function('ale#handlers#languagetool#GetExecutable'), | ||||
|     \   'command': function('ale#handlers#languagetool#GetCommand'), | ||||
|     \   'output_stream': 'stdout', | ||||
|     \   'callback': 'ale#handlers#languagetool#HandleOutput', | ||||
|     \   'lint_file': 1, | ||||
|     \}) | ||||
| endfunction | ||||
| @ -60,7 +60,7 @@ function! ale#handlers#rust#HandleRustErrors(buffer, lines) abort | ||||
|                 \   'lnum': l:span.line_start, | ||||
|                 \   'end_lnum': l:span.line_end, | ||||
|                 \   'col': l:span.column_start, | ||||
|                 \   'end_col': l:span.column_end, | ||||
|                 \   'end_col': l:span.column_end-1, | ||||
|                 \   'text': empty(l:span.label) ? l:error.message : printf('%s: %s', l:error.message, l:span.label), | ||||
|                 \   'type': toupper(l:error.level[0]), | ||||
|                 \}) | ||||
|  | ||||
| @ -26,7 +26,6 @@ function! ale#handlers#sml#GetCmFile(buffer) abort | ||||
| endfunction | ||||
|  | ||||
| " Only one of smlnj or smlnj-cm can be enabled at a time. | ||||
| " executable_callback is called before *every* lint attempt | ||||
| function! s:GetExecutable(buffer, source) abort | ||||
|     if ale#handlers#sml#GetCmFile(a:buffer) is# '' | ||||
|         " No CM file found; only allow single-file mode to be enabled | ||||
|  | ||||
| @ -65,8 +65,8 @@ function! ale#handlers#writegood#DefineLinter(filetype) abort | ||||
|     call ale#linter#Define(a:filetype, { | ||||
|     \   'name': 'writegood', | ||||
|     \   'aliases': ['write-good'], | ||||
|     \   'executable_callback': 'ale#handlers#writegood#GetExecutable', | ||||
|     \   'command_callback': 'ale#handlers#writegood#GetCommand', | ||||
|     \   'executable': function('ale#handlers#writegood#GetExecutable'), | ||||
|     \   'command': function('ale#handlers#writegood#GetCommand'), | ||||
|     \   'callback': 'ale#handlers#writegood#Handle', | ||||
|     \}) | ||||
| endfunction | ||||
|  | ||||
| @ -205,10 +205,13 @@ function! ale#path#FromURI(uri) abort | ||||
|         let l:encoded_path = a:uri | ||||
|     endif | ||||
|  | ||||
|     let l:path = ale#uri#Decode(l:encoded_path) | ||||
|  | ||||
|     " If the path is like /C:/foo/bar, it should be C:\foo\bar instead. | ||||
|     if l:encoded_path =~# '^/[a-zA-Z]:' | ||||
|         let l:encoded_path = substitute(l:encoded_path[1:], '/', '\\', 'g') | ||||
|     if has('win32') && l:path =~# '^/[a-zA-Z][:|]' | ||||
|         let l:path = substitute(l:path[1:], '/', '\\', 'g') | ||||
|         let l:path = l:path[0] . ':' . l:path[2:] | ||||
|     endif | ||||
|  | ||||
|     return ale#uri#Decode(l:encoded_path) | ||||
|     return l:path | ||||
| endfunction | ||||
|  | ||||
| @ -14,10 +14,10 @@ function! ale#semver#GetVersion(executable, version_lines) abort | ||||
|     let l:version = get(s:version_cache, a:executable, []) | ||||
|  | ||||
|     for l:line in a:version_lines | ||||
|         let l:match = matchlist(l:line, '\v(\d+)\.(\d+)\.?(\d?)') | ||||
|         let l:match = matchlist(l:line, '\v(\d+)\.(\d+)(\.(\d+))?') | ||||
|  | ||||
|         if !empty(l:match) | ||||
|             let l:version = [l:match[1] + 0, l:match[2] + 0, l:match[3] + 0] | ||||
|             let l:version = [l:match[1] + 0, l:match[2] + 0, l:match[4] + 0] | ||||
|             let s:version_cache[a:executable] = l:version | ||||
|  | ||||
|             break | ||||
|  | ||||
| @ -64,16 +64,21 @@ if !hlexists('ALESignColumnWithoutErrors') | ||||
|     call ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() | ||||
| endif | ||||
|  | ||||
| " Spaces and backslashes need to be escaped for signs. | ||||
| function! s:EscapeSignText(sign_text) abort | ||||
|     return substitute(a:sign_text, '\\\| ', '\\\0', 'g') | ||||
| endfunction | ||||
|  | ||||
| " Signs show up on the left for error markers. | ||||
| execute 'sign define ALEErrorSign text=' . g:ale_sign_error | ||||
| execute 'sign define ALEErrorSign text=' . s:EscapeSignText(g:ale_sign_error) | ||||
| \   . ' texthl=ALEErrorSign linehl=ALEErrorLine' | ||||
| execute 'sign define ALEStyleErrorSign text=' . g:ale_sign_style_error | ||||
| execute 'sign define ALEStyleErrorSign text=' .  s:EscapeSignText(g:ale_sign_style_error) | ||||
| \   . ' texthl=ALEStyleErrorSign linehl=ALEErrorLine' | ||||
| execute 'sign define ALEWarningSign text=' . g:ale_sign_warning | ||||
| execute 'sign define ALEWarningSign text=' . s:EscapeSignText(g:ale_sign_warning) | ||||
| \   . ' texthl=ALEWarningSign linehl=ALEWarningLine' | ||||
| execute 'sign define ALEStyleWarningSign text=' . g:ale_sign_style_warning | ||||
| execute 'sign define ALEStyleWarningSign text=' . s:EscapeSignText(g:ale_sign_style_warning) | ||||
| \   . ' texthl=ALEStyleWarningSign linehl=ALEWarningLine' | ||||
| execute 'sign define ALEInfoSign text=' . g:ale_sign_info | ||||
| execute 'sign define ALEInfoSign text=' . s:EscapeSignText(g:ale_sign_info) | ||||
| \   . ' texthl=ALEInfoSign linehl=ALEInfoLine' | ||||
| sign define ALEDummySign | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Amir Salihefendic
					Amir Salihefendic