diff options
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/csscomplete.vim | 6 | ||||
-rw-r--r-- | runtime/autoload/health.vim | 126 | ||||
-rw-r--r-- | runtime/autoload/health/lsp.vim | 5 | ||||
-rw-r--r-- | runtime/autoload/health/provider.vim | 2 | ||||
-rw-r--r-- | runtime/autoload/health/treesitter.vim | 5 | ||||
-rw-r--r-- | runtime/autoload/man.vim | 12 | ||||
-rw-r--r-- | runtime/autoload/netrw.vim | 3 | ||||
-rw-r--r-- | runtime/autoload/provider/pythonx.vim | 2 |
8 files changed, 102 insertions, 59 deletions
diff --git a/runtime/autoload/csscomplete.vim b/runtime/autoload/csscomplete.vim index 85e40c862f..4b673ac9b8 100644 --- a/runtime/autoload/csscomplete.vim +++ b/runtime/autoload/csscomplete.vim @@ -4,7 +4,7 @@ " plus CSS Speech Module <http://www.w3.org/TR/css3-speech/> " Maintainer: Kao, Wei-Ko(othree) ( othree AT gmail DOT com ) " Original Author: Mikolaj Machowski ( mikmach AT wp DOT pl ) -" Last Change: 2018 Jul 02 +" Last Change: 2021 Sep 21 let s:values = split("all additive-symbols align-content align-items align-self animation animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function backface-visibility background background-attachment background-blend-mode background-clip background-color background-image background-origin background-position background-repeat background-size block-size border border-block-end border-block-end-color border-block-end-style border-block-end-width border-block-start border-block-start-color border-block-start-style border-block-start-width border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-inline-end border-inline-end-color border-inline-end-style border-inline-end-width border-inline-start border-inline-start-color border-inline-start-style border-inline-start-width border-left border-left-color border-left-style border-left-width border-radius border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-width bottom box-decoration-break box-shadow box-sizing break-after break-before break-inside caption-side clear clip clip-path color columns column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width content counter-increment counter-reset cue cue-before cue-after cursor direction display empty-cells fallback filter flex flex-basis flex-direction flex-flow flex-grow flex-shrink flex-wrap float font font-family font-feature-settings font-kerning font-language-override font-size font-size-adjust font-stretch font-style font-synthesis font-variant font-variant-alternates font-variant-caps font-variant-east-asian font-variant-ligatures font-variant-numeric font-variant-position font-weight grid grid-area grid-auto-columns grid-auto-flow grid-auto-position grid-auto-rows grid-column grid-column-start grid-column-end grid-row grid-row-start grid-row-end grid-template grid-template-areas grid-template-rows grid-template-columns height hyphens image-rendering image-resolution image-orientation ime-mode inline-size isolation justify-content left letter-spacing line-break line-height list-style list-style-image list-style-position list-style-type margin margin-block-end margin-block-start margin-bottom margin-inline-end margin-inline-start margin-left margin-right margin-top marks mask mask-type max-block-size max-height max-inline-size max-width max-zoom min-block-size min-height min-inline-size min-width min-zoom mix-blend-mode negative object-fit object-position offset-block-end offset-block-start offset-inline-end offset-inline-start opacity order orientation orphans outline outline-color outline-offset outline-style outline-width overflow overflow-wrap overflow-x overflow-y pad padding padding-block-end padding-block-start padding-bottom padding-inline-end padding-inline-start padding-left padding-right padding-top page-break-after page-break-before page-break-inside pause-before pause-after pause perspective perspective-origin pointer-events position prefix quotes range resize rest rest-before rest-after right ruby-align ruby-merge ruby-position scroll-behavior scroll-snap-coordinate scroll-snap-destination scroll-snap-points-x scroll-snap-points-y scroll-snap-type scroll-snap-type-x scroll-snap-type-y shape-image-threshold shape-margin shape-outside speak speak-as suffix symbols system table-layout tab-size text-align text-align-last text-combine-upright text-decoration text-decoration-color text-decoration-line text-emphasis text-emphasis-color text-emphasis-position text-emphasis-style text-indent text-orientation text-overflow text-rendering text-shadow text-transform text-underline-position top touch-action transform transform-box transform-origin transform-style transition transition-delay transition-duration transition-property transition-timing-function unicode-bidi unicode-range user-zoom vertical-align visibility voice-balance voice-duration voice-family voice-pitch voice-rate voice-range voice-stress voice-volume white-space widows width will-change word-break word-spacing word-wrap writing-mode z-index zoom") @@ -38,12 +38,12 @@ function! csscomplete#CompleteCSS(findstart, base) if exists("b:compl_context") let line = getline('.') let compl_begin = col('.') - 2 - let after = line[compl_begin:] + let b:after = line[compl_begin:] let line = b:compl_context unlet! b:compl_context else let line = a:base - let after = '' + let b:after = '' endif let res = [] diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 0f7983f175..73c1459f86 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -26,8 +26,8 @@ endfunction " Runs all discovered healthchecks if a:plugin_names is empty. function! health#check(plugin_names) abort let healthchecks = empty(a:plugin_names) - \ ? s:discover_health_checks() - \ : s:to_fn_names(a:plugin_names) + \ ? s:discover_healthchecks() + \ : s:get_healthcheck(a:plugin_names) tabnew setlocal wrap breakindent linebreak @@ -41,25 +41,29 @@ function! health#check(plugin_names) abort call setline(1, 'ERROR: No healthchecks found.') else redraw|echo 'Running healthchecks...' - for c in healthchecks - let output = '' - call append('$', split(printf("\n%s\n%s", c, repeat('=',72)), "\n")) + for name in sort(keys(healthchecks)) + let [func, type] = healthchecks[name] + let s:output = [] try - let output = "\n\n".execute('call '.c.'()') + if func == '' + throw 'healthcheck_not_found' + endif + eval type == 'v' ? call(func, []) : luaeval(func) catch - if v:exception =~# '^Vim\%((\a\+)\)\=:E117.*\V'.c - let output = execute( - \ 'call health#report_error(''No healthcheck found for "' - \ .s:to_plugin_name(c) - \ .'" plugin.'')') + let s:output = [] " Clear the output + if v:exception =~# 'healthcheck_not_found' + call health#report_error('No healthcheck found for "'.name.'" plugin.') else - let output = execute( - \ 'call health#report_error(''Failed to run healthcheck for "' - \ .s:to_plugin_name(c) - \ .'" plugin. Exception:''."\n".v:throwpoint."\n".v:exception)') + call health#report_error(printf( + \ "Failed to run healthcheck for \"%s\" plugin. Exception:\n%s\n%s", + \ name, v:throwpoint, v:exception)) endif endtry - call append('$', split(output, "\n") + ['']) + let header = [name. ': ' . func, repeat('=', 72)] + " remove empty line after header from report_start + let s:output = s:output[0] == '' ? s:output[1:] : s:output + let s:output = header + s:output + [''] + call append('$', s:output) redraw endfor endif @@ -71,9 +75,13 @@ function! health#check(plugin_names) abort redraw|echo '' endfunction +function! s:collect_output(output) + let s:output += split(a:output, "\n", 1) +endfunction + " Starts a new report. function! health#report_start(name) abort - echo "\n## " . a:name + call s:collect_output("\n## " . a:name) endfunction " Indents lines *except* line 1 of a string if it contains newlines. @@ -119,21 +127,21 @@ endfunction " }}} " Use {msg} to report information in the current section function! health#report_info(msg) abort " {{{ - echo s:format_report_message('INFO', a:msg) + call s:collect_output(s:format_report_message('INFO', a:msg)) endfunction " }}} " Reports a successful healthcheck. function! health#report_ok(msg) abort " {{{ - echo s:format_report_message('OK', a:msg) + call s:collect_output(s:format_report_message('OK', a:msg)) endfunction " }}} " Reports a health warning. " a:1: Optional advice (string or list) function! health#report_warn(msg, ...) abort " {{{ if a:0 > 0 - echo s:format_report_message('WARNING', a:msg, a:1) + call s:collect_output(s:format_report_message('WARNING', a:msg, a:1)) else - echo s:format_report_message('WARNING', a:msg) + call s:collect_output(s:format_report_message('WARNING', a:msg)) endif endfunction " }}} @@ -141,37 +149,73 @@ endfunction " }}} " a:1: Optional advice (string or list) function! health#report_error(msg, ...) abort " {{{ if a:0 > 0 - echo s:format_report_message('ERROR', a:msg, a:1) + call s:collect_output(s:format_report_message('ERROR', a:msg, a:1)) else - echo s:format_report_message('ERROR', a:msg) + call s:collect_output(s:format_report_message('ERROR', a:msg)) endif endfunction " }}} -function! s:filepath_to_function(name) abort - return substitute(substitute(substitute(a:name, '.*autoload[\/]', '', ''), - \ '\.vim', '#check', ''), '[\/]', '#', 'g') +" From a path return a list [{name}, {func}, {type}] representing a healthcheck +function! s:filepath_to_healthcheck(path) abort + if a:path =~# 'vim$' + let name = matchstr(a:path, '\zs[^\/]*\ze\.vim$') + let func = 'health#'.name.'#check' + let type = 'v' + else + let base_path = substitute(a:path, + \ '.*lua[\/]\(.\{-}\)[\/]health\([\/]init\)\?\.lua$', + \ '\1', '') + let name = substitute(base_path, '[\/]', '.', 'g') + let func = 'require("'.name.'.health").check()' + let type = 'l' + endif + return [name, func, type] endfunction -function! s:discover_health_checks() abort - let healthchecks = globpath(&runtimepath, 'autoload/health/*.vim', 1, 1) - let healthchecks = map(healthchecks, '<SID>filepath_to_function(v:val)') - return healthchecks +function! s:discover_healthchecks() abort + return s:get_healthcheck('*') +endfunction + +" Returns Dictionary {name: [func, type], ..} representing healthchecks +function! s:get_healthcheck(plugin_names) abort + let health_list = s:get_healthcheck_list(a:plugin_names) + let healthchecks = {} + for c in health_list + let normalized_name = substitute(c[0], '-', '_', 'g') + let existent = get(healthchecks, normalized_name, []) + " Prefer Lua over vim entries + if existent != [] && existent[2] == 'l' + continue + else + let healthchecks[normalized_name] = c + endif + endfor + let output = {} + for v in values(healthchecks) + let output[v[0]] = v[1:] + endfor + return output endfunction -" Translates a list of plugin names to healthcheck function names. -function! s:to_fn_names(plugin_names) abort +" Returns list of lists [ [{name}, {func}, {type}] ] representing healthchecks +function! s:get_healthcheck_list(plugin_names) abort let healthchecks = [] - let plugin_names = type('') ==# type(a:plugin_names) - \ ? split(a:plugin_names, '', v:false) + let plugin_names = type('') == type(a:plugin_names) + \ ? split(a:plugin_names, ' ', v:false) \ : a:plugin_names for p in plugin_names - call add(healthchecks, 'health#'.p.'#check') + " support vim/lsp/health{/init/}.lua as :checkhealth vim.lsp + let p = substitute(p, '\.', '/', 'g') + let p = substitute(p, '*$', '**', 'g') " find all submodule e.g vim* + let paths = nvim_get_runtime_file('autoload/health/'.p.'.vim', v:true) + \ + nvim_get_runtime_file('lua/**/'.p.'/health/init.lua', v:true) + \ + nvim_get_runtime_file('lua/**/'.p.'/health.lua', v:true) + if len(paths) == 0 + let healthchecks += [[p, '', '']] " healthchek not found + else + let healthchecks += map(uniq(sort(paths)), + \'<SID>filepath_to_healthcheck(v:val)') + end endfor return healthchecks endfunction - -" Extracts 'foo' from 'health#foo#check'. -function! s:to_plugin_name(fn_name) abort - return substitute(a:fn_name, - \ '\v.*health\#(.+)\#check.*', '\1', '') -endfunction diff --git a/runtime/autoload/health/lsp.vim b/runtime/autoload/health/lsp.vim deleted file mode 100644 index 2d2ba91cdf..0000000000 --- a/runtime/autoload/health/lsp.vim +++ /dev/null @@ -1,5 +0,0 @@ -function! health#lsp#check() abort - call health#report_start('Checking language server client configuration') - lua require 'vim.lsp.health'.check_health() -endfunction - diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 001379c85d..7b4dce3441 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -710,7 +710,7 @@ function! s:check_perl() abort let latest_cpan = s:system(latest_cpan_cmd) if s:shell_error || empty(latest_cpan) - call health#report_error('Failed to run: '. latest_cpan_cmd, + call health#report_error('Failed to run: '. join(latest_cpan_cmd, " "), \ ["Make sure you're connected to the internet.", \ 'Are you behind a firewall or proxy?']) return diff --git a/runtime/autoload/health/treesitter.vim b/runtime/autoload/health/treesitter.vim deleted file mode 100644 index 5f167310ce..0000000000 --- a/runtime/autoload/health/treesitter.vim +++ /dev/null @@ -1,5 +0,0 @@ -function! health#treesitter#check() abort - call health#report_start('Checking treesitter configuration') - lua require 'vim.treesitter.health'.check_health() -endfunction - diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 4f132b6121..90d353f9de 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -197,13 +197,21 @@ function! s:extract_sect_and_name_ref(ref) abort if empty(name) throw 'manpage reference cannot contain only parentheses' endif - return ['', name] + return ['', s:spaces_to_underscores(name)] endif let left = split(ref, '(') " see ':Man 3X curses' on why tolower. " TODO(nhooyr) Not sure if this is portable across OSs " but I have not seen a single uppercase section. - return [tolower(split(left[1], ')')[0]), left[0]] + return [tolower(split(left[1], ')')[0]), s:spaces_to_underscores(left[0])] +endfunction + +" replace spaces in a man page name with underscores +" intended for PostgreSQL, which has man pages like 'CREATE_TABLE(7)'; +" while editing SQL source code, it's nice to visually select 'CREATE TABLE' +" and hit 'K', which requires this transformation +function! s:spaces_to_underscores(str) + return substitute(a:str, ' ', '_', 'g') endfunction function! s:get_path(sect, name) abort diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index b6edc4c4d8..ef0282848f 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1711,7 +1711,8 @@ fun! s:NetrwOptionsSafe(islocal) if &cpo =~ 'a' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'a','','g')) | endif if &cpo =~ 'A' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'A','','g')) | endif setl fo=nroql2 - call s:NetrwSetSafeSetting("&go","begmr") + " call s:NetrwSetSafeSetting("&go","begmr") + if &go =~ '\ca' | call s:NetrwSetSafeSetting("&go",substitute(&go,'\ca','','g')) | endif call s:NetrwSetSafeSetting("&l:hid",0) call s:NetrwSetSafeSetting("&l:im",0) setl isk+=@ isk+=* isk+=/ diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index c292b374b6..0eeb35cba8 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -96,7 +96,7 @@ function! provider#pythonx#CheckForModule(prog, module, major_version) abort if prog_version !~ '^' . a:major_version return [0, prog_path . ' is Python ' . prog_version . ' and cannot provide Python ' \ . a:major_version . '.'] - elseif prog_version =~ '^' . a:major_version && prog_version < min_version + elseif prog_version =~ '^' . a:major_version && str2nr(prog_version[2:]) < str2nr(min_version[2:]) return [0, prog_path . ' is Python ' . prog_version . ' and cannot provide Python >= ' \ . min_version . '.'] endif |