diff options
50 files changed, 504 insertions, 319 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index de74ee891e..5923dada43 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -630,7 +630,7 @@ FilterReadPre Before reading a file from a filter command. *FilterWritePost* FilterWritePost After writing a file for a filter command or making a diff with an external diff (see - DiffUpdated for internal diff). + |DiffUpdated| for internal diff). Vim checks the pattern against the name of the current buffer as with FilterWritePre. Not triggered when 'shelltemp' is off. @@ -683,23 +683,6 @@ InsertCharPre When a character is typed in Insert mode, Cannot change the text. |textlock| Not triggered when 'paste' is set. - *TextYankPost* -TextYankPost Just after a |yank| or |deleting| command, but not - if the black hole register |quote_| is used nor - for |setreg()|. Pattern must be *. - Sets these |v:event| keys: - inclusive - operator - regcontents - regname - regtype - visual - The `inclusive` flag combined with the |'[| - and |']| marks can be used to calculate the - precise region of the operation. - - Non-recursive (event cannot trigger itself). - Cannot change the text. |textlock| *InsertEnter* InsertEnter Just before starting Insert mode. Also for Replace mode and Virtual Replace mode. The @@ -948,6 +931,23 @@ TextChangedP After a change was made to the text in the current buffer in Insert mode, only when the popup menu is visible. Otherwise the same as TextChanged. + *TextYankPost* +TextYankPost Just after a |yank| or |deleting| command, but not + if the black hole register |quote_| is used nor + for |setreg()|. Pattern must be *. + Sets these |v:event| keys: + inclusive + operator + regcontents + regname + regtype + visual + The `inclusive` flag combined with the |'[| + and |']| marks can be used to calculate the + precise region of the operation. + + Non-recursive (event cannot trigger itself). + Cannot change the text. |textlock| *User* User Not executed automatically. Use |:doautocmd| to trigger this, typically for "custom events" diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 2b799e3e27..ffdd8427f9 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1129,9 +1129,6 @@ a register, a paste on a visual selected area will paste that single line on each of the selected lines (thus replacing the blockwise selected region by a block of the pasted line). -Use |zP|/|zp| to paste a blockwise yanked register without appending trailing -spaces. - *blockwise-register* If you use a blockwise Visual mode command to get the text into the register, the block of text will be inserted before ("P") or after ("p") the cursor @@ -1142,6 +1139,9 @@ this happen. However, if the width of the block is not a multiple of a <Tab> width and the text after the inserted block contains <Tab>s, that text may be misaligned. +Use |zP|/|zp| to paste a blockwise yanked register without appending trailing +spaces. + Note that after a charwise yank command, Vim leaves the cursor on the first yanked character that is closest to the start of the buffer. This means that "yl" doesn't move the cursor, but "yh" moves the cursor one character left. diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 0e7e461a61..f91e4f0627 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1310,7 +1310,7 @@ change anything for the current directory. When |:lcd| has been used for a window, the specified directory becomes the current directory for that window. Windows where the |:lcd| command has not been used stick to the global or tab-local directory. When jumping to another -window the current directory will become the last specified local current +window the current directory is changed to the last specified local current directory. If none was specified, the global or tab-local directory is used. When changing tabs the same behaviour applies. If the current tab has no @@ -1467,6 +1467,11 @@ It is also possible that you modified the file yourself, from another edit session or with another command (e.g., a filter command). Then you will know which version of the file you want to keep. +The accuracy of the time check depends on the filesystem. On Unix it is +usually sub-second. With old file sytems and on MS-Windows it is normally one +second. Use has('nanotime') check if sub-second time stamp checks are +available. + There is one situation where you get the message while there is nothing wrong: On a Win32 system on the day daylight saving time starts. There is something in the Win32 libraries that confuses Vim about the hour time difference. The diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 981bdd09fc..3520d40591 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5981,13 +5981,13 @@ A jump table for the options with a short description can be found at |Q_op|. return value of expr contains % items they will get expanded. The expression can contain the } character, the end of expression is denoted by %}. - The For example: > + For example: > func! Stl_filename() abort return "%t" endfunc < `stl=%{Stl_filename()}` results in `"%t"` `stl=%{%Stl_filename()%}` results in `"Name of current file"` - } - End of `{%` expression + %} - End of `{%` expression ( - Start of item group. Can be used for setting the width and alignment of a section. Must be followed by %) somewhere. ) - End of item group. No width fields allowed. diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index c49cc6d540..dfed39dba6 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -977,7 +977,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): /.*\%17v < Column 17 is highlighted by 'hlsearch' because there is another match where ".*" matches zero characters. -< + Character classes: \i identifier character (see 'isident' option) */\i* diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index b06fa7518c..5484e27797 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -168,7 +168,7 @@ g8 Print the hex values of the bytes used in the *:z!* :[range]z![+-^.=][count] - Like ":z:", but when [count] is not specified, it + Like ":z", but when [count] is not specified, it defaults to the Vim window height minus one. :[range]z[!]#[+-^.=][count] *:z#* diff --git a/runtime/filetype.vim b/runtime/filetype.vim index c86ca9646b..75354968e9 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -703,6 +703,7 @@ au BufNewFile,BufRead *.gpi setf gnuplot " Go (Google) au BufNewFile,BufRead *.go setf go +au BufNewFile,BufRead Gopkg.lock setf toml " GrADS scripts au BufNewFile,BufRead *.gs setf grads @@ -1283,7 +1284,7 @@ au BufNewFile,BufRead *.rcp setf pilrc au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine " Pipenv Pipfiles -au BufNewFile,BufRead Pipfile setf config +au BufNewFile,BufRead Pipfile setf toml au BufNewFile,BufRead Pipfile.lock setf json " PL/1, PL/I @@ -1517,6 +1518,7 @@ au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby " Rust au BufNewFile,BufRead *.rs setf rust +au BufNewFile,BufRead Cargo.lock,*/.cargo/config,*/.cargo/credentials setf toml " S-lang (or shader language, or SmallLisp) au BufNewFile,BufRead *.sl setf slang @@ -2301,6 +2303,9 @@ au BufNewFile,BufRead .tcshrc* call dist#ft#SetFileTypeShell("tcsh") " csh scripts ending in a star au BufNewFile,BufRead .login*,.cshrc* call dist#ft#CSH() +" tmux configuration with arbitrary extension +au BufNewFile,BufRead {.,}tmux*.conf* setf tmux + " VHDL au BufNewFile,BufRead *.vhdl_[0-9]* call s:StarSetf('vhdl') diff --git a/runtime/ftplugin/context.vim b/runtime/ftplugin/context.vim index 10f1ae1648..37f7240d7b 100644 --- a/runtime/ftplugin/context.vim +++ b/runtime/ftplugin/context.vim @@ -2,7 +2,7 @@ " Language: ConTeXt typesetting engine " Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> " Former Maintainers: Nikolai Weibull <now@bitwi.se> -" Latest Revision: 2016 Oct 30 +" Latest Revision: 2021 Oct 15 if exists("b:did_ftplugin") finish @@ -17,7 +17,6 @@ if !exists('current_compiler') endif let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo< ofu<" - \ . "| unlet! b:match_ignorecase b:match_words b:match_skip" setlocal comments=b:%D,b:%C,b:%M,:% commentstring=%\ %s formatoptions+=tjcroql2 if get(b:, 'context_metapost', get(g:, 'context_metapost', 1)) @@ -35,11 +34,12 @@ let &l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)' setlocal suffixesadd=.tex -if exists("loaded_matchit") +if exists("loaded_matchit") && !exists("b:match_words") let b:match_ignorecase = 0 let b:match_skip = 'r:\\\@<!\%(\\\\\)*%' let b:match_words = '(:),\[:],{:},\\(:\\),\\\[:\\],' . \ '\\start\(\a\+\):\\stop\1' + let b:undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words b:match_skip" endif let s:context_regex = { @@ -57,19 +57,28 @@ function! s:move_around(count, what, flags, visual) call map(range(2, a:count), 'search(s:context_regex[a:what], a:flags)') endfunction -" Move around macros. -nnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR> -vnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR> -nnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR> -vnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR> -nnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR> -vnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR> -nnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR> -vnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR> -nnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR> -vnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR> -nnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR> -vnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR> +if !exists("no_plugin_maps") && !exists("no_context_maps") + " Move around macros. + nnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR> + vnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR> + nnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR> + vnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR> + nnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR> + vnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR> + nnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR> + vnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR> + nnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR> + vnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR> + nnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR> + vnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR> + + let b:undo_ftplugin .= " | sil! exe 'nunmap <buffer> [[' | sil! exe 'vunmap <buffer> [['" . + \ " | sil! exe 'nunmap <buffer> ]]' | sil! exe 'vunmap <buffer> ]]'" . + \ " | sil! exe 'nunmap <buffer> []' | sil! exe 'vunmap <buffer> []'" . + \ " | sil! exe 'nunmap <buffer> ][' | sil! exe 'vunmap <buffer> ]['" . + \ " | sil! exe 'nunmap <buffer> [{' | sil! exe 'vunmap <buffer> [{'" . + \ " | sil! exe 'nunmap <buffer> ]}' | sil! exe 'vunmap <buffer> ]}'" +end " Other useful mappings if get(g:, 'context_mappings', 1) @@ -81,16 +90,22 @@ if get(g:, 'context_mappings', 1) call cursor(search(s:tp_regex, 'W') - 1, 1) endf - " Reflow paragraphs with commands like gqtp ("gq TeX paragraph") - onoremap <silent><buffer> tp :<c-u>call <sid>tp()<cr> - " Select TeX paragraph - vnoremap <silent><buffer> tp <esc>:<c-u>call <sid>tp()<cr> - - " $...$ text object - onoremap <silent><buffer> i$ :<c-u>normal! T$vt$<cr> - onoremap <silent><buffer> a$ :<c-u>normal! F$vf$<cr> - vnoremap <buffer> i$ T$ot$ - vnoremap <buffer> a$ F$of$ + if !exists("no_plugin_maps") && !exists("no_context_maps") + " Reflow paragraphs with commands like gqtp ("gq TeX paragraph") + onoremap <silent><buffer> tp :<c-u>call <sid>tp()<cr> + " Select TeX paragraph + vnoremap <silent><buffer> tp <esc>:<c-u>call <sid>tp()<cr> + + " $...$ text object + onoremap <silent><buffer> i$ :<c-u>normal! T$vt$<cr> + onoremap <silent><buffer> a$ :<c-u>normal! F$vf$<cr> + vnoremap <buffer> i$ T$ot$ + vnoremap <buffer> a$ F$of$ + + let b:undo_ftplugin .= " | sil! exe 'ounmap <buffer> tp' | sil! exe 'vunmap <buffer> tp'" . + \ " | sil! exe 'ounmap <buffer> i$' | sil! exe 'vunmap <buffer> i$'" . + \ " | sil! exe 'ounmap <buffer> a$' | sil! exe 'vunmap <buffer> a$'" + endif endif " Commands for asynchronous typesetting diff --git a/runtime/ftplugin/csh.vim b/runtime/ftplugin/csh.vim index 4ae09f91be..929823219c 100644 --- a/runtime/ftplugin/csh.vim +++ b/runtime/ftplugin/csh.vim @@ -1,21 +1,23 @@ " Vim filetype plugin file -" Language: csh -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> -" Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin +" Language: csh +" Maintainer: Doug Kearns <dougkearns@gmail.com> +" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" Contributor: Johannes Zellner <johannes@zellner.org> +" Last Change: 2021 Oct 15 if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 -" Make sure the continuation lines below do not cause problems in -" compatibility mode. let s:save_cpo = &cpo set cpo-=C +setlocal comments=:# setlocal commentstring=#%s setlocal formatoptions-=t setlocal formatoptions+=crql +let b:undo_ftplugin = "setlocal com< cms< fo<" + " Csh: thanks to Johannes Zellner " - Both foreach and end must appear alone on separate lines. " - The words else and endif must appear at the beginning of input lines; @@ -23,26 +25,27 @@ setlocal formatoptions+=crql " - Each case label and the default label must appear at the start of a " line. " - while and end must appear alone on their input lines. -if exists("loaded_matchit") - let b:match_words = - \ '^\s*\<if\>.*(.*).*\<then\>:'. - \ '^\s*\<else\>\s\+\<if\>.*(.*).*\<then\>:^\s*\<else\>:'. - \ '^\s*\<endif\>,'. - \ '\%(^\s*\<foreach\>\s\+\S\+\|^s*\<while\>\).*(.*):'. - \ '\<break\>:\<continue\>:^\s*\<end\>,'. - \ '^\s*\<switch\>.*(.*):^\s*\<case\>\s\+:^\s*\<default\>:^\s*\<endsw\>' +if exists("loaded_matchit") && !exists("b:match_words") + let s:line_start = '\%(^\s*\)\@<=' + let b:match_words = + \ s:line_start .. 'if\s*(.*)\s*then\>:' .. + \ s:line_start .. 'else\s\+if\s*(.*)\s*then\>:' .. s:line_start .. 'else\>:' .. + \ s:line_start .. 'endif\>,' .. + \ s:line_start .. '\%(\<foreach\s\+\h\w*\|while\)\s*(:' .. + \ '\<break\>:\<continue\>:' .. + \ s:line_start .. 'end\>,' .. + \ s:line_start .. 'switch\s*(:' .. + \ s:line_start .. 'case\s\+:' .. s:line_start .. 'default\>:\<breaksw\>:' .. + \ s:line_start .. 'endsw\>' + unlet s:line_start + let b:undo_ftplugin ..= " | unlet b:match_words" endif -" Change the :browse e filter to primarily show csh-related files. -if has("gui_win32") - let b:browsefilter="csh Scripts (*.csh)\t*.csh\n" . - \ "All Files (*.*)\t*.*\n" +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter="csh Scripts (*.csh)\t*.csh\n" .. + \ "All Files (*.*)\t*.*\n" + let b:undo_ftplugin ..= " | unlet b:browsefilter" endif -" Undo the stuff we changed. -let b:undo_ftplugin = "setlocal commentstring< formatoptions<" . - \ " | unlet! b:match_words b:browsefilter" - -" Restore the saved compatibility options. let &cpo = s:save_cpo unlet s:save_cpo diff --git a/runtime/ftplugin/tcsh.vim b/runtime/ftplugin/tcsh.vim index 7e2d959932..33f1aabf68 100644 --- a/runtime/ftplugin/tcsh.vim +++ b/runtime/ftplugin/tcsh.vim @@ -1,19 +1,17 @@ " Vim filetype plugin file -" Language: tcsh -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> -" Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin +" Language: tcsh +" Maintainer: Doug Kearns <dougkearns@gmail.com> +" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" Last Change: 2021 Oct 15 if exists("b:did_ftplugin") | finish | endif -" Make sure the continuation lines below do not cause problems in -" compatibility mode. let s:save_cpo = &cpo set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" -let s:browsefilter = "csh Files (*.csh)\t*.csh\n" . +let s:browsefilter = "csh Files (*.csh)\t*.csh\n" .. \ "All Files (*.*)\t*.*\n" runtime! ftplugin/csh.vim ftplugin/csh_*.vim ftplugin/csh/*.vim @@ -27,14 +25,11 @@ if exists("b:browsefilter") let s:browsefilter = b:browsefilter endif -" Change the :browse e filter to primarily show tcsh-related files. -if has("gui_win32") - let b:browsefilter="tcsh Scripts (*.tcsh)\t*.tcsh\n" . s:browsefilter +if (has("gui_win32") || has("gui_gtk")) + let b:browsefilter="tcsh Scripts (*.tcsh)\t*.tcsh\n" .. s:browsefilter endif -" Undo the stuff we changed. -let b:undo_ftplugin = "unlet! b:browsefilter | " . s:undo_ftplugin +let b:undo_ftplugin = "unlet! b:browsefilter | " .. s:undo_ftplugin -" Restore the saved compatibility options. let &cpo = s:save_cpo unlet s:save_cpo diff --git a/runtime/ftplugin/tmux.vim b/runtime/ftplugin/tmux.vim index ed9154924b..5c3461fefb 100644 --- a/runtime/ftplugin/tmux.vim +++ b/runtime/ftplugin/tmux.vim @@ -9,4 +9,7 @@ if exists("b:did_ftplugin") endif let b:did_ftplugin = 1 +let b:undo_ftplugin = "setlocal comments< commentstring<" + +setlocal comments=:# setlocal commentstring=#\ %s diff --git a/runtime/ftplugin/toml.vim b/runtime/ftplugin/toml.vim new file mode 100644 index 0000000000..1ef09a16e3 --- /dev/null +++ b/runtime/ftplugin/toml.vim @@ -0,0 +1,23 @@ +" Vim filetype plugin +" Language: TOML +" Homepage: https://github.com/cespare/vim-toml +" Maintainer: Aman Verma +" Author: Kevin Ballard <kevin@sb.org> +" Last Change: Sep 21, 2021 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +let s:save_cpo = &cpo +set cpo&vim +let b:undo_ftplugin = 'setlocal commentstring< comments<' + +setlocal commentstring=#\ %s +setlocal comments=:# + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: et sw=2 sts=2 diff --git a/runtime/indent/hamster.vim b/runtime/indent/hamster.vim index b27a173924..ae5c3fdedd 100644 --- a/runtime/indent/hamster.vim +++ b/runtime/indent/hamster.vim @@ -1,8 +1,14 @@ " Vim indent file " Language: Hamster Script -" Version: 2.0.6.0 -" Last Change: Wed Nov 08 2006 12:02:42 PM -" Maintainer: David Fishburn <fishburn@ianywhere.com> +" Version: 2.0.6.1 +" Last Change: 2021 Oct 11 +" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com> +" Download: https://www.vim.org/scripts/script.php?script_id=1099 +" +" 2.0.6.1 (Oct 2021) +" Added b:undo_indent +" Added cpo check +" " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -14,12 +20,17 @@ setlocal indentkeys+==~if,=~else,=~endif,=~endfor,=~endwhile setlocal indentkeys+==~do,=~until,=~while,=~repeat,=~for,=~loop setlocal indentkeys+==~sub,=~endsub +let b:undo_indent = "setl indentkeys<" + " Define the appropriate indent function but only once setlocal indentexpr=HamGetFreeIndent() if exists("*HamGetFreeIndent") finish endif +let s:keepcpo = &cpo +set cpo&vim + function HamGetIndent(lnum) let ind = indent(a:lnum) let prevline=getline(a:lnum) @@ -52,4 +63,8 @@ function HamGetFreeIndent() return ind endfunction +" Restore: +let &cpo = s:keepcpo +unlet s:keepcpo + " vim:sw=2 tw=80 diff --git a/runtime/indent/sqlanywhere.vim b/runtime/indent/sqlanywhere.vim index d39fa3240e..4772b5951b 100644 --- a/runtime/indent/sqlanywhere.vim +++ b/runtime/indent/sqlanywhere.vim @@ -1,9 +1,8 @@ " Vim indent file " Language: SQL " Maintainer: David Fishburn <dfishburn dot vim at gmail dot com> -" Last Change By Maintainer: 2017 Jun 13 -" Last Change: by Stephen Wall, #5578, 2020 Jun 07 -" Version: 3.0 +" Last Change: 2021 Oct 11 +" Version: 4.0 " Download: http://vim.sourceforge.net/script.php?script_id=495 " Notes: @@ -21,6 +20,9 @@ " it, this can leave the indent hanging to the right one too many. " " History: +" 4.0 (Oct 2021) +" Added b:undo_indent +" " 3.0 (Dec 2012) " Added cpo check " @@ -56,10 +58,13 @@ setlocal indentkeys+==~end,=~else,=~elseif,=~elsif,0=~when,0=) " in the indentkeys is typed setlocal indentexpr=GetSQLIndent() +let b:undo_indent = "setl indentexpr< indentkeys<" + " Only define the functions once. if exists("*GetSQLIndent") finish endif + let s:keepcpo= &cpo set cpo&vim @@ -68,14 +73,9 @@ set cpo&vim " IS is excluded, since it is difficult to determine when the " ending block is (especially for procedures/functions). let s:SQLBlockStart = '^\s*\%('. - \ 'if\>.*\<then\|'. - \ 'then\|else\>\|'. - \ 'elseif\>.*\<then\|'. - \ 'elsif\>.(\<then\|'. - \ 'while\>.*\<loop\|'. - \ 'for\>.*\<loop\|'. - \ 'foreach\>.*\<loop\|'. - \ 'loop\|do\|declare\|begin\|'. + \ 'if\|else\|elseif\|elsif\|'. + \ 'while\|loop\|do\|for\|'. + \ 'begin\|'. \ 'case\|when\|merge\|exception'. \ '\)\>' let s:SQLBlockEnd = '^\s*\(end\)\>' diff --git a/runtime/indent/tcsh.vim b/runtime/indent/tcsh.vim index 025d9c805d..93d96e7789 100644 --- a/runtime/indent/tcsh.vim +++ b/runtime/indent/tcsh.vim @@ -1,7 +1,8 @@ " Vim indent file " Language: C-shell (tcsh) -" Maintainer: Doug Kearns <a@b.com> where a=dougkearns, b=gmail -" Last Modified: Sun 26 Sep 2021 12:38:38 PM EDT +" Maintainer: Doug Kearns <dougkearns@gmail.com> +" Previous Maintainer: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author) +" Last Change: 2021 Oct 15 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -11,7 +12,9 @@ endif let b:did_indent = 1 setlocal indentexpr=TcshGetIndent() -setlocal indentkeys+=e,0=end,0=endsw indentkeys-=0{,0},0),:,0# +setlocal indentkeys+=e,0=end +setlocal indentkeys-=0{,0},0),:,0# + let b:undo_indent = "setl inde< indk<" " Only define the function once. @@ -40,9 +43,9 @@ function TcshGetIndent() let ind = ind - shiftwidth() endif - " Subtract indent if current line has on end, endif, case commands + " Subtract indent if current line has on end, endif, endsw, case commands let line = getline(v:lnum) - if line =~ '\v^\s*%(else|end|endif)\s*$' + if line =~ '\v^\s*%(else|end|endif|endsw)\s*$' let ind = ind - shiftwidth() endif diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua index a3e79a0f2b..5d8d4fa169 100644 --- a/runtime/lua/vim/uri.lua +++ b/runtime/lua/vim/uri.lua @@ -75,13 +75,22 @@ local function uri_from_fname(path) end local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):.*' +local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):[a-zA-Z]:.*' --- Get a URI from a bufnr ---@param bufnr (number): Buffer number ---@return URI local function uri_from_bufnr(bufnr) local fname = vim.api.nvim_buf_get_name(bufnr) - local scheme = fname:match(URI_SCHEME_PATTERN) + local volume_path = fname:match("^([a-zA-Z]:).*") + local is_windows = volume_path ~= nil + local scheme + if is_windows then + fname = fname:gsub("\\", "/") + scheme = fname:match(WINDOWS_URI_SCHEME_PATTERN) + else + scheme = fname:match(URI_SCHEME_PATTERN) + end if scheme then return fname else diff --git a/runtime/syntax/css.vim b/runtime/syntax/css.vim index 19326d01e4..67ad1ea335 100644 --- a/runtime/syntax/css.vim +++ b/runtime/syntax/css.vim @@ -2,12 +2,12 @@ " Language: Cascading Style Sheets " Previous Contributor List: " Jules Wang <w.jq0722@gmail.com> -" Claudio Fleiner <claudio@fleiner.com> (Maintainer) +" Claudio Fleiner <claudio@fleiner.com> " Yeti (Add full CSS2, HTML4 support) " Nikolai Weibull (Add CSS2 support) -" URL: https://github.com/jsit/css.vim +" URL: https://github.com/vim-language-dept/css-syntax.vim " Maintainer: Jay Sitter <jay@jaysitter.com> -" Last Change: 2019 Jul. 29 +" Last Change: 2021 Oct 15 " quit when a syntax file was already loaded if !exists("main_syntax") @@ -23,6 +23,8 @@ let s:cpo_save = &cpo set cpo&vim syn case ignore +" Add dash to allowed keyword characters. +syn iskeyword @,48-57,_,192-255,- " HTML4 tags syn keyword cssTagName abbr address area a b base @@ -32,7 +34,7 @@ syn keyword cssTagName dfn div dl dt em fieldset form syn keyword cssTagName h1 h2 h3 h4 h5 h6 head hr html img i syn keyword cssTagName iframe input ins isindex kbd label legend li syn keyword cssTagName link map menu meta noscript ol optgroup -syn keyword cssTagName option p param pre q s samp script small +syn keyword cssTagName option p param picture pre q s samp script small syn keyword cssTagName span strong sub sup tbody td syn keyword cssTagName textarea tfoot th thead title tr ul u var syn keyword cssTagName object svg @@ -127,7 +129,7 @@ syn region cssURL contained matchgroup=cssFunctionName start="\<\(uri\|url\|loca syn region cssFunction contained matchgroup=cssFunctionName start="\<\(var\|calc\)\s*(" end=")" contains=cssCustomProp,cssValue.*,cssFunction,cssColor,cssStringQ,cssStringQQ oneline syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgb\|clip\|attr\|counter\|rect\|cubic-bezier\|steps\)\s*(" end=")" oneline contains=cssValueInteger,cssValueNumber,cssValueLength,cssFunctionComma syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgba\|hsl\|hsla\|color-stop\|from\|to\)\s*(" end=")" oneline contains=cssColor,cssValueInteger,cssValueNumber,cssValueLength,cssFunctionComma,cssFunction -syn region cssFunction contained matchgroup=cssFunctionName start="\<\(linear-\|radial-\)\=\gradient\s*(" end=")" oneline contains=cssColor,cssValueInteger,cssValueNumber,cssValueLength,cssFunction,cssGradientAttr,cssFunctionComma +syn region cssFunction contained matchgroup=cssFunctionName start="\<\(linear-\|radial-\|conic-\)\=\gradient\s*(" end=")" oneline contains=cssColor,cssValueInteger,cssValueNumber,cssValueLength,cssFunction,cssGradientAttr,cssFunctionComma syn region cssFunction contained matchgroup=cssFunctionName start="\<\(matrix\(3d\)\=\|scale\(3d\|X\|Y\|Z\)\=\|translate\(3d\|X\|Y\|Z\)\=\|skew\(X\|Y\)\=\|rotate\(3d\|X\|Y\|Z\)\=\|perspective\)\s*(" end=")" oneline contains=cssValueInteger,cssValueNumber,cssValueLength,cssValueAngle,cssFunctionComma syn region cssFunction contained matchgroup=cssFunctionName start="\<\(blur\|brightness\|contrast\|drop-shadow\|grayscale\|hue-rotate\|invert\|opacity\|saturate\|sepia\)\s*(" end=")" oneline contains=cssValueInteger,cssValueNumber,cssValueLength,cssValueAngle,cssFunctionComma syn keyword cssGradientAttr contained top bottom left right cover center middle ellipse at @@ -220,7 +222,7 @@ syn keyword cssFlexibleBoxProp contained order syn match cssFlexibleBoxAttr contained "\<\(row\|column\|wrap\)\(-reverse\)\=\>" syn keyword cssFlexibleBoxAttr contained nowrap stretch baseline center syn match cssFlexibleBoxAttr contained "\<flex\(-\(start\|end\)\)\=\>" -syn match cssFlexibleBoxAttr contained "\<space\(-\(between\|around\)\)\=\>" +syn match cssFlexibleBoxAttr contained "\<space\(-\(between\|around\|evenly\)\)\=\>" " CSS Fonts Module Level 3 " http://www.w3.org/TR/css-fonts-3/ @@ -234,9 +236,7 @@ syn keyword cssFontAttr contained larger smaller syn match cssFontAttr contained "\<\(x\{1,2\}-\)\=\(large\|small\)\>" syn match cssFontAttr contained "\<small-\(caps\|caption\)\>" " font-family attributes -syn match cssFontAttr contained "\<\(sans-\)\=serif\>" -syn keyword cssFontAttr contained Antiqua Arial Black Book Charcoal Comic Courier Dingbats Gadget Geneva Georgia Grande Helvetica Impact Linotype Lucida MS Monaco Neue New Palatino Roboto Roman Symbol Tahoma Times Trebuchet Verdana Webdings Wingdings York Zapf -syn keyword cssFontAttr contained cursive fantasy monospace +syn keyword cssFontAttr contained sans-serif serif cursive fantasy monospace " font-feature-settings attributes syn keyword cssFontAttr contained on off " font-stretch attributes @@ -283,6 +283,7 @@ syn match cssGridProp contained "\<grid\>" syn match cssGridProp contained "\<grid-template\(-\(columns\|rows\|areas\)\)\=\>" syn match cssGridProp contained "\<grid-\(column\|row\)\(-\(start\|end\|gap\)\)\=\>" syn match cssGridProp contained "\<grid-\(area\|gap\)\>" +syn match cssGridProp contained "\<gap\>" syn match cssGridProp contained "\<grid-auto-\(flow\|rows\|columns\)\>" syn match cssHyerlinkProp contained "\<target\(-\(name\|new\|position\)\)\=\>" @@ -294,6 +295,10 @@ syn match cssListAttr contained "\<\(decimal\(-leading-zero\)\=\|cjk-ideographic syn keyword cssListAttr contained disc circle square hebrew armenian georgian syn keyword cssListAttr contained inside outside +" object-fit https://www.w3.org/TR/css-images-3/#the-object-fit +syn match cssObjectProp contained "\<object-\(fit\|position\)\>" +syn keyword cssObjectAttr contained fill contain cover scale-down + syn keyword cssPositioningProp contained bottom clear clip display float left syn keyword cssPositioningProp contained position right top visibility syn match cssPositioningProp contained "\<z-index\>" @@ -303,7 +308,7 @@ syn keyword cssPositioningAttr contained left right both syn match cssPositioningAttr contained "\<list-item\>" syn match cssPositioningAttr contained "\<inline\(-\(block\|box\|table\|grid\|flex\)\)\=\>" syn match cssPositioningAttr contained "\<flow\(-root\)\=\>" -syn keyword cssPositioningAttr contained static relative absolute fixed subgrid +syn keyword cssPositioningAttr contained static relative absolute fixed subgrid sticky syn keyword cssPrintAttr contained landscape portrait crop cross always @@ -548,6 +553,7 @@ hi def link cssMarqueeProp cssProp hi def link cssMultiColumnProp cssProp hi def link cssPagedMediaProp cssProp hi def link cssPositioningProp cssProp +hi def link cssObjectProp cssProp hi def link cssPrintProp cssProp hi def link cssRubyProp cssProp hi def link cssSpeechProp cssProp @@ -581,6 +587,7 @@ hi def link cssMultiColumnAttr cssAttr hi def link cssPaddingAttr cssAttr hi def link cssPagedMediaAttr cssAttr hi def link cssPositioningAttr cssAttr +hi def link cssObjectAttr cssAttr hi def link cssGradientAttr cssAttr hi def link cssPrintAttr cssAttr hi def link cssRubyAttr cssAttr diff --git a/runtime/syntax/tcsh.vim b/runtime/syntax/tcsh.vim index 27c6417fd0..6837125129 100644 --- a/runtime/syntax/tcsh.vim +++ b/runtime/syntax/tcsh.vim @@ -1,8 +1,9 @@ -" tcsh.vim: Vim syntax file for tcsh scripts -" Maintainer: Doug Kearns <dougkearns@NoSpam.com> where NoSpam=gmail -" Author: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail -" Modified: Sun 26 Sep 2021 12:40:55 PM EDT -" +" Vim syntax file +" Language: tcsh scripts +" Maintainer: Doug Kearns <dougkearns@gmail.com> +" Previous Maintainer: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author) +" Last Change: 2021 Oct 15 + " Description: We break up each statement into a "command" and an "end" part. " All groups are either a "command" or part of the "end" of a statement (ie " everything after the "command"). This is because blindly highlighting tcsh @@ -20,36 +21,36 @@ endif let s:oldcpo = &cpo set cpo&vim " Line continuation is used -setlocal iskeyword+=- +syn iskeyword @,48-57,_,192-255,- syn case match -" ----- Clusters ----- +" ----- Clusters ----- {{{1 syn cluster tcshModifiers contains=tcshModifier,tcshModifierError syn cluster tcshQuoteList contains=tcshDQuote,tcshSQuote,tcshBQuote -syn cluster tcshStatementEnds contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshRedir,tcshMeta,tcshHereDoc,tcshSpecial,tcshArguement +syn cluster tcshStatementEnds contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshRedir,tcshMeta,tcshHereDoc,tcshSpecial,tcshArgument syn cluster tcshStatements contains=tcshBuiltin,tcshCommands,tcshIf,tcshWhile syn cluster tcshVarList contains=tcshUsrVar,tcshArgv,tcshSubst syn cluster tcshConditions contains=tcshCmdSubst,tcshParenExpr,tcshOperator,tcshNumber,@tcshVarList -" ----- Errors ----- +" ----- Errors ----- {{{1 " Define first, so can be easily overridden. syn match tcshError contained '\v\S.+' -" ----- Statements ----- +" ----- Statements ----- {{{1 " Tcsh commands: Any filename / modifiable variable (must be first!) syn match tcshCommands '\v[a-zA-Z0-9\\./_$:-]+' contains=tcshSpecial,tcshUsrVar,tcshArgv,tcshVarError nextgroup=tcshStatementEnd " Builtin commands except those treated specially. Currently (un)set(env), " (un)alias, if, while, else, bindkey -syn keyword tcshBuiltin nextgroup=tcshStatementEnd alloc bg break breaksw builtins bye case cd chdir complete continue default dirs echo echotc end endif endsw eval exec exit fg filetest foreach getspath getxvers glob goto hashstat history hup inlib jobs kill limit log login logout ls ls-F migrate newgrp nice nohup notify onintr popd printenv pushd rehash repeat rootnode sched setpath setspath settc setty setxvers shift source stop suspend switch telltc time umask uncomplete unhash universe unlimit ver wait warp watchlog where which +syn keyword tcshBuiltin nextgroup=tcshStatementEnd alloc bg break breaksw builtins bye case cd chdir complete continue default dirs echo echotc end endif endsw eval exec exit fg filetest foreach getspath getxvers glob goto hashstat history hup inlib jobs kill limit log login logout ls ls-F migrate newgrp nice nohup notify onintr popd printenv pushd rehash repeat rootnode sched setpath setspath settc setty setxvers shift source stop suspend switch telltc termname time umask uncomplete unhash universe unlimit ver wait warp watchlog where which " StatementEnd is anything after a built-in / command till the lexical end of a " statement (;, |, ||, |&, && or end of line) syn region tcshStatementEnd transparent contained matchgroup=tcshBuiltin start='' end='\v\\@<!(;|\|[|&]?|\&\&|$)' contains=@tcshStatementEnds " set expressions (Contains shell variables) -syn keyword tcshShellVar contained afsuser ampm argv autocorrect autoexpand autolist autologout backslash_quote catalog cdpath color colorcat command complete continue continue_args correct cwd dextract dirsfile dirstack dspmbyte dunique echo echo_style edit ellipsis fignore filec gid group histchars histdup histfile histlit history home ignoreeof implicitcd inputmode killdup killring listflags listjobs listlinks listmax listmaxrows loginsh logout mail matchbeep nobeep noclobber noding noglob nokanji nonomatch nostat notify oid owd path printexitvalue prompt prompt2 prompt3 promptchars pushdtohome pushdsilent recexact recognize_only_executables rmstar rprompt savedirs savehist sched shell shlvl status symlinks tcsh term time tperiod tty uid user verbose version visiblebell watch who wordchars +syn keyword tcshShellVar contained addsuffix afsuser ampm anyerror argv autocorrect autoexpand autolist autologout autorehash backslash_quote catalog cdpath cdtohome color colorcat command compat_expr complete continue continue_args correct csubstnonl cwd dextract dirsfile dirstack dspmbyte dunique echo echo_style edit editors ellipsis euid euser fignore filec gid globdot globstar group highlight histchars histdup histfile histlit history home ignoreeof implicitcd inputmode killdup killring listflags listjobs listlinks listmax listmaxrows loginsh logout mail matchbeep nobeep noclobber noding noglob nokanji nonomatch nostat notify oid owd padhour parseoctal path printexitvalue prompt prompt2 prompt3 promptchars pushdtohome pushdsilent recexact recognize_only_executables rmstar rprompt savedirs savehist sched shell shlvl status symlinks tcsh term time tperiod tty uid user verbose version vimode visiblebell watch who wordchars syn keyword tcshBuiltin nextgroup=tcshSetEnd set unset syn region tcshSetEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=tcshShellVar,@tcshStatementEnds @@ -96,14 +97,15 @@ syn keyword tcshBindkeyFuncs contained backward-char backward-delete-char \ history-search-forward insert-last-word i-search-fwd \ i-search-back keyboard-quit kill-line kill-region \ kill-whole-line list-choices list-choices-raw list-glob - \ list-or-eof load-average magic-space newline normalize-path - \ normalize-command overwrite-mode prefix-meta quoted-insert - \ redisplay run-fg-editor run-help self-insert-command - \ sequence-lead-in set-mark-command spell-word spell-line - \ stuff-char toggle-literal-history transpose-chars - \ transpose-gosling tty-dsusp tty-flush-output tty-sigintr - \ tty-sigquit tty-sigtsusp tty-start-output tty-stop-output - \ undefined-key universal-argument up-history upcase-word + \ list-or-eof load-average magic-space newline newline-and-hold + \ newline-and-down-history normalize-path normalize-command + \ overwrite-mode prefix-meta quoted-insert redisplay + \ run-fg-editor run-help self-insert-command sequence-lead-in + \ set-mark-command spell-word spell-line stuff-char + \ toggle-literal-history transpose-chars transpose-gosling + \ tty-dsusp tty-flush-output tty-sigintr tty-sigquit tty-sigtsusp + \ tty-start-output tty-stop-output undefined-key + \ universal-argument up-history upcase-word \ vi-beginning-of-next-word vi-add vi-add-at-eol vi-chg-case \ vi-chg-meta vi-chg-to-eol vi-cmd-mode vi-cmd-mode-complete \ vi-delprev vi-delmeta vi-endword vi-eword vi-char-back @@ -116,7 +118,7 @@ syn keyword tcshBindkeyFuncs contained backward-char backward-delete-char \ e_paste_from_clipboard e_dosify_next e_dosify_prev e_page_up \ e_page_down syn keyword tcshBuiltin nextgroup=tcshBindkeyEnd bindkey -syn region tcshBindkeyEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$' contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshMeta,tcshSpecial,tcshArguement,tcshBindkeyFuncs +syn region tcshBindkeyEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$' contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshMeta,tcshSpecial,tcshArgument,tcshBindkeyFuncs " Expressions start with @. syn match tcshExprStart '\v\@\s+' nextgroup=tcshExprVar @@ -126,20 +128,20 @@ syn match tcshExprOp contained '\v\s*\=' nextgroup=tcshExprEnd syn match tcshExprEnd contained '\v.*$'hs=e+1 contains=@tcshConditions syn match tcshExprEnd contained '\v.{-};'hs=e contains=@tcshConditions -" ----- Comments: ----- +" ----- Comments: ----- {{{1 syn match tcshComment '#\s.*' contains=tcshTodo,tcshCommentTi,@Spell syn match tcshComment '\v#($|\S.*)' contains=tcshTodo,tcshCommentTi syn match tcshSharpBang '^#! .*$' syn match tcshCommentTi contained '\v#\s*\u\w*(\s+\u\w*)*:'hs=s+1 contains=tcshTodo syn match tcshTodo contained '\v\c<todo>' -" ----- Strings ----- +" ----- Strings ----- {{{1 " Tcsh does not allow \" in strings unless the "backslash_quote" shell " variable is set. Set the vim variable "tcsh_backslash_quote" to 0 if you " want VIM to assume that no backslash quote constructs exist. " Backquotes are treated as commands, and are not contained in anything -if(exists('tcsh_backslash_quote') && tcsh_backslash_quote == 0) +if exists('tcsh_backslash_quote') && tcsh_backslash_quote == 0 syn region tcshSQuote keepend contained start="\v\\@<!'" end="'" syn region tcshDQuote keepend contained start='\v\\@<!"' end='"' contains=@tcshVarList,tcshSpecial,@Spell syn region tcshBQuote keepend start='\v\\@<!`' end='`' contains=@tcshStatements @@ -149,7 +151,7 @@ else syn region tcshBQuote keepend matchgroup=tcshBQuoteGrp start='\v\\@<!`' skip='\v\\\\|\\`' end='`' contains=@tcshStatements endif -" ----- Variables ----- +" ----- Variables ----- {{{1 " Variable Errors. Must come first! \$ constructs will be flagged by " tcshSpecial, so we don't consider them here. syn match tcshVarError '\v\$\S*' contained @@ -171,7 +173,7 @@ syn match tcshSubst contained '\v\$\{[%#?]%(\h\w*|\d+)%(:\S*)?\}' contains=tcshM syn match tcshModifierError contained '\v:\S*' syn match tcshModifier contained '\v:[ag]?[htreuls&qx]' nextgroup=@tcshModifiers -" ----- Operators / Specials ----- +" ----- Operators / Specials ----- {{{1 " Standard redirects (except <<) [<, >, >>, >>&, >>!, >>&!] syn match tcshRedir contained '\v\<|\>\>?\&?!?' @@ -190,13 +192,13 @@ syn match tcshOperator contained '&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\| syn match tcshNumber contained '\v<-?\d+>' " Arguments -syn match tcshArguement contained '\v\s@<=-(\w|-)*' +syn match tcshArgument contained '\v\s@<=-(\w|-)*' " Special characters. \xxx, or backslashed characters. "syn match tcshSpecial contained '\v\\@<!\\(\d{3}|.)' syn match tcshSpecial contained '\v\\%([0-7]{3}|.)' -" ----- Synchronising ----- +" ----- Synchronising ----- {{{1 if exists('tcsh_minlines') if tcsh_minlines == 'fromstart' syn sync fromstart @@ -207,6 +209,7 @@ else syn sync minlines=100 " Some completions can be quite long endif +" ----- Highlighting ----- {{{1 " Define highlighting of syntax groups hi def link tcshError Error hi def link tcshBuiltin Statement @@ -233,17 +236,20 @@ hi def link tcshVarError Error hi def link tcshUsrVar Type hi def link tcshArgv tcshUsrVar hi def link tcshSubst tcshUsrVar -hi def link tcshModifier tcshArguement +hi def link tcshModifier tcshArgument hi def link tcshModifierError tcshVarError hi def link tcshMeta tcshSubst hi def link tcshRedir tcshOperator hi def link tcshHereDoc tcshSQuote hi def link tcshOperator Operator hi def link tcshNumber Number -hi def link tcshArguement Special +hi def link tcshArgument Special hi def link tcshSpecial SpecialChar +" }}} let &cpo = s:oldcpo unlet s:oldcpo let b:current_syntax = 'tcsh' + +" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: diff --git a/runtime/syntax/tmux.vim b/runtime/syntax/tmux.vim index 4f435ab923..867c033cb5 100644 --- a/runtime/syntax/tmux.vim +++ b/runtime/syntax/tmux.vim @@ -1,5 +1,5 @@ " Language: tmux(1) configuration file -" Version: 3.0 (git-48cbbb87) +" Version: 3.2a (git-44ada9cd) " URL: https://github.com/ericpruitt/tmux.vim/ " Maintainer: Eric Pruitt <eric.pruitt@gmail.com> " License: 2-Clause BSD (http://opensource.org/licenses/BSD-2-Clause) @@ -30,14 +30,14 @@ syn match tmuxVariable /\w\+=/ display syn match tmuxVariableExpansion /\${\=\w\+}\=/ display syn match tmuxControl /%\(if\|elif\|else\|endif\)/ -syn region tmuxComment start=/#/ skip=/\\\@<!\\$/ end=/$/ contains=tmuxTodo +syn region tmuxComment start=/#/ skip=/\\\@<!\\$/ end=/$/ contains=tmuxTodo,@Spell -syn region tmuxString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=tmuxFormatString -syn region tmuxString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end='$' contains=tmuxFormatString +syn region tmuxString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=tmuxFormatString,@Spell +syn region tmuxString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end='$' contains=tmuxFormatString,@Spell " TODO: Figure out how escaping works inside of #(...) and #{...} blocks. syn region tmuxFormatString start=/#[#DFhHIPSTW]/ end=// contained keepend -syn region tmuxFormatString start=/#{/ skip=/#{.\{-}}/ end=/}/ contained keepend +syn region tmuxFormatString start=/#{/ skip=/#{.\{-}}/ end=/}/ keepend syn region tmuxFormatString start=/#(/ skip=/#(.\{-})/ end=/)/ contained keepend hi def link tmuxFormatString Identifier @@ -55,62 +55,69 @@ hi def link tmuxTodo Todo hi def link tmuxVariable Identifier hi def link tmuxVariableExpansion Identifier -" Make the foreground of colourXXX keywords match the color they represent. +" Make the foreground of colourXXX keywords match the color they represent +" when g:tmux_syntax_colors is unset or set to a non-zero value. " Darker colors have their background set to white. -for s:i in range(0, 255) - let s:bg = (!s:i || s:i == 16 || (s:i > 231 && s:i < 235)) ? 15 : "none" - exec "syn match tmuxColour" . s:i . " /\\<colour" . s:i . "\\>/ display" -\ " | highlight tmuxColour" . s:i . " ctermfg=" . s:i . " ctermbg=" . s:bg -endfor +if get(g:, "tmux_syntax_colors", 1) + for s:i in range(0, 255) + let s:bg = (!s:i || s:i == 16 || (s:i > 231 && s:i < 235)) ? 15 : "none" + exec "syn match tmuxColour" . s:i . " /\\<colour" . s:i . "\\>/ display" +\ " | highlight tmuxColour" . s:i . " ctermfg=" . s:i . " ctermbg=" . s:bg + endfor +endif syn keyword tmuxOptions -\ backspace buffer-limit command-alias default-terminal escape-time -\ exit-empty activity-action assume-paste-time base-index bell-action -\ default-command default-shell default-size destroy-unattached +\ backspace buffer-limit command-alias copy-command default-terminal editor +\ escape-time exit-empty activity-action assume-paste-time base-index +\ bell-action default-command default-shell default-size destroy-unattached \ detach-on-destroy display-panes-active-colour display-panes-colour -\ display-panes-time display-time exit-unattached focus-events history-file -\ history-limit key-table lock-after-time lock-command message-command-style -\ message-limit message-style aggressive-resize allow-rename -\ alternate-screen automatic-rename automatic-rename-format -\ clock-mode-colour clock-mode-style main-pane-height main-pane-width -\ mode-keys mode-style monitor-activity monitor-bell monitor-silence mouse -\ other-pane-height other-pane-width pane-active-border-style -\ pane-base-index pane-border-format pane-border-status pane-border-style -\ prefix prefix2 remain-on-exit renumber-windows repeat-time set-clipboard -\ set-titles set-titles-string silence-action status status-bg status-fg -\ status-format status-interval status-justify status-keys status-left -\ status-left-length status-left-style status-position status-right -\ status-right-length status-right-style status-style synchronize-panes -\ terminal-overrides update-environment user-keys visual-activity -\ visual-bell visual-silence window-active-style window-size -\ window-status-activity-style window-status-bell-style +\ display-panes-time display-time exit-unattached extended-keys focus-events +\ history-file history-limit key-table lock-after-time lock-command +\ message-command-style message-limit message-style aggressive-resize +\ allow-rename alternate-screen automatic-rename automatic-rename-format +\ clock-mode-colour clock-mode-style copy-mode-current-match-style +\ copy-mode-mark-style copy-mode-match-style main-pane-height +\ main-pane-width mode-keys mode-style monitor-activity monitor-bell +\ monitor-silence mouse other-pane-height other-pane-width +\ pane-active-border-style pane-base-index pane-border-format +\ pane-border-lines pane-border-status pane-border-style pane-colours prefix +\ prefix2 prompt-history-limit remain-on-exit renumber-windows repeat-time +\ set-clipboard set-titles set-titles-string silence-action status status-bg +\ status-fg status-format status-interval status-justify status-keys +\ status-left status-left-length status-left-style status-position +\ status-right status-right-length status-right-style status-style +\ synchronize-panes terminal-features terminal-overrides update-environment +\ user-keys visual-activity visual-bell visual-silence window-active-style +\ window-size window-status-activity-style window-status-bell-style \ window-status-current-format window-status-current-style \ window-status-format window-status-last-style window-status-separator -\ window-status-style window-style word-separators wrap-search xterm-keys +\ window-status-style window-style word-separators wrap-search syn keyword tmuxCommands \ attach attach-session bind bind-key break-pane breakp capture-pane \ capturep choose-buffer choose-client choose-tree clear-history clearhist -\ clock-mode command-prompt confirm confirm-before copy-mode detach -\ detach-client display display-menu display-message display-panes displayp -\ find-window findw if if-shell join-pane joinp kill-pane kill-server -\ kill-session kill-window killp has-session has killw link-window linkw -\ list-buffers list-clients list-commands list-keys list-panes list-sessions -\ list-windows load-buffer loadb lock lock-client lock-server lock-session -\ lockc last-pane lastp locks ls last-window last lsb lsc delete-buffer -\ deleteb lscm lsk lsp lsw menu move-pane move-window movep movew new -\ new-session new-window neww next next-layout next-window nextl -\ paste-buffer pasteb pipe-pane pipep prev previous-layout previous-window -\ prevl refresh refresh-client rename rename-session rename-window renamew -\ resize-pane resize-window resizep resizew respawn-pane respawn-window -\ respawnp respawnw rotate-window rotatew run run-shell save-buffer saveb +\ clock-mode command-prompt confirm confirm-before copy-mode customize-mode +\ detach detach-client display display-menu display-message display-panes +\ display-popup displayp find-window findw if if-shell join-pane joinp +\ kill-pane kill-server kill-session kill-window killp has has-session killw +\ link-window linkw list-buffers list-clients list-commands list-keys +\ list-panes list-sessions list-windows load-buffer loadb lock lock-client +\ lock-server lock-session lockc last-pane lastp locks ls last last-window +\ lsb delete-buffer deleteb lsc lscm lsk lsp lsw menu move-pane move-window +\ clear-prompt-history clearphist movep movew new new-session new-window +\ neww next next-layout next-window nextl paste-buffer pasteb pipe-pane +\ pipep popup prev previous-layout previous-window prevl refresh +\ refresh-client rename rename-session rename-window renamew resize-pane +\ resize-window resizep resizew respawn-pane respawn-window respawnp +\ respawnw rotate-window rotatew run run-shell save-buffer saveb \ select-layout select-pane select-window selectl selectp selectw send \ send-keys send-prefix set set-buffer set-environment set-hook set-option \ set-window-option setb setenv setw show show-buffer show-environment -\ show-hooks show-messages show-options show-window-options showb showenv -\ showmsgs showw source source-file split-window splitw start start-server -\ suspend-client suspendc swap-pane swap-window swapp swapw switch-client -\ switchc unbind unbind-key unlink-window unlinkw wait wait-for +\ show-hooks show-messages show-options show-prompt-history +\ show-window-options showb showenv showmsgs showphist showw source +\ source-file split-window splitw start start-server suspend-client suspendc +\ swap-pane swap-window swapp swapw switch-client switchc unbind unbind-key +\ unlink-window unlinkw wait wait-for let &cpo = s:original_cpo unlet! s:original_cpo s:bg s:i diff --git a/runtime/syntax/toml.vim b/runtime/syntax/toml.vim new file mode 100644 index 0000000000..bcb1b0b9c9 --- /dev/null +++ b/runtime/syntax/toml.vim @@ -0,0 +1,81 @@ +" Vim syntax file +" Language: TOML +" Homepage: https://github.com/cespare/vim-toml +" Maintainer: Aman Verma +" Previous Maintainer: Caleb Spare <cespare@gmail.com> +" Last Change: Oct 8, 2021 + +if exists('b:current_syntax') + finish +endif + +syn match tomlEscape /\\[btnfr"/\\]/ display contained +syn match tomlEscape /\\u\x\{4}/ contained +syn match tomlEscape /\\U\x\{8}/ contained +syn match tomlLineEscape /\\$/ contained + +" Basic strings +syn region tomlString oneline start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=tomlEscape +" Multi-line basic strings +syn region tomlString start=/"""/ end=/"""/ contains=tomlEscape,tomlLineEscape +" Literal strings +syn region tomlString oneline start=/'/ end=/'/ +" Multi-line literal strings +syn region tomlString start=/'''/ end=/'''/ + +syn match tomlInteger /[+-]\=\<[1-9]\(_\=\d\)*\>/ display +syn match tomlInteger /[+-]\=\<0\>/ display +syn match tomlInteger /[+-]\=\<0x[[:xdigit:]]\(_\=[[:xdigit:]]\)*\>/ display +syn match tomlInteger /[+-]\=\<0o[0-7]\(_\=[0-7]\)*\>/ display +syn match tomlInteger /[+-]\=\<0b[01]\(_\=[01]\)*\>/ display +syn match tomlInteger /[+-]\=\<\(inf\|nan\)\>/ display + +syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\.\d\+\>/ display +syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\(\.\d\(_\=\d\)*\)\=[eE][+-]\=\d\(_\=\d\)*\>/ display + +syn match tomlBoolean /\<\%(true\|false\)\>/ display + +" https://tools.ietf.org/html/rfc3339 +syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}/ display +syn match tomlDate /\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?/ display +syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}[T ]\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)\?/ display + +syn match tomlDotInKey /\v[^.]+\zs\./ contained display +syn match tomlKey /\v(^|[{,])\s*\zs[[:alnum:]._-]+\ze\s*\=/ contains=tomlDotInKey display +syn region tomlKeyDq oneline start=/\v(^|[{,])\s*\zs"/ end=/"\ze\s*=/ contains=tomlEscape +syn region tomlKeySq oneline start=/\v(^|[{,])\s*\zs'/ end=/'\ze\s*=/ + +syn region tomlTable oneline start=/^\s*\[[^\[]/ end=/\]/ contains=tomlKey,tomlKeyDq,tomlKeySq,tomlDotInKey + +syn region tomlTableArray oneline start=/^\s*\[\[/ end=/\]\]/ contains=tomlKey,tomlKeyDq,tomlKeySq,tomlDotInKey + +syn region tomlKeyValueArray start=/=\s*\[\zs/ end=/\]/ contains=@tomlValue + +syn region tomlArray start=/\[/ end=/\]/ contains=@tomlValue contained + +syn cluster tomlValue contains=tomlArray,tomlString,tomlInteger,tomlFloat,tomlBoolean,tomlDate,tomlComment + +syn keyword tomlTodo TODO FIXME XXX BUG contained + +syn match tomlComment /#.*/ contains=@Spell,tomlTodo + +hi def link tomlComment Comment +hi def link tomlTodo Todo +hi def link tomlTableArray Title +hi def link tomlTable Title +hi def link tomlDotInKey Normal +hi def link tomlKeySq Identifier +hi def link tomlKeyDq Identifier +hi def link tomlKey Identifier +hi def link tomlDate Constant +hi def link tomlBoolean Boolean +hi def link tomlFloat Float +hi def link tomlInteger Number +hi def link tomlString String +hi def link tomlLineEscape SpecialChar +hi def link tomlEscape SpecialChar + +syn sync minlines=500 +let b:current_syntax = 'toml' + +" vim: et sw=2 sts=2 diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 98f9da246c..c30a1b10da 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -106,7 +106,7 @@ end function M.main(opt) _trace = not opt or not not opt.trace - local branch = run({'git', 'branch', '--show-current'}, true) + local branch = run({'git', 'rev-parse', '--abbrev-ref', 'HEAD'}, true) -- TODO(justinmk): check $GITHUB_REF local ancestor = run({'git', 'merge-base', 'origin/master', branch}) if not ancestor then diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index e58a59e872..44552bcb26 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -712,7 +712,7 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Error *err) } fn = (String) { .data = (char *)di->di_tv.vval.v_string, - .size = strlen((char *)di->di_tv.vval.v_string), + .size = STRLEN(di->di_tv.vval.v_string), }; } diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 2617859381..37cc854959 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3235,7 +3235,7 @@ void maketitle(void) int use_sandbox = false; int save_called_emsg = called_emsg; - use_sandbox = was_set_insecurely(curwin, (char_u *)"titlestring", 0); + use_sandbox = was_set_insecurely(curwin, "titlestring", 0); called_emsg = false; build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf), p_titlestring, use_sandbox, @@ -3353,7 +3353,7 @@ void maketitle(void) int use_sandbox = false; int save_called_emsg = called_emsg; - use_sandbox = was_set_insecurely(curwin, (char_u *)"iconstring", 0); + use_sandbox = was_set_insecurely(curwin, "iconstring", 0); called_emsg = false; build_stl_str_hl(curwin, icon_str, sizeof(buf), p_iconstring, use_sandbox, diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index b0fc4ee463..0fa6ebcd94 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1843,12 +1843,12 @@ char_u *keymap_init(void) vim_snprintf(buf, buflen, "keymap/%s_%s.vim", curbuf->b_p_keymap, p_enc); - if (source_runtime((char_u *)buf, 0) == FAIL) { + if (source_runtime(buf, 0) == FAIL) { // try finding "keymap/'keymap'.vim" in 'runtimepath' vim_snprintf(buf, buflen, "keymap/%s.vim", curbuf->b_p_keymap); - if (source_runtime((char_u *)buf, 0) == FAIL) { + if (source_runtime(buf, 0) == FAIL) { xfree(buf); return (char_u *)N_("E544: Keymap file not found"); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 2709f24998..e6a3901dcf 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1191,7 +1191,7 @@ int eval_foldexpr(char_u *arg, int *cp) { typval_T tv; varnumber_T retval; - int use_sandbox = was_set_insecurely(curwin, (char_u *)"foldexpr", OPT_LOCAL); + int use_sandbox = was_set_insecurely(curwin, "foldexpr", OPT_LOCAL); ++emsg_off; if (use_sandbox) { @@ -10228,7 +10228,7 @@ bool script_autoload(const char *const name, const size_t name_len, const bool r } // Try loading the package from $VIMRUNTIME/autoload/<name>.vim - if (source_runtime((char_u *)scriptname, 0) == OK) { + if (source_runtime(scriptname, 0) == OK) { ret = true; } } diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 17cf141b54..da129c1170 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -4362,7 +4362,7 @@ static void f_globpath(typval_T *argvars, typval_T *rettv, FunPtr fptr) globpath((char_u *)tv_get_string(&argvars[0]), (char_u *)file, &ga, flags); if (rettv->v_type == VAR_STRING) { - rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n"); + rettv->vval.v_string = (char_u *)ga_concat_strings_sep(&ga, "\n"); } else { tv_list_alloc_ret(rettv, ga.ga_len); for (int i = 0; i < ga.ga_len; i++) { diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index d247118589..5d43a14168 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1439,11 +1439,11 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, if (linecount > p_report) { if (do_in) { - vim_snprintf((char *)msg_buf, sizeof(msg_buf), + vim_snprintf(msg_buf, sizeof(msg_buf), _("%" PRId64 " lines filtered"), (int64_t)linecount); - if (msg(msg_buf) && !msg_scroll) { + if (msg((char_u *)msg_buf) && !msg_scroll) { // save message to display it after redraw - set_keep_msg(msg_buf, 0); + set_keep_msg((char_u *)msg_buf, 0); } } else { msgmore((long)linecount); @@ -4451,24 +4451,24 @@ bool do_sub_msg(bool count_only) *msg_buf = NUL; } if (sub_nsubs == 1) { - vim_snprintf_add((char *)msg_buf, sizeof(msg_buf), + vim_snprintf_add(msg_buf, sizeof(msg_buf), "%s", count_only ? _("1 match") : _("1 substitution")); } else { - vim_snprintf_add((char *)msg_buf, sizeof(msg_buf), + vim_snprintf_add(msg_buf, sizeof(msg_buf), count_only ? _("%" PRId64 " matches") : _("%" PRId64 " substitutions"), (int64_t)sub_nsubs); } if (sub_nlines == 1) { - vim_snprintf_add((char *)msg_buf, sizeof(msg_buf), + vim_snprintf_add(msg_buf, sizeof(msg_buf), "%s", _(" on 1 line")); } else { - vim_snprintf_add((char *)msg_buf, sizeof(msg_buf), + vim_snprintf_add(msg_buf, sizeof(msg_buf), _(" on %" PRId64 " lines"), (int64_t)sub_nlines); } - if (msg(msg_buf)) { + if (msg((char_u *)msg_buf)) { // save message to display it after redraw - set_keep_msg(msg_buf, 0); + set_keep_msg((char_u *)msg_buf, 0); } return true; } @@ -5800,8 +5800,7 @@ void ex_helptags(exarg_T *eap) } if (STRCMP(eap->arg, "ALL") == 0) { - do_in_path(p_rtp, (char_u *)"doc", DIP_ALL + DIP_DIR, - helptags_cb, &add_help_tags); + do_in_path(p_rtp, "doc", DIP_ALL + DIP_DIR, helptags_cb, &add_help_tags); } else { ExpandInit(&xpc); xpc.xp_context = EXPAND_DIRECTORIES; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 4d26e16104..5d40d7a16a 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1614,10 +1614,10 @@ void ex_compiler(exarg_T *eap) do_unlet(S_LEN("b:current_compiler"), true); snprintf((char *)buf, bufsize, "compiler/%s.vim", eap->arg); - if (source_runtime(buf, DIP_ALL) == FAIL) { + if (source_runtime((char *)buf, DIP_ALL) == FAIL) { // Try lua compiler snprintf((char *)buf, bufsize, "compiler/%s.lua", eap->arg); - if (source_runtime(buf, DIP_ALL) == FAIL) { + if (source_runtime((char *)buf, DIP_ALL) == FAIL) { EMSG2(_("E666: compiler not supported: %s"), eap->arg); } } @@ -1797,7 +1797,7 @@ static void cmd_source(char_u *fname, exarg_T *eap) || eap->cstack->cs_idx >= 0); // ":source" read ex commands - } else if (do_source(fname, false, DOSO_NONE) == FAIL) { + } else if (do_source((char *)fname, false, DOSO_NONE) == FAIL) { EMSG2(_(e_notopen), fname); } } @@ -2024,7 +2024,7 @@ int do_source_str(const char *cmd, const char *traceback_name) /// @param is_vimrc DOSO_ value /// /// @return FAIL if file could not be opened, OK otherwise -int do_source(char_u *fname, int check_other, int is_vimrc) +int do_source(char *fname, int check_other, int is_vimrc) { struct source_cookie cookie; char_u *save_sourcing_name; @@ -2039,7 +2039,7 @@ int do_source(char_u *fname, int check_other, int is_vimrc) proftime_T wait_start; bool trigger_source_post = false; - p = expand_env_save(fname); + p = expand_env_save((char_u *)fname); if (p == NULL) { return retval; } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index dff3b4223b..16a9b78c6a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9433,14 +9433,14 @@ static void ex_filetype(exarg_T *eap) } if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) { if (*arg == 'o' || !filetype_detect) { - source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); + source_runtime(FILETYPE_FILE, DIP_ALL); filetype_detect = kTrue; if (plugin) { - source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); + source_runtime(FTPLUGIN_FILE, DIP_ALL); filetype_plugin = kTrue; } if (indent) { - source_runtime((char_u *)INDENT_FILE, DIP_ALL); + source_runtime(INDENT_FILE, DIP_ALL); filetype_indent = kTrue; } } @@ -9451,15 +9451,15 @@ static void ex_filetype(exarg_T *eap) } else if (STRCMP(arg, "off") == 0) { if (plugin || indent) { if (plugin) { - source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); + source_runtime(FTPLUGOF_FILE, DIP_ALL); filetype_plugin = kFalse; } if (indent) { - source_runtime((char_u *)INDOFF_FILE, DIP_ALL); + source_runtime(INDOFF_FILE, DIP_ALL); filetype_indent = kFalse; } } else { - source_runtime((char_u *)FTOFF_FILE, DIP_ALL); + source_runtime(FTOFF_FILE, DIP_ALL); filetype_detect = kFalse; } } else { @@ -9471,15 +9471,15 @@ static void ex_filetype(exarg_T *eap) void filetype_maybe_enable(void) { if (filetype_detect == kNone) { - source_runtime((char_u *)FILETYPE_FILE, true); + source_runtime(FILETYPE_FILE, true); filetype_detect = kTrue; } if (filetype_plugin == kNone) { - source_runtime((char_u *)FTPLUGIN_FILE, true); + source_runtime(FTPLUGIN_FILE, true); filetype_plugin = kTrue; } if (filetype_indent == kNone) { - source_runtime((char_u *)INDENT_FILE, true); + source_runtime(INDENT_FILE, true); filetype_indent = kTrue; } } diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 4aadd77d45..1e1da6a9a3 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -859,7 +859,7 @@ void ex_loadview(exarg_T *eap) { char *fname = get_view_file(*eap->arg); if (fname != NULL) { - if (do_source((char_u *)fname, false, DOSO_NONE) == FAIL) { + if (do_source(fname, false, DOSO_NONE) == FAIL) { EMSG2(_(e_notopen), fname); } xfree(fname); diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index d364895ea4..5458d8acf2 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1664,13 +1664,13 @@ int vim_chdirfile(char_u *fname) /// Change directory to "new_dir". Search 'cdpath' for relative directory names. int vim_chdir(char_u *new_dir) { - char_u *dir_name = find_directory_in_path(new_dir, STRLEN(new_dir), - FNAME_MESS, curbuf->b_ffname); + char *dir_name = (char *)find_directory_in_path(new_dir, STRLEN(new_dir), + FNAME_MESS, curbuf->b_ffname); if (dir_name == NULL) { return -1; } - int r = os_chdir((char *)dir_name); + int r = os_chdir(dir_name); xfree(dir_name); return r; } diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 06b8049176..5a2ce74666 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1838,8 +1838,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin curbuf = wp->w_buffer; emsg_silent++; // handle exceptions, but don't display errors - text = eval_to_string_safe(wp->w_p_fdt, NULL, - was_set_insecurely(wp, (char_u *)"foldtext", OPT_LOCAL)); + text = eval_to_string_safe(wp->w_p_fdt, NULL, was_set_insecurely(wp, "foldtext", OPT_LOCAL)); emsg_silent--; if (text == NULL || did_emsg) { diff --git a/src/nvim/garray.c b/src/nvim/garray.c index 69ad17ebcb..7a3cc4a944 100644 --- a/src/nvim/garray.c +++ b/src/nvim/garray.c @@ -143,14 +143,14 @@ void ga_remove_duplicate_strings(garray_T *gap) /// @param sep /// /// @returns the concatenated strings -char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep) +char *ga_concat_strings_sep(const garray_T *gap, const char *sep) FUNC_ATTR_NONNULL_RET { const size_t nelem = (size_t)gap->ga_len; const char **strings = gap->ga_data; if (nelem == 0) { - return (char_u *)xstrdup(""); + return xstrdup(""); } size_t len = 0; @@ -169,7 +169,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep) } strcpy(s, strings[nelem - 1]); - return (char_u *)ret; + return ret; } /// For a growing array that contains a list of strings: concatenate all the @@ -180,7 +180,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep) /// @returns the concatenated strings char_u *ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET { - return ga_concat_strings_sep(gap, ","); + return (char_u *)ga_concat_strings_sep(gap, ","); } /// Concatenate a string to a growarray which contains characters. @@ -198,7 +198,7 @@ void ga_concat(garray_T *gap, const char *restrict s) return; } - ga_concat_len(gap, s, strlen((char *)s)); + ga_concat_len(gap, s, STRLEN(s)); } /// Concatenate a string to a growarray which contains characters diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 280d2506c6..eb836b9005 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2660,12 +2660,11 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, const char_u *replaced = replace_termcodes(orig_lhs, orig_lhs_len, &lhs_buf, true, true, true, cpo_flags); mapargs->lhs_len = STRLEN(replaced); - xstrlcpy((char *)mapargs->lhs, (char *)replaced, sizeof(mapargs->lhs)); + STRLCPY(mapargs->lhs, replaced, sizeof(mapargs->lhs)); mapargs->orig_rhs_len = orig_rhs_len; mapargs->orig_rhs = xcalloc(mapargs->orig_rhs_len + 1, sizeof(char_u)); - xstrlcpy((char *)mapargs->orig_rhs, (char *)orig_rhs, - mapargs->orig_rhs_len + 1); + STRLCPY(mapargs->orig_rhs, orig_rhs, mapargs->orig_rhs_len + 1); if (STRICMP(orig_rhs, "<nop>") == 0) { // "<Nop>" means nothing mapargs->rhs = xcalloc(1, sizeof(char_u)); // single null-char @@ -2677,7 +2676,7 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, const mapargs->rhs_len = STRLEN(replaced); mapargs->rhs_is_noop = false; mapargs->rhs = xcalloc(mapargs->rhs_len + 1, sizeof(char_u)); - xstrlcpy((char *)mapargs->rhs, (char *)replaced, mapargs->rhs_len + 1); + STRLCPY(mapargs->rhs, replaced, mapargs->rhs_len + 1); } xfree(lhs_buf); @@ -2785,7 +2784,7 @@ int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs) // (e.g. "<Space>" is longer than ' '), so first copy into a buffer. size_t orig_lhs_len = (size_t)(lhs_end - to_parse); char_u *lhs_to_replace = xcalloc(orig_lhs_len + 1, sizeof(char_u)); - xstrlcpy((char *)lhs_to_replace, (char *)to_parse, orig_lhs_len + 1); + STRLCPY(lhs_to_replace, to_parse, orig_lhs_len + 1); size_t orig_rhs_len = STRLEN(rhs_start); set_maparg_lhs_rhs(lhs_to_replace, orig_lhs_len, diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 435949379b..8a36b3bedd 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -669,7 +669,7 @@ EXTERN bool swap_exists_did_quit INIT(= false); EXTERN char_u IObuff[IOSIZE]; ///< Buffer for sprintf, I/O, etc. EXTERN char_u NameBuff[MAXPATHL]; ///< Buffer for expanding file names -EXTERN char_u msg_buf[MSG_BUF_LEN]; ///< Small buffer for messages +EXTERN char msg_buf[MSG_BUF_LEN]; ///< Small buffer for messages EXTERN char os_buf[ ///< Buffer for the os/ layer #if MAXPATHL > IOSIZE MAXPATHL @@ -982,9 +982,8 @@ EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String")); EXTERN char_u e_autocmd_err[] INIT(=N_("E5500: autocmd has thrown an exception: %s")); EXTERN char_u e_cmdmap_err[] INIT(=N_("E5520: <Cmd> mapping must end with <CR>")); -EXTERN char_u e_cmdmap_repeated[] INIT(= - N_( - "E5521: <Cmd> mapping must end with <CR> before second <Cmd>")); +EXTERN char_u +e_cmdmap_repeated[] INIT(=N_("E5521: <Cmd> mapping must end with <CR> before second <Cmd>")); EXTERN char_u e_cmdmap_key[] INIT(=N_("E5522: <Cmd> mapping must not include %s key")); EXTERN char_u e_api_error[] INIT(=N_("E5555: API call: %s")); diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 9d9ffa550a..99e0bff81c 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -551,7 +551,7 @@ static void prt_header(prt_settings_T *const psettings, const int pagenum, const curwin->w_botline = lnum + 63; printer_page_num = pagenum; - use_sandbox = was_set_insecurely(curwin, (char_u *)"printheader", 0); + use_sandbox = was_set_insecurely(curwin, "printheader", 0); build_stl_str_hl(curwin, tbuf, (size_t)width + IOSIZE, p_header, use_sandbox, ' ', width, NULL, NULL); diff --git a/src/nvim/indent.c b/src/nvim/indent.c index a3ee3983e5..f49aff6643 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -533,7 +533,7 @@ int get_expr_indent(void) colnr_T save_curswant; int save_set_curswant; int save_State; - int use_sandbox = was_set_insecurely(curwin, (char_u *)"indentexpr", OPT_LOCAL); + int use_sandbox = was_set_insecurely(curwin, "indentexpr", OPT_LOCAL); // Save and restore cursor position and curswant, in case it was changed // * via :normal commands. diff --git a/src/nvim/main.c b/src/nvim/main.c index 069c253bff..9a82eccc6f 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1700,7 +1700,7 @@ static void do_system_initialization(void) memcpy(vimrc, dir, dir_len); vimrc[dir_len] = PATHSEP; memcpy(vimrc + dir_len + 1, path_tail, sizeof(path_tail)); - if (do_source((char_u *)vimrc, false, DOSO_NONE) != FAIL) { + if (do_source(vimrc, false, DOSO_NONE) != FAIL) { xfree(vimrc); xfree(config_dirs); return; @@ -1712,7 +1712,7 @@ static void do_system_initialization(void) #ifdef SYS_VIMRC_FILE // Get system wide defaults, if the file name is defined. - (void)do_source((char_u *)SYS_VIMRC_FILE, false, DOSO_NONE); + (void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE); #endif } @@ -1741,7 +1741,7 @@ static bool do_user_initialization(void) // init.lua if (os_path_exists(init_lua_path) - && do_source(init_lua_path, true, DOSO_VIMRC)) { + && do_source((char *)init_lua_path, true, DOSO_VIMRC)) { if (os_path_exists(user_vimrc)) { EMSG3(_("E5422: Conflicting configs: \"%s\" \"%s\""), init_lua_path, user_vimrc); @@ -1754,7 +1754,7 @@ static bool do_user_initialization(void) xfree(init_lua_path); // init.vim - if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) { + if (do_source((char *)user_vimrc, true, DOSO_VIMRC) != FAIL) { do_exrc = p_exrc; if (do_exrc) { do_exrc = (path_full_compare((char_u *)VIMRC_FILE, user_vimrc, @@ -1782,7 +1782,7 @@ static bool do_user_initialization(void) memmove(vimrc, dir, dir_len); vimrc[dir_len] = PATHSEP; memmove(vimrc + dir_len + 1, path_tail, sizeof(path_tail)); - if (do_source((char_u *)vimrc, true, DOSO_VIMRC) != FAIL) { + if (do_source(vimrc, true, DOSO_VIMRC) != FAIL) { do_exrc = p_exrc; if (do_exrc) { do_exrc = (path_full_compare((char_u *)VIMRC_FILE, (char_u *)vimrc, @@ -1814,7 +1814,7 @@ static void source_startup_scripts(const mparm_T *const parmp) || strequal(parmp->use_vimrc, "NORC")) { // Do nothing. } else { - if (do_source((char_u *)parmp->use_vimrc, false, DOSO_NONE) != OK) { + if (do_source(parmp->use_vimrc, false, DOSO_NONE) != OK) { EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc); } } @@ -1835,7 +1835,7 @@ static void source_startup_scripts(const mparm_T *const parmp) #endif secure = p_secure; - if (do_source((char_u *)VIMRC_FILE, true, DOSO_VIMRC) == FAIL) { + if (do_source(VIMRC_FILE, true, DOSO_VIMRC) == FAIL) { #if defined(UNIX) // if ".exrc" is not owned by user set 'secure' mode if (!file_owned(EXRC_FILE)) { @@ -1844,7 +1844,7 @@ static void source_startup_scripts(const mparm_T *const parmp) secure = 0; } #endif - (void)do_source((char_u *)EXRC_FILE, false, DOSO_NONE); + (void)do_source(EXRC_FILE, false, DOSO_NONE); } } if (secure == 2) { diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 2dfe5df325..40db5b7cf3 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -696,18 +696,18 @@ void msgmore(long n) } } else { if (n > 0) { - vim_snprintf((char *)msg_buf, MSG_BUF_LEN, + vim_snprintf(msg_buf, MSG_BUF_LEN, _("%" PRId64 " more lines"), (int64_t)pn); } else { - vim_snprintf((char *)msg_buf, MSG_BUF_LEN, + vim_snprintf(msg_buf, MSG_BUF_LEN, _("%" PRId64 " fewer lines"), (int64_t)pn); } } if (got_int) { - xstrlcat((char *)msg_buf, _(" (Interrupted)"), MSG_BUF_LEN); + xstrlcat(msg_buf, _(" (Interrupted)"), MSG_BUF_LEN); } - if (msg(msg_buf)) { - set_keep_msg(msg_buf, 0); + if (msg((char_u *)msg_buf)) { + set_keep_msg((char_u *)msg_buf, 0); keep_msg_more = true; } } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 0668924237..8bc2b3781a 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4253,7 +4253,7 @@ void op_formatexpr(oparg_T *oap) /// @param c character to be inserted int fex_format(linenr_T lnum, long count, int c) { - int use_sandbox = was_set_insecurely(curwin, (char_u *)"formatexpr", OPT_LOCAL); + int use_sandbox = was_set_insecurely(curwin, "formatexpr", OPT_LOCAL); int r; char_u *fex; @@ -4817,7 +4817,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd) if (change_cnt == 1) { MSG(_("1 line changed")); } else { - smsg((char *)_("%" PRId64 " lines changed"), (int64_t)change_cnt); + smsg(_("%" PRId64 " lines changed"), (int64_t)change_cnt); } } } @@ -6056,7 +6056,7 @@ bool prepare_yankreg_from_object(yankreg_T *reg, String regtype, size_t lines) void finish_yankreg_from_object(yankreg_T *reg, bool clipboard_adjust) { - if (reg->y_size > 0 && strlen((char *)reg->y_array[reg->y_size-1]) == 0) { + if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size-1]) == 0) { // a known-to-be charwise yank might have a final linebreak // but otherwise there is no line after the final newline if (reg->y_type != kMTCharWise) { @@ -6121,7 +6121,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) goto err; } char_u *regtype = TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string; - if (regtype == NULL || strlen((char *)regtype) > 1) { + if (regtype == NULL || STRLEN(regtype) > 1) { goto err; } switch (regtype[0]) { @@ -6164,7 +6164,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) reg->y_array[tv_idx++] = (char_u *)xstrdupnul((const char *)TV_LIST_ITEM_TV(li)->vval.v_string); }); - if (reg->y_size > 0 && strlen((char *)reg->y_array[reg->y_size-1]) == 0) { + if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size-1]) == 0) { // a known-to-be charwise yank might have a final linebreak // but otherwise there is no line after the final newline if (reg->y_type != kMTCharWise) { diff --git a/src/nvim/option.c b/src/nvim/option.c index b766ae92cf..659e16268b 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2072,9 +2072,9 @@ static void check_string_option(char_u **pp) /// Return true when option "opt" was set from a modeline or in secure mode. /// Return false when it wasn't. /// Return -1 for an unknown option. -int was_set_insecurely(win_T *const wp, char_u *opt, int opt_flags) +int was_set_insecurely(win_T *const wp, char *opt, int opt_flags) { - int idx = findoption((const char *)opt); + int idx = findoption(opt); if (idx >= 0) { uint32_t *flagp = insecure_flag(wp, idx, opt_flags); @@ -3288,7 +3288,7 @@ ambw_end: if (p > q) { vim_snprintf((char *)fname, sizeof(fname), "spell/%.*s.vim", (int)(p - q), q); - source_runtime(fname, DIP_ALL); + source_runtime((char *)fname, DIP_ALL); } } } diff --git a/src/nvim/path.c b/src/nvim/path.c index 60c7ea7fa4..5b1793b111 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1658,8 +1658,7 @@ static char *eval_includeexpr(const char *const ptr, const size_t len) { set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len); char *res = (char *)eval_to_string_safe(curbuf->b_p_inex, NULL, - was_set_insecurely(curwin, (char_u *)"includeexpr", - OPT_LOCAL)); + was_set_insecurely(curwin, "includeexpr", OPT_LOCAL)); set_vim_var_string(VV_FNAME, NULL, 0); return res; } @@ -2038,7 +2037,7 @@ char_u *path_shorten_fname(char_u *full_path, char_u *dir_name) } assert(dir_name != NULL); - size_t len = strlen((char *)dir_name); + size_t len = STRLEN(dir_name); // If dir_name is a path head, full_path can always be made relative. if (len == (size_t)path_head_length() && is_path_head(dir_name)) { diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 046e6dbd12..53be2c04e2 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1628,8 +1628,8 @@ static int qf_parse_multiline_pfx(int idx, qf_list_T *qfl, qffields_T *fields) return QF_FAIL; } if (*fields->errmsg) { - size_t textlen = strlen((char *)qfprev->qf_text); - size_t errlen = strlen((char *)fields->errmsg); + size_t textlen = STRLEN(qfprev->qf_text); + size_t errlen = STRLEN(fields->errmsg); qfprev->qf_text = xrealloc(qfprev->qf_text, textlen + errlen + 2); qfprev->qf_text[textlen] = '\n'; STRCPY(qfprev->qf_text + textlen + 1, fields->errmsg); diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index c47bffd426..67df0c9258 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -47,13 +47,13 @@ void ex_runtime(exarg_T *eap) arg = skipwhite(arg + len); } - source_runtime(arg, flags); + source_runtime((char *)arg, flags); } static void source_callback(char_u *fname, void *cookie) { - (void)do_source(fname, false, DOSO_NONE); + (void)do_source((char *)fname, false, DOSO_NONE); } /// Find the file "name" in all directories in "path" and invoke @@ -64,7 +64,7 @@ static void source_callback(char_u *fname, void *cookie) /// When "flags" has DIP_ERR: give an error message if there is no match. /// /// return FAIL when no file could be sourced, OK otherwise. -int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie) +int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback, void *cookie) { char_u *tail; int num_files; @@ -79,8 +79,7 @@ int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback { if (p_verbose > 10 && name != NULL) { verbose_enter(); - smsg(_("Searching for \"%s\" in \"%s\""), - (char *)name, (char *)path); + smsg(_("Searching for \"%s\" in \"%s\""), name, (char *)path); verbose_leave(); } @@ -109,7 +108,7 @@ int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback tail = buf + STRLEN(buf); // Loop over all patterns in "name" - char_u *np = name; + char_u *np = (char_u *)name; while (*np != NUL && ((flags & DIP_ALL) || !did_one)) { // Append the pattern from "name" to buf[]. assert(MAXPATHL >= (tail - buf)); @@ -281,16 +280,16 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c int done = FAIL; if ((flags & DIP_NORTP) == 0) { - done |= do_in_path(path, (name && !*name) ? NULL : name, flags, callback, cookie); + done |= do_in_path(path, (char *)((name && !*name) ? NULL : name), flags, callback, cookie); } if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) { char *start_dir = "pack/*/start/*/%s%s"; // NOLINT size_t len = STRLEN(start_dir) + STRLEN(name) + 6; - char_u *s = xmallocz(len); // TODO(bfredl): get rid of random allocations + char *s = xmallocz(len); // TODO(bfredl): get rid of random allocations char *suffix = (flags & DIP_AFTER) ? "after/" : ""; - vim_snprintf((char *)s, len, start_dir, suffix, name); + vim_snprintf(s, len, start_dir, suffix, name); done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie); xfree(s); @@ -300,7 +299,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c len = STRLEN(start_dir) + STRLEN(name) + 6; s = xmallocz(len); - vim_snprintf((char *)s, len, start_dir, suffix, name); + vim_snprintf(s, len, start_dir, suffix, name); done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie); xfree(s); @@ -310,9 +309,9 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT)) { char *opt_dir = "pack/*/opt/*/%s"; // NOLINT size_t len = STRLEN(opt_dir) + STRLEN(name); - char_u *s = xmallocz(len); + char *s = xmallocz(len); - vim_snprintf((char *)s, len, opt_dir, name); + vim_snprintf(s, len, opt_dir, name); done |= do_in_path(p_pp, s, flags, callback, cookie); xfree(s); @@ -322,7 +321,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c len = STRLEN(opt_dir) + STRLEN(name); s = xmallocz(len); - vim_snprintf((char *)s, len, opt_dir, name); + vim_snprintf(s, len, opt_dir, name); done |= do_in_path(p_pp, s, flags, callback, cookie); xfree(s); @@ -374,7 +373,7 @@ static void expand_pack_entry(RuntimeSearchPath *search_path, Map(String, handle if (STRLEN(pack_entry) + STRLEN(start_pat[i]) + 1 > MAXPATHL) { continue; } - xstrlcpy(buf, (char *)pack_entry, MAXPATHL); + STRLCPY(buf, pack_entry, MAXPATHL); xstrlcat(buf, start_pat[i], sizeof buf); expand_rtp_entry(search_path, rtp_used, buf, false); size_t after_size = STRLEN(buf)+7; @@ -515,9 +514,9 @@ int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, void /// When "flags" has DIP_ALL: source all files, otherwise only the first one. /// /// return FAIL when no file could be sourced, OK otherwise. -int source_runtime(char_u *name, int flags) +int source_runtime(char *name, int flags) { - return do_in_runtimepath(name, flags, source_callback, NULL); + return do_in_runtimepath((char_u *)name, flags, source_callback, NULL); } /// Just like source_runtime(), but use "path" instead of 'runtimepath'. @@ -535,7 +534,7 @@ static void source_all_matches(char_u *pat) if (gen_expand_wildcards(1, &pat, &num_files, &files, EW_FILE) == OK) { for (int i = 0; i < num_files; i++) { - (void)do_source(files[i], false, DOSO_NONE); + (void)do_source((char *)files[i], false, DOSO_NONE); } FreeWild(num_files, files); } @@ -791,7 +790,7 @@ static void add_pack_start_dir(char_u *fname, void *cookie) if (STRLEN(fname) + STRLEN(start_pat[i]) + 1 > MAXPATHL) { continue; } - xstrlcpy((char *)buf, (char *)fname, MAXPATHL); + STRLCPY(buf, fname, MAXPATHL); xstrlcat((char *)buf, start_pat[i], sizeof buf); if (pack_has_entries(buf)) { add_pack_dir_to_rtp(buf, true); @@ -804,9 +803,9 @@ static void add_pack_start_dir(char_u *fname, void *cookie) void load_start_packages(void) { did_source_packages = true; - do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT + do_in_path(p_pp, "pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_start_pack_plugin, &APP_LOAD); - do_in_path(p_pp, (char_u *)"start/*", DIP_ALL + DIP_DIR, // NOLINT + do_in_path(p_pp, "start/*", DIP_ALL + DIP_DIR, // NOLINT add_start_pack_plugin, &APP_LOAD); } @@ -849,8 +848,8 @@ void load_plugins(void) } TIME_MSG("loading packages"); - source_runtime(plugin_pattern_vim, DIP_ALL | DIP_AFTER); - source_runtime(plugin_pattern_lua, DIP_ALL | DIP_AFTER); + source_runtime((char *)plugin_pattern_vim, DIP_ALL | DIP_AFTER); + source_runtime((char *)plugin_pattern_lua, DIP_ALL | DIP_AFTER); TIME_MSG("loading after plugins"); } } @@ -873,9 +872,7 @@ void ex_packadd(exarg_T *eap) vim_snprintf(pat, len, plugpat, round == 1 ? "start" : "opt", eap->arg); // The first round don't give a "not found" error, in the second round // only when nothing was found in the first round. - res = do_in_path(p_pp, (char_u *)pat, - DIP_ALL + DIP_DIR - + (round == 2 && res == FAIL ? DIP_ERR : 0), + res = do_in_path(p_pp, pat, DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0), round == 1 ? add_start_pack_plugin : add_opt_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH); xfree(pat); diff --git a/src/nvim/screen.c b/src/nvim/screen.c index d8cd8c2008..0bd9dbe0d5 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5465,7 +5465,7 @@ static void win_redr_custom(win_T *wp, bool draw_ruler) fillchar = ' '; attr = HL_ATTR(HLF_TPF); maxwidth = Columns; - use_sandbox = was_set_insecurely(wp, (char_u *)"tabline", 0); + use_sandbox = was_set_insecurely(wp, "tabline", 0); } else { row = W_ENDROW(wp); fillchar = fillchar_status(&attr, wp); @@ -5500,15 +5500,14 @@ static void win_redr_custom(win_T *wp, bool draw_ruler) attr = HL_ATTR(HLF_MSG); } - use_sandbox = was_set_insecurely(wp, (char_u *)"rulerformat", 0); + use_sandbox = was_set_insecurely(wp, "rulerformat", 0); } else { if (*wp->w_p_stl != NUL) { stl = wp->w_p_stl; } else { stl = p_stl; } - use_sandbox = was_set_insecurely(wp, (char_u *)"statusline", - *wp->w_p_stl == NUL ? 0 : OPT_LOCAL); + use_sandbox = was_set_insecurely(wp, "statusline", *wp->w_p_stl == NUL ? 0 : OPT_LOCAL); } col += wp->w_wincol; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2b5faee8de..ac4c81f6b3 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4393,8 +4393,8 @@ static void syn_cmd_include(exarg_T *eap, int syncing) prev_toplvl_grp = curwin->w_s->b_syn_topgrp; curwin->w_s->b_syn_topgrp = sgl_id; if (source - ? do_source(eap->arg, false, DOSO_NONE) == FAIL - : source_runtime(eap->arg, DIP_ALL) == FAIL) { + ? do_source((char *)eap->arg, false, DOSO_NONE) == FAIL + : source_runtime((char *)eap->arg, DIP_ALL) == FAIL) { EMSG2(_(e_notopen), eap->arg); } curwin->w_s->b_syn_topgrp = prev_toplvl_grp; @@ -6616,10 +6616,10 @@ int load_colors(char_u *name) buf = xmalloc(buflen); apply_autocmds(EVENT_COLORSCHEMEPRE, name, curbuf->b_fname, false, curbuf); snprintf((char *)buf, buflen, "colors/%s.vim", name); - retval = source_runtime(buf, DIP_START + DIP_OPT); + retval = source_runtime((char *)buf, DIP_START + DIP_OPT); if (retval == FAIL) { snprintf((char *)buf, buflen, "colors/%s.lua", name); - retval = source_runtime(buf, DIP_START + DIP_OPT); + retval = source_runtime((char *)buf, DIP_START + DIP_OPT); } xfree(buf); apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, false, curbuf); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 768cca284b..ee92a2c642 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -906,7 +906,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char_u **matches) if (len > 128) { len = 128; } - xstrlcpy((char *)tag_name, (const char *)tagp.tagname, len + 1); + STRLCPY(tag_name, tagp.tagname, len + 1); tag_name[len] = NUL; // Save the tag file name @@ -914,7 +914,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char_u **matches) if (p == NULL) { continue; } - xstrlcpy((char *)fname, (const char *)p, MAXPATHL); + STRLCPY(fname, p, MAXPATHL); XFREE_CLEAR(p); // Get the line number or the search pattern used to locate diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 52e6ba64cc..18e59bb6b7 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -112,7 +112,7 @@ let s:filename_checks = { \ 'coco': ['file.atg'], \ 'conaryrecipe': ['file.recipe'], \ 'conf': ['auto.master'], - \ 'config': ['configure.in', 'configure.ac', 'Pipfile', '/etc/hostname.file'], + \ 'config': ['configure.in', 'configure.ac', '/etc/hostname.file'], \ 'context': ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'], \ 'cpp': ['file.cxx', 'file.c++', 'file.hh', 'file.hxx', 'file.hpp', 'file.ipp', 'file.moc', 'file.tcc', 'file.inl', 'file.tlh'], \ 'crm': ['file.crm'], @@ -503,8 +503,8 @@ let s:filename_checks = { \ 'tidy': ['.tidyrc', 'tidyrc', 'tidy.conf'], \ 'tilde': ['file.t.html'], \ 'tli': ['file.tli'], - \ 'tmux': ['tmuxfile.conf', '.tmuxfile.conf', '.tmux-file.conf', '.tmux.conf', 'tmux-file.conf', 'tmux.conf'], - \ 'toml': ['file.toml'], + \ 'tmux': ['tmuxfile.conf', '.tmuxfile.conf', '.tmux-file.conf', '.tmux.conf', 'tmux-file.conf', 'tmux.conf', 'tmux.conf.local'], + \ 'toml': ['file.toml', 'Gopkg.lock', 'Pipfile', '/home/user/.cargo/config'], \ 'tpp': ['file.tpp'], \ 'treetop': ['file.treetop'], \ 'trustees': ['trustees.conf'], diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua index 052a8a1ecd..81f1820986 100644 --- a/test/functional/lua/uri_spec.lua +++ b/test/functional/lua/uri_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local exec_lua = helpers.exec_lua local eq = helpers.eq +local write_file = require('test.helpers').write_file describe('URI methods', function() before_each(function() @@ -158,6 +159,22 @@ describe('URI methods', function() end) + describe('uri from bufnr', function() + it('Windows paths should not be treated as uris', function() + if not helpers.iswin() then return end + + local file = helpers.tmpname() + write_file(file, 'Test content') + local test_case = string.format([[ + local file = '%s' + return vim.uri_from_bufnr(vim.fn.bufadd(file)) + ]], file) + local expected_uri = 'file:///' .. file:gsub("\\", "/") + eq(expected_uri, exec_lua(test_case)) + os.remove(file) + end) + end) + describe('uri to bufnr', function() it('uri_to_bufnr & uri_from_bufnr returns original uri for non-file uris', function() local uri = 'jdt://contents/java.base/java.util/List.class?=sql/%5C/home%5C/user%5C/.jabba%5C/jdk%5C/openjdk%5C@1.14.0%5C/lib%5C/jrt-fs.jar%60java.base=/javadoc_location=/https:%5C/%5C/docs.oracle.com%5C/en%5C/java%5C/javase%5C/14%5C/docs%5C/api%5C/=/%3Cjava.util(List.class' diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 45fcf945f4..b84e9d1533 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -208,12 +208,12 @@ describe('health.vim', function() ^ | {Heading:foo: } | {Bar:========================================================================}| - {Bullet: -} {Error:ERROR:} No healthcheck found for "foo" plugin. | + {Bullet: -} {Error:ERROR}: No healthcheck found for "foo" plugin. | | {Heading:success1: health#success1#check} | {Bar:========================================================================}| {Heading2:##}{Heading: report 1} | - {Bullet: -} {Ok:OK:} everything is fine | + {Bullet: -} {Ok:OK}: everything is fine | | ]]} end) |