diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | autoload/csv.vim | 111 | ||||
-rw-r--r-- | doc/ft-csv.txt | 24 | ||||
-rw-r--r-- | ftplugin/help.vim | 77 | ||||
-rw-r--r-- | packages.yaml | 2 | ||||
-rw-r--r-- | syntax/help.vim | 26 |
6 files changed, 149 insertions, 93 deletions
@@ -125,7 +125,7 @@ If you need full functionality of any plugin, please use it directly with your p - [haxe](https://github.com/yaymukund/vim-haxe) - [hcl](https://github.com/b4b4r07/vim-hcl) - [helm](https://github.com/towolf/vim-helm) -- [help](https://github.com/vim/vim/tree/master/runtime) +- [help](https://github.com/neovim/neovim/tree/master/runtime) - [hive](https://github.com/zebradil/hive.vim) - [html5](https://github.com/othree/html5.vim) - [i3](https://github.com/mboughaba/i3config.vim) diff --git a/autoload/csv.vim b/autoload/csv.vim index 8561f30f..16eeb676 100644 --- a/autoload/csv.vim +++ b/autoload/csv.vim @@ -1450,7 +1450,7 @@ fu! csv#SumColumn(list) "{{{3 let b:csv_result = '0' return 0 else - let sum = has("float") ? 0.0 : 0 + let sum = 0.0 for item in a:list if empty(item) continue @@ -1460,33 +1460,25 @@ fu! csv#SumColumn(list) "{{{3 let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' try let nr = substitute(nr, format1, '', '') - if has("float") && s:nr_format[1] != '.' + if s:nr_format[1] != '.' let nr = substitute(nr, format2, '.', '') endif catch - let nr = 0 + let nr = '0' endtry - let sum += (has("float") ? str2float(nr) : (nr + 0)) + let sum += str2float(nr) endfor - if has("float") - let b:csv_result = string(float2nr(sum)) - if float2nr(sum) == sum - return float2nr(sum) - else - return printf("%.2f", sum) - endif - endif - let b:csv_result = string(sum) - return sum + let b:csv_result = sum + return printf("%.2f", sum) endif endfu fu! csv#AvgColumn(list) "{{{3 if empty(a:list) let b:csv_result = '0' - return 0 + return 0.0 else let cnt = 0 - let sum = has("float") ? 0.0 : 0 + let sum = 0.0 for item in a:list if empty(item) continue @@ -1496,30 +1488,25 @@ fu! csv#AvgColumn(list) "{{{3 let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' try let nr = substitute(nr, format1, '', '') - if has("float") && s:nr_format[1] != '.' + if s:nr_format[1] != '.' let nr = substitute(nr, format2, '.', '') endif catch - let nr = 0 + let nr ='0' endtry - let sum += (has("float") ? str2float(nr) : (nr + 0)) + let sum += str2float(nr) let cnt += 1 endfor - if has("float") - let b:csv_result = printf("%.2f", sum/cnt) - return str2float(b:csv_result) - else - let b:csv_result = printf("%s", sum/cnt) - return b:csv_result + 0 - endif + let b:csv_result = printf("%.2f", sum/cnt) + return sum/cnt endif endfu fu! csv#VarianceColumn(list, is_population) "{{{3 if empty(a:list) - return 0 + return 0.0 else let cnt = 0 - let sum = has("float") ? 0.0 : 0 + let sum = 0.0 let avg = csv#AvgColumn(a:list) for item in a:list if empty(item) @@ -1530,64 +1517,64 @@ fu! csv#VarianceColumn(list, is_population) "{{{3 let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' try let nr = substitute(nr, format1, '', '') - if has("float") && s:nr_format[1] != '.' + if s:nr_format[1] != '.' let nr = substitute(nr, format2, '.', '') endif catch - let nr = 0 + let nr = '0' endtry - let sum += pow((has("float") ? (str2float(nr)-avg) : ((nr + 0)-avg)), 2) + let nr = str2float(nr) + let sum += pow((nr-avg), 2) let cnt += 1 endfor if(a:is_population == 0) let cnt = cnt-1 endif - if has("float") - let b:csv_result = printf("%." . get(b:, 'csv_accuracy', get(g:, 'csv_accuracy', 2)) . "f", sum/cnt) - return b:csv_result - else - let b:csv_result = printf("%s", sum/cnt) - return sum/(cnt) - endif + let b:csv_result = sum/cnt + return b:csv_result endif endfu fu! csv#SmplVarianceColumn(list) "{{{2 + unlet! b:csv_result if empty(a:list) - let b:csv_result = '0' - return 0 + let b:csv_result = 0.0 + return 0.0 else return csv#VarianceColumn(a:list, 0) endif endfu fu! csv#PopVarianceColumn(list) "{{{2 + unlet! b:csv_result if empty(a:list) - let b:csv_result = '0' - return 0 + let b:csv_result = 0.0 + return 0.0 else return csv#VarianceColumn(a:list, 1) endif endfu fu! csv#SmplStdDevColumn(list) "{{{2 + unlet! b:csv_result if empty(a:list) - let b:csv_result = '0' - return 0 + let b:csv_result = 0.0 + return 0.0 else - let result = sqrt(str2float(csv#VarianceColumn(a:list, 0))) - let b:csv_result = string(result) + let result = sqrt(csv#VarianceColumn(a:list, 0)) + let b:csv_result = result return result endif endfu fu! csv#PopStdDevColumn(list) "{{{2 + unlet! b:csv_result if empty(a:list) - let b:csv_result = '0' - return 0 + let b:csv_result = 0.0 + return 0.0 else - let result = sqrt(str2float(csv#VarianceColumn(a:list, 1))) - let b:csv_result = string(result) + let result = sqrt(csv#VarianceColumn(a:list, 1)) + let b:csv_result = result return result endif endfu @@ -1610,13 +1597,13 @@ fu! csv#MaxColumn(list) "{{{3 let format2 = '\d\+\zs\V' . s:nr_format[1] . '\m\ze\d' try let nr = substitute(nr, format1, '', '') - if has("float") && s:nr_format[1] != '.' + if s:nr_format[1] != '.' let nr = substitute(nr, format2, '.', '') endif catch - let nr = 0 + let nr = '0' endtry - call add(result, has("float") ? str2float(nr) : nr+0) + call add(result, str2float(nr)) endfor let result = sort(result, s:csv_numeric_sort ? 'n' : 'csv#CSVSortValues') let ind = len(result) > 9 ? 9 : len(result) @@ -1995,10 +1982,7 @@ fu! csv#AnalyzeColumn(...) "{{{3 call filter(res, 'v:val =~ ''^''.join(max_items, ''\|'').''$''') endif - if has("float") - let title="Nr\tCount\t % \tValue" - else - let title="Nr\tCount\tValue" + let title="Nr\tCount\t % \tValue" endif echohl Title echo printf("%s", title) @@ -2014,12 +1998,8 @@ fu! csv#AnalyzeColumn(...) "{{{3 else let k = key endif - if has("float") - echo printf("%02d\t%02d\t%2.0f%%\t%.50s", i, res[key], - \ ((res[key] + 0.0)/qty)*100, k) - else - echo printf("%02d\t%02d\t%.50s", i, res[key], k) - endif + echo printf("%02d\t%02d\t%2.0f%%\t%.50s", i, res[key], + \ ((res[key] + 0.0)/qty)*100, k) call remove(res,key) let i+=1 else @@ -2950,6 +2930,11 @@ fu! csv#EvalColumn(nr, func, first, last, ...) range "{{{3 call csv#Warn("File is no CSV file!") return endif + " Need a Vim with floating point feature + if !has("float") + call csv#Warn("Your Vim is missing floating point feature!") + return + endif let save = winsaveview() call csv#CheckHeaderLine() let nr = matchstr(a:nr, '^\-\?\d\+') diff --git a/doc/ft-csv.txt b/doc/ft-csv.txt index 7e2a00ad..7f8f6eb3 100644 --- a/doc/ft-csv.txt +++ b/doc/ft-csv.txt @@ -969,8 +969,7 @@ The result is also available in the buffer-local variable `b:csv_result`. See also |csv-aggregate-functions| - *MinCol_CSV* -3.27 Maximum/Minimum value of a Column *MaxCol_CSV* +3.27 Maximum/Minimum value of a Column *MaxCol_CSV* *MinCol_CSV* --------------------------------------- You can let Vim output the 10 maximum/minimum values of a column using the `:CSVMaxCol` command > @@ -984,6 +983,7 @@ given, this calculates the sum for the column the cursor is on. Note, that the delimiter will be stripped away from each value and also empty values won't be considered. + *format_number_csv* By default, Vim uses the a numerical format that uses the '.' as decimal separator while there is no thousands separator. If youre file contains the numbers in a different format, you can use the /format/ option to specify @@ -1003,10 +1003,6 @@ uses the Space as thousands separator and the '.' as decimal separator. If [distinct] is given, only returns the number of distinct values. -Note, if you Vim is compiled without floating point number format (|+float|), -Vim will only aggregate the integer part and therefore won't use the 'y' -argument in the /format/ specifier. - The result is also available in the buffer-local variable `b:csv_result`. 3.28 Average value of a Column *AvgCol_CSV* @@ -1021,19 +1017,21 @@ given, this calculates the sum for the column the cursor is on. Note, that the delimiter will be stripped away from each value and also empty values won't be considered. -For the [/format/] part, see |MaxCol_CSV|. +For the [/format/] part, see |format_number_csv|. The result is also available in the buffer-local variable `b:csv_result`. See also |csv-aggregate-functions| -3.29 Variance of a Column *VarCol_CSV* +3.29 Variance of a Column *VarCol_CSV* *SmplVarCol* *PopVarCol* _________________________ :[range]PopVarCol [nr] [/format/] :[range]SmplVarCol [nr] [/format/] +Calculate the Population or Sample Variance for the specified column. + This outputs the result of the column `<nr>` within the range given. If no range is given, this will calculate the statistical variance of the whole column. If <nr> is not given, this calculates the variance for the column the cursor is on. Note, that the delimiter @@ -1041,13 +1039,17 @@ will be stripped away from each value and also empty values won't be considered. The result is also available in the buffer-local variable `b:csv_result`. -3.30 Standard Deviation of a Column *StdDevCol_CSV* +For the [/format/] part, see |format_number_csv|. + +3.30 Standard Deviation of a Column *StdDevCol_CSV* *PopStdCol* *SmplStdCol* ___________________________________ :[range]PopStdCol [nr] [/format/] :[range]SmplStdCol [nr] [/format/] +Calculate the Population or Sample Standard Deviation for the specified column. + This outputs the result of the column `<nr>` within the range given. If no range is given, this will calculate the standard deviation of the whole column. If <nr> is not given, this calculates the standard deviation for the column the cursor is on. Note, that @@ -1055,6 +1057,8 @@ the delimiter will be stripped away from each value and also empty values won't The result is also available in the buffer-local variable `b:csv_result`. +For the [/format/] part, see |format_number_csv|. + *:CSVDupColumn* 3.31 Duplicate columns *DupColumn_CSV* ---------------------- @@ -1089,7 +1093,7 @@ This outputs the sum of the row [range]. If no range is given, this will calculate the sum for the current row. Note, that the delimiter will be stripped away from each value and also empty values won't be considered. -For the [/format/] part, see |MaxCol_CSV|. +For the [/format/] part, see |format_number_csv| ============================================================================== 4. CSV Configuration *csv-configuration* diff --git a/ftplugin/help.vim b/ftplugin/help.vim index 5e9a4aa0..bb6d43e8 100644 --- a/ftplugin/help.vim +++ b/ftplugin/help.vim @@ -15,11 +15,86 @@ set cpo&vim let b:undo_ftplugin = "setl fo< tw< cole< cocu< keywordprg<" -setlocal formatoptions+=tcroql textwidth=78 keywordprg=:help +setlocal formatoptions+=tcroql textwidth=78 if has("conceal") setlocal cole=2 cocu=nc endif +" Prefer Vim help instead of manpages. +setlocal keywordprg=:help + +if !exists('g:no_plugin_maps') + function! s:show_toc() abort + let bufname = bufname('%') + let info = getloclist(0, {'winid': 1}) + if !empty(info) && getwinvar(info.winid, 'qf_toc') ==# bufname + lopen + return + endif + + let toc = [] + let lnum = 2 + let last_line = line('$') - 1 + let last_added = 0 + let has_section = 0 + let has_sub_section = 0 + + while lnum && lnum <= last_line + let level = 0 + let add_text = '' + let text = getline(lnum) + + if text =~# '^=\+$' && lnum + 1 < last_line + " A de-facto section heading. Other headings are inferred. + let has_section = 1 + let has_sub_section = 0 + let lnum = nextnonblank(lnum + 1) + let text = getline(lnum) + let add_text = text + while add_text =~# '\*[^*]\+\*\s*$' + let add_text = matchstr(add_text, '.*\ze\*[^*]\+\*\s*$') + endwhile + elseif text =~# '^[A-Z0-9][-A-ZA-Z0-9 .][-A-Z0-9 .():]*\%([ \t]\+\*.\+\*\)\?$' + " Any line that's yelling is important. + let has_sub_section = 1 + let level = has_section + let add_text = matchstr(text, '.\{-}\ze\s*\%([ \t]\+\*.\+\*\)\?$') + elseif text =~# '\~$' + \ && matchstr(text, '^\s*\zs.\{-}\ze\s*\~$') !~# '\t\|\s\{2,}' + \ && getline(lnum - 1) =~# '^\s*<\?$\|^\s*\*.*\*$' + \ && getline(lnum + 1) =~# '^\s*>\?$\|^\s*\*.*\*$' + " These lines could be headers or code examples. We only want the + " ones that have subsequent lines at the same indent or more. + let l = nextnonblank(lnum + 1) + if getline(l) =~# '\*[^*]\+\*$' + " Ignore tag lines + let l = nextnonblank(l + 1) + endif + + if indent(lnum) <= indent(l) + let level = has_section + has_sub_section + let add_text = matchstr(text, '\S.*') + endif + endif + + let add_text = substitute(add_text, '\s\+$', '', 'g') + if !empty(add_text) && last_added != lnum + let last_added = lnum + call add(toc, {'bufnr': bufnr('%'), 'lnum': lnum, + \ 'text': repeat(' ', level) . add_text}) + endif + let lnum = nextnonblank(lnum + 1) + endwhile + + call setloclist(0, toc, ' ') + call setloclist(0, [], 'a', {'title': 'Help TOC'}) + lopen + let w:qf_toc = bufname + endfunction + + nnoremap <silent><buffer> gO :call <sid>show_toc()<cr> +endif + let &cpo = s:cpo_save unlet s:cpo_save diff --git a/packages.yaml b/packages.yaml index f4f801cf..1ff3f0eb 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1672,7 +1672,7 @@ filetypes: - "*/templates/*.tpl" --- name: help -remote: vim/vim:runtime +remote: neovim/neovim:runtime glob: '**/help.vim' filetypes: - name: help diff --git a/syntax/help.vim b/syntax/help.vim index aca620ee..a031e48e 100644 --- a/syntax/help.vim +++ b/syntax/help.vim @@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'help') == -1 " Vim syntax file " Language: Vim help file " Maintainer: Bram Moolenaar (Bram@vim.org) -" Last Change: 2020 Jul 28 +" Last Change: 2019 May 12 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -13,7 +13,7 @@ endif let s:cpo_save = &cpo set cpo&vim -syn match helpHeadline "^[-A-Z .][-A-Z0-9 .()_]*\ze\(\s\+\*\|$\)" +syn match helpHeadline "^[-A-Z .][-A-Z0-9 .()_]*[ \t]\+\*"me=e-1 syn match helpSectionDelim "^===.*===$" syn match helpSectionDelim "^---.*--$" if has("conceal") @@ -21,15 +21,9 @@ if has("conceal") else syn region helpExample matchgroup=helpIgnore start=" >$" start="^>$" end="^[^ \t]"me=e-1 end="^<" endif -if has("ebcdic") - syn match helpHyperTextJump "\\\@<!|[^"*|]\+|" contains=helpBar - syn match helpHyperTextEntry "\*[^"*|]\+\*\s"he=e-1 contains=helpStar - syn match helpHyperTextEntry "\*[^"*|]\+\*$" contains=helpStar -else - syn match helpHyperTextJump "\\\@<!|[#-)!+-~]\+|" contains=helpBar - syn match helpHyperTextEntry "\*[#-)!+-~]\+\*\s"he=e-1 contains=helpStar - syn match helpHyperTextEntry "\*[#-)!+-~]\+\*$" contains=helpStar -endif +syn match helpHyperTextJump "\\\@<!|[#-)!+-~]\+|" contains=helpBar +syn match helpHyperTextEntry "\*[#-)!+-~]\+\*\s"he=e-1 contains=helpStar +syn match helpHyperTextEntry "\*[#-)!+-~]\+\*$" contains=helpStar if has("conceal") syn match helpBar contained "|" conceal syn match helpBacktick contained "`" conceal @@ -44,6 +38,7 @@ syn match helpNormal "|||" syn match helpNormal ":|vim:|" " for :help modeline syn match helpVim "\<Vim version [0-9][0-9.a-z]*" syn match helpVim "VIM REFERENCE.*" +syn match helpVim "NVIM REFERENCE.*" syn match helpOption "'[a-z]\{2,\}'" syn match helpOption "'t_..'" syn match helpCommand "`[^` \t]\+`"hs=s+1,he=e-1 contains=helpBacktick @@ -68,7 +63,7 @@ syn match helpSpecial "\[N]" syn match helpSpecial "N N"he=s+1 syn match helpSpecial "Nth"me=e-2 syn match helpSpecial "N-1"me=e-2 -syn match helpSpecial "{[-a-zA-Z0-9'"*+/:%#=[\]<>.,]\+}" +syn match helpSpecial "{[-_a-zA-Z0-9'"*+/:%#=[\]<>.,]\+}" syn match helpSpecial "\s\[[-a-z^A-Z0-9_]\{2,}]"ms=s+1 syn match helpSpecial "<[-a-zA-Z0-9_]\+>" syn match helpSpecial "<[SCM]-.>" @@ -92,15 +87,14 @@ syn match helpSpecial "\[group]" syn match helpNormal "\[\(readonly\|fifo\|socket\|converted\|crypted\)]" syn match helpSpecial "CTRL-." -syn match helpSpecial "CTRL-SHIFT-." syn match helpSpecial "CTRL-Break" syn match helpSpecial "CTRL-PageUp" syn match helpSpecial "CTRL-PageDown" syn match helpSpecial "CTRL-Insert" syn match helpSpecial "CTRL-Del" syn match helpSpecial "CTRL-{char}" -syn region helpNotVi start="{Vi[: ]" start="{not" start="{only" end="}" contains=helpLeadBlank,helpHyperTextJump -syn match helpLeadBlank "^\s\+" contained +syn match helpSpecial "META-." +syn match helpSpecial "ALT-." " Highlight group items in their own color. syn match helpComment "\t[* ]Comment\t\+[a-z].*" @@ -154,7 +148,6 @@ if v:lang =~ '\<IT\>' || v:lang =~ '_IT\>' || v:lang =~? "italian" syn match helpSpecial "Nmi"me=e-2 syn match helpSpecial "Nmo"me=e-2 syn match helpSpecial "\[interv.]" - syn region helpNotVi start="{non" start="{solo" start="{disponibile" end="}" contains=helpLeadBlank,helpHyperTextJump endif syn sync minlines=40 @@ -175,7 +168,6 @@ hi def link helpVim Identifier hi def link helpCommand Comment hi def link helpExample Comment hi def link helpOption Type -hi def link helpNotVi Special hi def link helpSpecial Special hi def link helpNote Todo hi def link helpWarning Todo |