aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/ada.vim6
-rw-r--r--runtime/autoload/adacomplete.vim2
-rw-r--r--runtime/autoload/csscomplete.vim2
-rw-r--r--runtime/autoload/decada.vim2
-rw-r--r--runtime/autoload/dist/ft.vim6
-rw-r--r--runtime/autoload/haskellcomplete.vim6
-rw-r--r--runtime/autoload/htmlcomplete.vim2
-rw-r--r--runtime/autoload/man.vim1
-rw-r--r--runtime/autoload/netrw.vim274
-rw-r--r--runtime/autoload/netrwSettings.vim8
-rw-r--r--runtime/autoload/phpcomplete.vim40
-rw-r--r--runtime/autoload/python3complete.vim2
-rw-r--r--runtime/autoload/pythoncomplete.vim2
-rw-r--r--runtime/autoload/sqlcomplete.vim10
-rw-r--r--runtime/autoload/tar.vim2
-rw-r--r--runtime/autoload/tohtml.vim2
-rw-r--r--runtime/autoload/xmlcomplete.vim2
-rw-r--r--runtime/autoload/zip.vim2
-rw-r--r--runtime/compiler/fpc.vim2
-rw-r--r--runtime/compiler/scdoc.vim16
-rw-r--r--runtime/compiler/spectral.vim17
-rw-r--r--runtime/compiler/tex.vim2
-rw-r--r--runtime/compiler/yamllint.vim16
-rw-r--r--runtime/doc/api.txt100
-rw-r--r--runtime/doc/autocmd.txt6
-rw-r--r--runtime/doc/cmdline.txt7
-rw-r--r--runtime/doc/deprecated.txt44
-rw-r--r--runtime/doc/diagnostic.txt483
-rw-r--r--runtime/doc/eval.txt964
-rw-r--r--runtime/doc/fold.txt2
-rw-r--r--runtime/doc/if_perl.txt3
-rw-r--r--runtime/doc/index.txt6
-rw-r--r--runtime/doc/insert.txt13
-rw-r--r--runtime/doc/intro.txt7
-rw-r--r--runtime/doc/lsp.txt594
-rw-r--r--runtime/doc/lua.txt242
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt33
-rw-r--r--runtime/doc/options.txt12
-rw-r--r--runtime/doc/pi_netrw.txt82
-rw-r--r--runtime/doc/provider.txt1
-rw-r--r--runtime/doc/repeat.txt25
-rw-r--r--runtime/doc/sign.txt24
-rw-r--r--runtime/doc/syntax.txt32
-rw-r--r--runtime/doc/testing.txt2
-rw-r--r--runtime/doc/treesitter.txt2
-rw-r--r--runtime/doc/usr_05.txt6
-rw-r--r--runtime/doc/usr_41.txt9
-rw-r--r--runtime/doc/vim_diff.txt2
-rw-r--r--runtime/doc/windows.txt5
-rw-r--r--runtime/filetype.vim9
-rw-r--r--runtime/ftplugin/chicken.vim1
-rw-r--r--runtime/ftplugin/dosini.vim2
-rw-r--r--runtime/ftplugin/matlab.vim7
-rw-r--r--runtime/ftplugin/ocaml.vim8
-rw-r--r--runtime/ftplugin/octave.vim63
-rw-r--r--runtime/ftplugin/scala.vim6
-rw-r--r--runtime/ftplugin/scdoc.vim26
-rw-r--r--runtime/ftplugin/scheme.vim5
-rw-r--r--runtime/ftplugin/systemverilog.vim2
-rw-r--r--runtime/ftplugin/tex.vim2
-rw-r--r--runtime/indent/ada.vim2
-rw-r--r--runtime/indent/bzl.vim41
-rw-r--r--runtime/indent/cdl.vim12
-rw-r--r--runtime/indent/config.vim4
-rw-r--r--runtime/indent/dtd.vim6
-rw-r--r--runtime/indent/erlang.vim8
-rw-r--r--runtime/indent/json.vim2
-rw-r--r--runtime/indent/lifelines.vim2
-rw-r--r--runtime/indent/objc.vim2
-rw-r--r--runtime/indent/pascal.vim4
-rw-r--r--runtime/indent/pov.vim2
-rw-r--r--runtime/indent/ruby.vim2
-rw-r--r--runtime/indent/scala.vim9
-rw-r--r--runtime/indent/sqlanywhere.vim2
-rw-r--r--runtime/indent/systemverilog.vim4
-rw-r--r--runtime/indent/testdir/xml.in2
-rw-r--r--runtime/indent/testdir/xml.ok2
-rw-r--r--runtime/indent/tex.vim2
-rw-r--r--runtime/indent/treetop.vim2
-rw-r--r--runtime/indent/typescript.vim2
-rw-r--r--runtime/indent/verilog.vim4
-rw-r--r--runtime/indent/yaml.vim2
-rw-r--r--runtime/keymap/kana.vim4
-rw-r--r--runtime/keymap/korean.vim2
-rw-r--r--runtime/keymap/russian-jcukenwintype.vim2
-rw-r--r--runtime/keymap/russian-typograph.vim4
-rw-r--r--runtime/lua/vim/diagnostic.lua1150
-rw-r--r--runtime/lua/vim/lsp.lua13
-rw-r--r--runtime/lua/vim/lsp/_snippet.lua399
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua1495
-rw-r--r--runtime/lua/vim/lsp/handlers.lua14
-rw-r--r--runtime/lua/vim/lsp/log.lua18
-rw-r--r--runtime/lua/vim/lsp/rpc.lua4
-rw-r--r--runtime/lua/vim/lsp/util.lua126
-rw-r--r--runtime/lua/vim/shared.lua11
-rw-r--r--runtime/pack/dist/opt/matchit/doc/matchit.txt4
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim25
-rw-r--r--runtime/plugin/diagnostic.vim26
-rw-r--r--runtime/plugin/netrwPlugin.vim28
-rw-r--r--runtime/plugin/tohtml.vim2
-rw-r--r--runtime/syntax/2html.vim4
-rw-r--r--runtime/syntax/abel.vim2
-rw-r--r--runtime/syntax/ada.vim2
-rw-r--r--runtime/syntax/ahdl.vim2
-rw-r--r--runtime/syntax/aptconf.vim13
-rw-r--r--runtime/syntax/aspvbs.vim6
-rw-r--r--runtime/syntax/cfg.vim2
-rw-r--r--runtime/syntax/chicken.vim21
-rw-r--r--runtime/syntax/cpp.vim21
-rw-r--r--runtime/syntax/csc.vim2
-rw-r--r--runtime/syntax/cupl.vim2
-rw-r--r--runtime/syntax/debchangelog.vim6
-rw-r--r--runtime/syntax/debsources.vim6
-rw-r--r--runtime/syntax/dosbatch.vim2
-rw-r--r--runtime/syntax/doxygen.vim8
-rw-r--r--runtime/syntax/focexec.vim2
-rw-r--r--runtime/syntax/forth.vim2
-rw-r--r--runtime/syntax/gemtext.vim24
-rw-r--r--runtime/syntax/go.vim444
-rw-r--r--runtime/syntax/hamster.vim2
-rw-r--r--runtime/syntax/idl.vim2
-rw-r--r--runtime/syntax/iss.vim4
-rw-r--r--runtime/syntax/mma.vim4
-rw-r--r--runtime/syntax/objc.vim2
-rw-r--r--runtime/syntax/pascal.vim2
-rw-r--r--runtime/syntax/postscr.vim8
-rw-r--r--runtime/syntax/redif.vim2
-rw-r--r--runtime/syntax/scala.vim24
-rw-r--r--runtime/syntax/scdoc.vim52
-rw-r--r--runtime/syntax/scheme.vim13
-rw-r--r--runtime/syntax/sgml.vim6
-rw-r--r--runtime/syntax/spup.vim4
-rw-r--r--runtime/syntax/st.vim4
-rw-r--r--runtime/syntax/structurizr.vim76
-rw-r--r--runtime/syntax/tmux.vim2
-rw-r--r--runtime/syntax/vim.vim2
136 files changed, 4737 insertions, 2749 deletions
diff --git a/runtime/autoload/ada.vim b/runtime/autoload/ada.vim
index d04feb9250..3f1b40398f 100644
--- a/runtime/autoload/ada.vim
+++ b/runtime/autoload/ada.vim
@@ -67,13 +67,13 @@ if exists ('g:ada_with_gnat_project_files')
endfor
endif
-" Section: add standart exception {{{2
+" Section: add standard exception {{{2
"
for Item in ['Constraint_Error', 'Program_Error', 'Storage_Error', 'Tasking_Error', 'Status_Error', 'Mode_Error', 'Name_Error', 'Use_Error', 'Device_Error', 'End_Error', 'Data_Error', 'Layout_Error', 'Length_Error', 'Pattern_Error', 'Index_Error', 'Translation_Error', 'Time_Error', 'Argument_Error', 'Tag_Error', 'Picture_Error', 'Terminator_Error', 'Conversion_Error', 'Pointer_Error', 'Dereference_Error', 'Update_Error']
let g:ada#Keywords += [{
\ 'word': Item,
\ 'menu': 'exception',
- \ 'info': 'Ada standart exception.',
+ \ 'info': 'Ada standard exception.',
\ 'kind': 'x',
\ 'icase': 1}]
endfor
@@ -210,7 +210,7 @@ function ada#Word (...)
let l:Line = substitute (getline (l:Line_Nr), g:ada#Comment, '', '' )
" Cope with tag searching for items in comments; if we are, don't loop
- " backards looking for previous lines
+ " backwards looking for previous lines
if l:Column_Nr > strlen(l:Line)
" We were in a comment
let l:Line = getline(l:Line_Nr)
diff --git a/runtime/autoload/adacomplete.vim b/runtime/autoload/adacomplete.vim
index 2659f51d5c..d7bba93d12 100644
--- a/runtime/autoload/adacomplete.vim
+++ b/runtime/autoload/adacomplete.vim
@@ -14,7 +14,7 @@
" 15.10.2006 MK Bram's suggestion for runtime integration
" 05.11.2006 MK Bram suggested not to use include protection for
" autoload
-" 05.11.2006 MK Bram suggested agaist using setlocal omnifunc
+" 05.11.2006 MK Bram suggested against using setlocal omnifunc
" 05.11.2006 MK Bram suggested to save on spaces
" Help Page: ft-ada-omni
"------------------------------------------------------------------------------
diff --git a/runtime/autoload/csscomplete.vim b/runtime/autoload/csscomplete.vim
index f6c5a6c391..85e40c862f 100644
--- a/runtime/autoload/csscomplete.vim
+++ b/runtime/autoload/csscomplete.vim
@@ -311,7 +311,7 @@ function! csscomplete#CompleteCSS(findstart, base)
let values = ["normal", "italic", "oblique", "small-caps", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900", "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller", "sans-serif", "serif", "monospace", "cursive", "fantasy", "caption", "icon", "menu", "message-box", "small-caption", "status-bar"]
elseif prop =~ '^\%(height\|width\)$'
let values = ["auto", "border-box", "content-box", "max-content", "min-content", "available", "fit-content"]
- elseif prop =~ '^\%(left\|rigth\)$'
+ elseif prop =~ '^\%(left\|right\)$'
let values = ["auto"]
elseif prop == 'image-rendering'
let values = ["auto", "crisp-edges", "pixelated"]
diff --git a/runtime/autoload/decada.vim b/runtime/autoload/decada.vim
index 5124429a75..fda2b76dac 100644
--- a/runtime/autoload/decada.vim
+++ b/runtime/autoload/decada.vim
@@ -23,7 +23,7 @@ endif
function decada#Unit_Name () dict " {{{1
" Convert filename into acs unit:
- " 1: remove the file extenstion.
+ " 1: remove the file extension.
" 2: replace all double '_' or '-' with an dot (which denotes a separate)
" 3: remove a trailing '_' (which denotes a specification)
return substitute (substitute (expand ("%:t:r"), '__\|-', ".", "g"), '_$', "", '')
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 48a9657cf5..7484149a26 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -269,7 +269,8 @@ func dist#ft#FTm()
return
endif
- let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\)\>'
+ " excluding end(for|function|if|switch|while) common to Murphi
+ let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
let n = 1
let saw_comment = 0 " Whether we've seen a multiline comment leader.
@@ -285,8 +286,7 @@ func dist#ft#FTm()
setf objc
return
endif
- if line =~ '^\s*\%(#\|%!\|[#%]{\=\s*$\)' ||
- \ line =~ '^\s*unwind_protect\>' ||
+ if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' ||
\ line =~ '\%(^\|;\)\s*' .. octave_block_terminators
setf octave
return
diff --git a/runtime/autoload/haskellcomplete.vim b/runtime/autoload/haskellcomplete.vim
index 48fbac7f9f..759ff8741a 100644
--- a/runtime/autoload/haskellcomplete.vim
+++ b/runtime/autoload/haskellcomplete.vim
@@ -54,7 +54,7 @@ function! haskellcomplete#Complete(findstart, base)
if b:completingLangExtension
if a:base ==? ""
- " Return all posible Lang extensions
+ " Return all possible Lang extensions
return s:langExtensions
else
let l:matches = []
@@ -70,7 +70,7 @@ function! haskellcomplete#Complete(findstart, base)
elseif b:completingOptionsGHC
if a:base ==? ""
- " Return all posible GHC options
+ " Return all possible GHC options
return s:optionsGHC
else
let l:matches = []
@@ -86,7 +86,7 @@ function! haskellcomplete#Complete(findstart, base)
elseif b:completingModule
if a:base ==? ""
- " Return all posible modules
+ " Return all possible modules
return s:commonModules
else
let l:matches = []
diff --git a/runtime/autoload/htmlcomplete.vim b/runtime/autoload/htmlcomplete.vim
index 6b9d49a469..267889d97f 100644
--- a/runtime/autoload/htmlcomplete.vim
+++ b/runtime/autoload/htmlcomplete.vim
@@ -486,7 +486,7 @@ function! htmlcomplete#CompleteTags(findstart, base)
endif
endif
" Value of attribute completion {{{
- " If attr contains =\s*[\"'] we catched value of attribute
+ " If attr contains =\s*[\"'] we match value of attribute
if attr =~ "=\s*[\"']" || attr =~ "=\s*$"
" Let do attribute specific completion
let attrname = matchstr(attr, '.*\ze\s*=')
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim
index 8bf95651b7..4f132b6121 100644
--- a/runtime/autoload/man.vim
+++ b/runtime/autoload/man.vim
@@ -58,6 +58,7 @@ function! man#open_page(count, mods, ...) abort
else
execute 'silent keepalt' a:mods 'stag' l:target
endif
+ call s:set_options(v:false)
finally
call setbufvar(l:buf, '&tagfunc', l:save_tfu)
endtry
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index 74ceab35d4..b6edc4c4d8 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -1,7 +1,7 @@
" netrw.vim: Handles file transfer and remote directory listing across
" AUTOLOAD SECTION
-" Date: Sep 18, 2020
-" Version: 170
+" Date: Aug 16, 2021
+" Version: 171
" Maintainer: Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
@@ -43,7 +43,7 @@ if exists("s:needspatches")
endfor
endif
-let g:loaded_netrw = "v170"
+let g:loaded_netrw = "v171"
if !exists("s:NOTE")
let s:NOTE = 0
let s:WARNING = 1
@@ -93,7 +93,7 @@ fun! netrw#ErrorMsg(level,msg,errnum)
else
let msg= level.a:msg
endif
- let s:popuperr_id = popup_beval(msg,{})
+ let s:popuperr_id = popup_atcursor(msg,{})
let s:popuperr_text= ""
elseif g:netrw_use_errorwindow
" (default) netrw creates a one-line window to show error/warning
@@ -322,6 +322,7 @@ call s:NetrwInit("g:netrw_banner" , 1)
call s:NetrwInit("g:netrw_browse_split", 0)
call s:NetrwInit("g:netrw_bufsettings" , "noma nomod nonu nobl nowrap ro nornu")
call s:NetrwInit("g:netrw_chgwin" , -1)
+call s:NetrwInit("g:netrw_clipboard" , 1)
call s:NetrwInit("g:netrw_compress" , "gzip")
call s:NetrwInit("g:netrw_ctags" , "ctags")
if exists("g:netrw_cursorline") && !exists("g:netrw_cursor")
@@ -331,6 +332,7 @@ endif
call s:NetrwInit("g:netrw_cursor" , 2)
let s:netrw_usercul = &cursorline
let s:netrw_usercuc = &cursorcolumn
+"call Decho("(netrw) COMBAK: cuc=".&l:cuc." cul=".&l:cul." initialization of s:netrw_cu[cl]")
call s:NetrwInit("g:netrw_cygdrive","/cygdrive")
" Default values - d-g ---------- {{{3
call s:NetrwInit("s:didstarstar",0)
@@ -1606,7 +1608,8 @@ endfun
fun! s:NetrwOptionsSave(vt)
" call Dfunc("s:NetrwOptionsSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$")." mod=".&mod." ma=".&ma)
" call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist"),'~'.expand("<slnum>"))
-" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
+" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt." hid=".&hid,'~'.expand("<slnum>"))
+" call Decho("(s:NetrwOptionsSave) lines=".&lines)
if !exists("{a:vt}netrw_optionsave")
let {a:vt}netrw_optionsave= 1
@@ -1632,6 +1635,9 @@ fun! s:NetrwOptionsSave(vt)
let {a:vt}netrw_cinokeep = &l:cino
let {a:vt}netrw_comkeep = &l:com
let {a:vt}netrw_cpokeep = &l:cpo
+ let {a:vt}netrw_cuckeep = &l:cuc
+ let {a:vt}netrw_culkeep = &l:cul
+" call Decho("(s:NetrwOptionsSave) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
let {a:vt}netrw_diffkeep = &l:diff
let {a:vt}netrw_fenkeep = &l:fen
if !exists("g:netrw_ffkeep") || g:netrw_ffkeep
@@ -1639,9 +1645,11 @@ fun! s:NetrwOptionsSave(vt)
endif
let {a:vt}netrw_fokeep = &l:fo " formatoptions
let {a:vt}netrw_gdkeep = &l:gd " gdefault
+ let {a:vt}netrw_gokeep = &l:go " guioptions
let {a:vt}netrw_hidkeep = &l:hidden
let {a:vt}netrw_imkeep = &l:im
let {a:vt}netrw_iskkeep = &l:isk
+ let {a:vt}netrw_lines = &lines
let {a:vt}netrw_lskeep = &l:ls
let {a:vt}netrw_makeep = &l:ma
let {a:vt}netrw_magickeep = &l:magic
@@ -1693,12 +1701,17 @@ fun! s:NetrwOptionsSafe(islocal)
endif
call s:NetrwSetSafeSetting("&l:ci",0)
call s:NetrwSetSafeSetting("&l:cin",0)
- call s:NetrwSetSafeSetting("&l:bh","hide")
+ if g:netrw_fastbrowse > a:islocal
+ call s:NetrwSetSafeSetting("&l:bh","hide")
+ else
+ call s:NetrwSetSafeSetting("&l:bh","delete")
+ endif
call s:NetrwSetSafeSetting("&l:cino","")
call s:NetrwSetSafeSetting("&l:com","")
if &cpo =~ 'a' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'a','','g')) | endif
if &cpo =~ 'A' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'A','','g')) | endif
setl fo=nroql2
+ call s:NetrwSetSafeSetting("&go","begmr")
call s:NetrwSetSafeSetting("&l:hid",0)
call s:NetrwSetSafeSetting("&l:im",0)
setl isk+=@ isk+=* isk+=/
@@ -1712,7 +1725,10 @@ fun! s:NetrwOptionsSafe(islocal)
call s:NetrwSetSafeSetting("&l:tw",0)
call s:NetrwSetSafeSetting("&l:wig","")
setl cedit&
- call s:NetrwCursor()
+
+ " set up cuc and cul based on g:netrw_cursor and listing style
+ " COMBAK -- cuc cul related
+ call s:NetrwCursor(0)
" allow the user to override safe options
" call Decho("ft<".&ft."> ei=".&ei,'~'.expand("<slnum>"))
@@ -1730,11 +1746,14 @@ endfun
" s:NetrwOptionsRestore: restore options (based on prior s:NetrwOptionsSave) {{{2
fun! s:NetrwOptionsRestore(vt)
" call Dfunc("s:NetrwOptionsRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$"))
+" call Decho("(s:NetrwOptionsRestore) lines=".&lines)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
if !exists("{a:vt}netrw_optionsave")
" call Decho("case ".a:vt."netrw_optionsave : doesn't exist",'~'.expand("<slnum>"))
-" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
-" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
+" call Decho("..doing filetype detect anyway")
+ filetype detect
+" call Decho("..settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
+" call Decho("..ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
" call Dret("s:NetrwOptionsRestore : ".a:vt."netrw_optionsave doesn't exist")
return
endif
@@ -1751,41 +1770,53 @@ fun! s:NetrwOptionsRestore(vt)
endif
endif
endif
+" call Decho("(s:NetrwOptionsRestore) #1 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_aikeep","&l:ai")
call s:NetrwRestoreSetting(a:vt."netrw_awkeep","&l:aw")
call s:NetrwRestoreSetting(a:vt."netrw_blkeep","&l:bl")
call s:NetrwRestoreSetting(a:vt."netrw_btkeep","&l:bt")
call s:NetrwRestoreSetting(a:vt."netrw_bombkeep","&l:bomb")
+" call Decho("(s:NetrwOptionsRestore) #2 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_cedit","&cedit")
call s:NetrwRestoreSetting(a:vt."netrw_cikeep","&l:ci")
call s:NetrwRestoreSetting(a:vt."netrw_cinkeep","&l:cin")
call s:NetrwRestoreSetting(a:vt."netrw_cinokeep","&l:cino")
call s:NetrwRestoreSetting(a:vt."netrw_comkeep","&l:com")
+" call Decho("(s:NetrwOptionsRestore) #3 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_cpokeep","&l:cpo")
call s:NetrwRestoreSetting(a:vt."netrw_diffkeep","&l:diff")
call s:NetrwRestoreSetting(a:vt."netrw_fenkeep","&l:fen")
if exists("g:netrw_ffkeep") && g:netrw_ffkeep
call s:NetrwRestoreSetting(a:vt."netrw_ffkeep")","&l:ff")
endif
- call s:NetrwRestoreSetting(a:vt."netrw_fokeep","&l:fo")
- call s:NetrwRestoreSetting(a:vt."netrw_gdkeep","&l:gd")
- call s:NetrwRestoreSetting(a:vt."netrw_hidkeep","&l:hidden")
- call s:NetrwRestoreSetting(a:vt."netrw_imkeep","&l:im")
- call s:NetrwRestoreSetting(a:vt."netrw_iskkeep","&l:isk")
- call s:NetrwRestoreSetting(a:vt."netrw_lskeep","&l:ls")
- call s:NetrwRestoreSetting(a:vt."netrw_makeep","&l:ma")
+" call Decho("(s:NetrwOptionsRestore) #4 lines=".&lines)
+ call s:NetrwRestoreSetting(a:vt."netrw_fokeep" ,"&l:fo")
+ call s:NetrwRestoreSetting(a:vt."netrw_gdkeep" ,"&l:gd")
+ call s:NetrwRestoreSetting(a:vt."netrw_gokeep" ,"&l:go")
+ call s:NetrwRestoreSetting(a:vt."netrw_hidkeep" ,"&l:hidden")
+" call Decho("(s:NetrwOptionsRestore) #5 lines=".&lines)
+ call s:NetrwRestoreSetting(a:vt."netrw_imkeep" ,"&l:im")
+ call s:NetrwRestoreSetting(a:vt."netrw_iskkeep" ,"&l:isk")
+" call Decho("(s:NetrwOptionsRestore) #6 lines=".&lines)
+ call s:NetrwRestoreSetting(a:vt."netrw_lines" ,"&lines")
+" call Decho("(s:NetrwOptionsRestore) #7 lines=".&lines)
+ call s:NetrwRestoreSetting(a:vt."netrw_lskeep" ,"&l:ls")
+ call s:NetrwRestoreSetting(a:vt."netrw_makeep" ,"&l:ma")
call s:NetrwRestoreSetting(a:vt."netrw_magickeep","&l:magic")
- call s:NetrwRestoreSetting(a:vt."netrw_modkeep","&l:mod")
- call s:NetrwRestoreSetting(a:vt."netrw_nukeep","&l:nu")
- call s:NetrwRestoreSetting(a:vt."netrw_rnukeep","&l:rnu")
- call s:NetrwRestoreSetting(a:vt."netrw_repkeep","&l:report")
- call s:NetrwRestoreSetting(a:vt."netrw_rokeep","&l:ro")
- call s:NetrwRestoreSetting(a:vt."netrw_selkeep","&l:sel")
+ call s:NetrwRestoreSetting(a:vt."netrw_modkeep" ,"&l:mod")
+ call s:NetrwRestoreSetting(a:vt."netrw_nukeep" ,"&l:nu")
+" call Decho("(s:NetrwOptionsRestore) #8 lines=".&lines)
+ call s:NetrwRestoreSetting(a:vt."netrw_rnukeep" ,"&l:rnu")
+ call s:NetrwRestoreSetting(a:vt."netrw_repkeep" ,"&l:report")
+ call s:NetrwRestoreSetting(a:vt."netrw_rokeep" ,"&l:ro")
+ call s:NetrwRestoreSetting(a:vt."netrw_selkeep" ,"&l:sel")
+" call Decho("(s:NetrwOptionsRestore) #9 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_spellkeep","&l:spell")
- call s:NetrwRestoreSetting(a:vt."netrw_twkeep","&l:tw")
- call s:NetrwRestoreSetting(a:vt."netrw_wigkeep","&l:wig")
- call s:NetrwRestoreSetting(a:vt."netrw_wrapkeep","&l:wrap")
+ call s:NetrwRestoreSetting(a:vt."netrw_twkeep" ,"&l:tw")
+ call s:NetrwRestoreSetting(a:vt."netrw_wigkeep" ,"&l:wig")
+ call s:NetrwRestoreSetting(a:vt."netrw_wrapkeep" ,"&l:wrap")
call s:NetrwRestoreSetting(a:vt."netrw_writekeep","&l:write")
+" call Decho("(s:NetrwOptionsRestore) #10 lines=".&lines)
call s:NetrwRestoreSetting("s:yykeep","@@")
" former problem: start with liststyle=0; press <i> : result, following line resets l:ts.
" Fixed; in s:PerformListing, when w:netrw_liststyle is s:LONGLIST, will use a printf to pad filename with spaces
@@ -1827,9 +1858,11 @@ fun! s:NetrwOptionsRestore(vt)
" were having their filetype detect-generated settings overwritten by
" NetrwOptionRestore.
if &ft != "netrw"
-" call Decho("filetype detect (ft=".&ft.")",'~'.expand("<slnum>"))
+" call Decho("before: filetype detect (ft=".&ft.")",'~'.expand("<slnum>"))
filetype detect
+" call Decho("after : filetype detect (ft=".&ft.")",'~'.expand("<slnum>"))
endif
+" call Decho("(s:NetrwOptionsRestore) lines=".&lines)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
" call Dret("s:NetrwOptionsRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)
endfun
@@ -1879,7 +1912,7 @@ fun! s:NetrwRestoreSetting(keepvar,setting)
" typically called from s:NetrwOptionsRestore
" call s:NetrwRestoreSettings(keep-option-variable-name,'associated-option')
" ex. call s:NetrwRestoreSetting(a:vt."netrw_selkeep","&l:sel")
- " Restores option (if different) from a keepvar
+ " Restores option (but only if different) from a:keepvar
if exists(a:keepvar)
exe "let keepvarval= ".a:keepvar
exe "let setting= ".a:setting
@@ -2801,14 +2834,16 @@ fun! netrw#SetTreetop(iscmd,...)
" call Decho("inittreetop<".(exists("inittreetop")? inittreetop : "n/a").">")
if (a:iscmd == 0 || a:1 == "") && exists("inittreetop")
- let treedir= s:NetrwTreePath(inittreetop)
+ let treedir = s:NetrwTreePath(inittreetop)
" call Decho("treedir<".treedir.">",'~'.expand("<slnum>"))
else
if isdirectory(s:NetrwFile(a:1))
" call Decho("a:1<".a:1."> is a directory",'~'.expand("<slnum>"))
- let treedir= a:1
+ let treedir = a:1
+ let s:netrw_treetop = treedir
elseif exists("b:netrw_curdir") && (isdirectory(s:NetrwFile(b:netrw_curdir."/".a:1)) || a:1 =~ '^\a\{3,}://')
- let treedir= b:netrw_curdir."/".a:1
+ let treedir = b:netrw_curdir."/".a:1
+ let s:netrw_treetop = treedir
" call Decho("a:1<".a:1."> is NOT a directory, using treedir<".treedir.">",'~'.expand("<slnum>"))
else
" normally the cursor is left in the message window.
@@ -2816,7 +2851,8 @@ fun! netrw#SetTreetop(iscmd,...)
let netrwbuf= bufnr("%")
call netrw#ErrorMsg(s:ERROR,"sorry, ".a:1." doesn't seem to be a directory!",95)
exe bufwinnr(netrwbuf)."wincmd w"
- let treedir= "."
+ let treedir = "."
+ let s:netrw_treetop = getcwd()
endif
endif
" call Decho("treedir<".treedir.">",'~'.expand("<slnum>"))
@@ -4071,6 +4107,7 @@ fun! s:NetrwFileInfo(islocal,fname)
elseif g:netrw_sizestyle =~# 'h'
let lsopt= "-lsadh --si"
endif
+" call Decho("(s:NetrwFileInfo) lsopt<".lsopt.">")
if (has("unix") || has("macunix")) && executable("/bin/ls")
if getline(".") == "../"
@@ -4132,9 +4169,10 @@ endfun
" s:NetrwGetBuffer: [get a new|find an old netrw] buffer for a netrw listing {{{2
" returns 0=cleared buffer
" 1=re-used buffer (buffer not cleared)
+" Nov 09, 2020: tst952 shows that when user does :set hidden that NetrwGetBuffer will come up with a [No Name] buffer (hid fix)
fun! s:NetrwGetBuffer(islocal,dirname)
" call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle)
-" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>"))
+" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." hid=".&hid,'~'.expand("<slnum>"))
" call Decho("netrwbuf dictionary=".(exists("s:netrwbuf")? string(s:netrwbuf) : 'n/a'),'~'.expand("<slnum>"))
" call Dredir("ls!","s:NetrwGetBuffer")
let dirname= a:dirname
@@ -4184,17 +4222,26 @@ fun! s:NetrwGetBuffer(islocal,dirname)
endif
" call Decho(" bufnum#".bufnum,'~'.expand("<slnum>"))
- " highjack the current buffer if
- " it has the desired name
- " it is empty
-" call Decho("deciding if I can highjack the current buffer#".bufnr("%"),'~'.expand("<slnum>"))
-" call Decho("..dirname<".dirname.">",'~'.expand("<slnum>"))
-" call Decho("..bufname<".bufname("%").">",'~'.expand("<slnum>"))
-" call Decho("..getline($)<".getline("$").">",'~'.expand("<slnum>"))
- if dirname == bufname("%") && line("$") == 1 && getline("%") == ""
+ " hijack the current buffer
+ " IF the buffer already has the desired name
+ " AND it is empty
+ let curbuf = bufname("%")
+ if curbuf == '.'
+ let curbuf = getcwd()
+ endif
+" call Dredir("ls!","NetrwGetFile (renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">)")
+" call Decho("deciding if netrw may hijack the current buffer#".bufnr("%")."<".curbuf.">",'~'.expand("<slnum>"))
+" call Decho("..dirname<".dirname."> IF dirname == bufname",'~'.expand("<slnum>"))
+" call Decho("..curbuf<".curbuf.">",'~'.expand("<slnum>"))
+" call Decho("..line($)=".line("$")." AND this is 1",'~'.expand("<slnum>"))
+" call Decho("..getline(%)<".getline("%")."> AND this line is empty",'~'.expand("<slnum>"))
+ if dirname == curbuf && line("$") == 1 && getline("%") == ""
" call Dret("s:NetrwGetBuffer 0<cleared buffer> : highjacking buffer#".bufnr("%"))
return 0
+ else " DEBUG
+" call Decho("..did NOT hijack buffer",'~'.expand("<slnum>"))
endif
+ " Aug 14, 2021: was thinking about looking for a [No Name] buffer here and using it, but that might cause problems
" get enew buffer and name it -or- re-use buffer {{{3
if bufnum < 0 " get enew buffer and name it
@@ -4519,7 +4566,7 @@ fun! s:NetrwListStyle(islocal)
" refresh the listing
" call Decho("refresh the listing",'~'.expand("<slnum>"))
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
- NetrwKeepj call s:NetrwCursor()
+ NetrwKeepj call s:NetrwCursor(0)
" repoint t:netrw_lexbufnr if appropriate
if exists("repointlexbufnr")
@@ -4725,7 +4772,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
endif
" call Decho("b:netrw_curdir<".b:netrw_curdir.">")
- " NetrwBrowseChgDir: save options and initialize {{{3
+ " NetrwBrowseChgDir; save options and initialize {{{3
" call Decho("saving options",'~'.expand("<slnum>"))
call s:SavePosn(s:netrw_posn)
NetrwKeepj call s:NetrwOptionsSave("s:")
@@ -4793,6 +4840,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)'
" call Decho("edit-a-file: handle tree listing: w:netrw_treedict<".(exists("w:netrw_treedict")? string(w:netrw_treedict) : 'n/a').">",'~'.expand("<slnum>"))
" call Decho("edit-a-file: newdir<".newdir.">",'~'.expand("<slnum>"))
+" let newdir = s:NetrwTreePath(s:netrw_treetop)
+" call Decho("edit-a-file: COMBAK why doesn't this recognize file1's directory???")
let dirname= s:NetrwTreeDir(a:islocal)
"COMBAK : not working for a symlink -- but what about a regular file? a directory?
" call Decho("COMBAK : not working for a symlink -- but what about a regular file? a directory?")
@@ -4906,7 +4955,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
exe "NetrwKeepj e ".fnameescape(dirname)
endif
" call Decho("edit-a-file: after e! ".dirname.": hidden=".&hidden." bufhidden<".&bufhidden."> mod=".&mod,'~'.expand("<slnum>"))
- call s:NetrwCursor()
+ " COMBAK -- cuc cul related
+ call s:NetrwCursor(1)
if &hidden || &bufhidden == "hide"
" file came from vim's hidden storage. Don't "restore" options with it.
let dorestore= 0
@@ -4927,8 +4977,8 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
elseif type(g:Netrw_funcref) == 3
" call Decho("edit-a-file: handling a list of g:Netrw_funcrefs",'~'.expand("<slnum>"))
for Fncref in g:Netrw_funcref
- if type(FncRef) == 2
- NetrwKeepj call FncRef()
+ if type(Fncref) == 2
+ NetrwKeepj call Fncref()
endif
endfor
endif
@@ -5220,6 +5270,12 @@ fun! netrw#BrowseX(fname,remote)
endif
" call Decho("not a local file nor a webpage request",'~'.expand("<slnum>"))
+ if exists("g:netrw_browsex_viewer") && exists("g:netrw_browsex_support_remote") && !g:netrw_browsex_support_remote
+ let remote = a:remote
+ else
+ let remote = 0
+ endif
+
let ykeep = @@
let screenposn = winsaveview()
" call Decho("saving posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>"))
@@ -5264,9 +5320,9 @@ fun! netrw#BrowseX(fname,remote)
endif
" call Decho("exten<".exten.">",'~'.expand("<slnum>"))
- if a:remote == 1
+ if remote == 1
" create a local copy
-" call Decho("remote: a:remote=".a:remote.": create a local copy of <".a:fname.">",'~'.expand("<slnum>"))
+" call Decho("remote: remote=".remote.": create a local copy of <".a:fname.">",'~'.expand("<slnum>"))
setl bh=delete
call netrw#NetRead(3,a:fname)
" attempt to rename tempfile
@@ -5288,7 +5344,7 @@ fun! netrw#BrowseX(fname,remote)
let fname= s:netrw_tmpfile
endif
else
-" call Decho("local: a:remote=".a:remote.": handling local copy of <".a:fname.">",'~'.expand("<slnum>"))
+" call Decho("local: remote=".remote.": handling local copy of <".a:fname.">",'~'.expand("<slnum>"))
let fname= a:fname
" special ~ handler for local
if fname =~ '^\~' && expand("$HOME") != ""
@@ -5382,8 +5438,8 @@ fun! netrw#BrowseX(fname,remote)
if a:fname =~ '^https\=://'
" atril does not appear to understand how to handle html -- so use gvim to edit the document
let use_ctrlo= 0
-" call Decho("(COMBAK) fname<".fname.">")
-" call Decho("(COMBAK) a:fname<".a:fname.">")
+" call Decho("fname<".fname.">")
+" call Decho("a:fname<".a:fname.">")
call s:NetrwExe("sil! !gvim ".fname.' -c "keepj keepalt file '.fnameescape(a:fname).'"')
else
@@ -5431,12 +5487,12 @@ fun! netrw#BrowseX(fname,remote)
" return to prior buffer (directory listing)
" Feb 12, 2008: had to de-activiate removal of
" temporary file because it wasn't getting seen.
-" if a:remote == 1 && fname != a:fname
+" if remote == 1 && fname != a:fname
"" call Decho("deleting temporary file<".fname.">",'~'.expand("<slnum>"))
" call s:NetrwDelete(fname)
" endif
- if a:remote == 1
+ if remote == 1
setl bh=delete bt=nofile
if g:netrw_use_noswf
setl noswf
@@ -5495,7 +5551,7 @@ fun! s:NetrwBufRename(newname)
let b:junk= 1
" call Decho("rename buffer: sil! keepj keepalt file ".fnameescape(a:newname),'~'.expand("<slnum>"))
exe 'sil! keepj keepalt file '.fnameescape(a:newname)
-" call Dredir("ls!","s:NetrwBufRename (before bwipe)")
+" call Dredir("ls!","s:NetrwBufRename (before bwipe)~".expand("<slnum>"))
let oldbufnr= bufnr(oldbufname)
" call Decho("oldbufname<".oldbufname."> oldbufnr#".oldbufnr,'~'.expand("<slnum>"))
" call Decho("bufnr(%)=".bufnr("%"),'~'.expand("<slnum>"))
@@ -5504,6 +5560,9 @@ fun! s:NetrwBufRename(newname)
exe "bwipe! ".oldbufnr
" else " Decho
" call Decho("did *not* bwipe buf#".oldbufnr,'~'.expand("<slnum>"))
+" call Decho("..reason: if oldbufname<".oldbufname."> is empty",'~'.expand("<slnum>"))"
+" call Decho("..reason: if oldbufnr#".oldbufnr." is -1",'~'.expand("<slnum>"))"
+" call Decho("..reason: if oldbufnr#".oldbufnr." != bufnr(%)#".bufnr("%"),'~'.expand("<slnum>"))"
endif
" call Dredir("ls!","s:NetrwBufRename (after rename)")
" else " Decho
@@ -6482,7 +6541,7 @@ fun! s:NetrwMaps(islocal)
if !hasmapto('<Plug>NetrwRefresh')
nmap <buffer> <unique> <c-l> <Plug>NetrwRefresh
endif
- nnoremap <buffer> <silent> <Plug>NetrwRefresh <c-l>:call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,(w:netrw_liststyle == 3)? w:netrw_treetop : './'))<cr>
+ nnoremap <buffer> <silent> <Plug>NetrwRefresh <c-l>:call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,(exists("w:netrw_liststyle") && exists("w:netrw_treetop") && w:netrw_liststyle == 3)? w:netrw_treetop : './'))<cr>
if s:didstarstar || !mapcheck("<s-down>","n")
nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
endif
@@ -6731,7 +6790,7 @@ fun! s:NetrwMarkFile(islocal,fname)
" sanity check
if empty(a:fname)
-" call Dret("s:NetrwMarkFile : emtpy fname")
+" call Dret("s:NetrwMarkFile : empty fname")
return
endif
let curdir = s:NetrwGetCurdir(a:islocal)
@@ -8110,6 +8169,23 @@ fun! s:NetrwOpenFile(islocal)
call inputsave()
let fname= input("Enter filename: ")
call inputrestore()
+" call Decho("(s:NetrwOpenFile) fname<".fname.">",'~'.expand("<slnum>"))
+
+ " determine if Lexplore is in use
+ if exists("t:netrw_lexbufnr")
+ " check if t:netrw_lexbufnr refers to a netrw window
+" call Decho("(s:netrwOpenFile) ..t:netrw_lexbufnr=".t:netrw_lexbufnr,'~'.expand("<slnum>"))
+ let lexwinnr = bufwinnr(t:netrw_lexbufnr)
+ if lexwinnr != -1 && exists("g:netrw_chgwin") && g:netrw_chgwin != -1
+" call Decho("(s:netrwOpenFile) ..Lexplore in use",'~'.expand("<slnum>"))
+ exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd w"
+ exe "NetrwKeepj e ".fnameescape(fname)
+ let @@= ykeep
+" call Dret("s:NetrwOpenFile : creating a file with Lexplore mode")
+ endif
+ endif
+
+ " Does the filename contain a path?
if fname !~ '[/\\]'
if exists("b:netrw_curdir")
if exists("g:netrw_quiet")
@@ -8448,6 +8524,7 @@ fun! s:NetrwPrevWinOpen(islocal)
let lastwinnr = winnr("$")
let curword = s:NetrwGetWord()
let choice = 0
+ let s:prevwinopen= 1 " lets s:NetrwTreeDir() know that NetrwPrevWinOpen called it
let s:treedir = s:NetrwTreeDir(a:islocal)
let curdir = s:treedir
" call Decho("winnr($)#".lastwinnr." curword<".curword.">",'~'.expand("<slnum>"))
@@ -8775,7 +8852,7 @@ fun! s:NetrwPreview(path) range
" 0 : 1: top -- preview window is horizontally split off and on the top
" 0 : 0: bot -- preview window is horizontally split off and on the bottom
"
- " Note that the file being previewed is already known to not be a directory, hence we can avoid doing a LocalBrowse() check via
+ " Note that the file being previewed is already known to not be a directory, hence we can avoid doing a LocalBrowseCheck() check via
" the BufEnter event set up in netrwPlugin.vim
" call Decho("exe ".(g:netrw_alto? "top " : "bot ").(g:netrw_preview? "vert " : "")."pedit ".fnameescape(a:path),'~'.expand("<slnum>"))
let eikeep = &ei
@@ -9210,14 +9287,20 @@ fun! s:NetrwTreeDir(islocal)
" call Decho("g:netrw_keepdir =".(exists("g:netrw_keepdir")? g:netrw_keepdir : 'n/a'),'~'.expand("<slnum>"))
" call Decho("w:netrw_liststyle=".(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'),'~'.expand("<slnum>"))
" call Decho("w:netrw_treetop =".(exists("w:netrw_treetop")? w:netrw_treetop : 'n/a'),'~'.expand("<slnum>"))
+" call Decho("current line<".getline(".").">")
- if exists("s:treedir")
+ if exists("s:treedir") && exists("s:prevwinopen")
" s:NetrwPrevWinOpen opens a "previous" window -- and thus needs to and does call s:NetrwTreeDir early
+" call Decho('s:NetrwPrevWinOpen opens a "previous" window -- and thus needs to and does call s:NetrwTreeDir early')
let treedir= s:treedir
unlet s:treedir
-" call Dret("s:NetrwTreeDir ".treedir)
+ unlet s:prevwinopen
+" call Dret("s:NetrwTreeDir ".treedir.": early return since s:treedir existed previously")
return treedir
endif
+ if exists("s:prevwinopen")
+ unlet s:prevwinopen
+ endif
if !exists("b:netrw_curdir") || b:netrw_curdir == ""
let b:netrw_curdir= getcwd()
@@ -9424,20 +9507,29 @@ endfun
" Called by s:PerformListing()
fun! s:NetrwTreeListing(dirname)
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
-" call Dfunc("NetrwTreeListing() bufname<".expand("%").">")
+" call Dfunc("s:NetrwTreeListing() bufname<".expand("%").">")
" call Decho("curdir<".a:dirname.">",'~'.expand("<slnum>"))
" call Decho("win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exist")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit"),'~'.expand("<slnum>"))
" call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>"))
" update the treetop
-" call Decho("update the treetop",'~'.expand("<slnum>"))
if !exists("w:netrw_treetop")
+" call Decho("update the treetop (w:netrw_treetop doesn't exist yet)",'~'.expand("<slnum>"))
let w:netrw_treetop= a:dirname
+ let s:netrw_treetop= w:netrw_treetop
" call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)",'~'.expand("<slnum>"))
elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop)
+" call Decho("update the treetop (override w:netrw_treetop with a:dirname<".a:dirname.">)",'~'.expand("<slnum>"))
let w:netrw_treetop= a:dirname
+ let s:netrw_treetop= w:netrw_treetop
" call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)",'~'.expand("<slnum>"))
endif
+ if exists("w:netrw_treetop")
+ let s:netrw_treetop= w:netrw_treetop
+ else
+ let w:netrw_treetop= getcwd()
+ let s:netrw_treetop= w:netrw_treetop
+ endif
if !exists("w:netrw_treedict")
" insure that we have a treedict, albeit empty
@@ -9475,7 +9567,7 @@ fun! s:NetrwTreeListing(dirname)
exe "setl ".g:netrw_bufsettings
-" call Dret("NetrwTreeListing : bufname<".expand("%").">")
+" call Dret("s:NetrwTreeListing : bufname<".expand("%").">")
return
endif
endfun
@@ -10619,7 +10711,7 @@ endfun
" ---------------------------------------------------------------------
" netrw#LocalBrowseCheck: {{{2
fun! netrw#LocalBrowseCheck(dirname)
- " This function is called by netrwPlugin.vim's s:LocalBrowse(), s:NetrwRexplore(),
+ " This function is called by netrwPlugin.vim's s:LocalBrowseCheck(), s:NetrwRexplore(),
" and by <cr> when atop a listed file/directory (via a buffer-local map)
"
" unfortunate interaction -- split window debugging can't be used here, must use
@@ -10770,7 +10862,7 @@ endfun
" Hiding a buffer means that it will be re-used when examined, hence "fast".
" (re-using a buffer may not be as accurate)
"
-" s:netrw_events : doesn't exist, s:LocalFastBrowser() will install autocmds whena med or fast browsing
+" s:netrw_events : doesn't exist, s:LocalFastBrowser() will install autocmds with medium-speed or fast browsing
" =1: autocmds installed, but ignore next FocusGained event to avoid initial double-refresh of listing.
" BufEnter may be first event, then a FocusGained event. Ignore the first FocusGained event.
" If :Explore used: it sets s:netrw_events to 2, so no FocusGained events are ignored.
@@ -10932,13 +11024,14 @@ fun! s:LocalListing()
let sz= s:NetrwHumanReadable(sz)
endif
let longfile= printf("%-".(g:netrw_maxfilenamelen+1)."s",pfile)
- let pfile = longfile.fsz." ".strftime(g:netrw_timefmt,getftime(filename))
+ let pfile = longfile.sz." ".strftime(g:netrw_timefmt,getftime(filename))
" call Decho("longlist support: sz=".sz." fsz=".fsz,'~'.expand("<slnum>"))
endif
if g:netrw_sort_by =~# "^t"
" sort by time (handles time up to 1 quintillion seconds, US)
" Decorate listing by prepending a timestamp/ . Sorting will then be done based on time.
+" call Decho("implementing g:netrw_sort_by=".g:netrw_sort_by." (time)")
" call Decho("getftime(".filename.")=".getftime(filename),'~'.expand("<slnum>"))
let t = getftime(filename)
let ft = strpart("000000000000000000",1,18-strlen(t)).t
@@ -10948,6 +11041,7 @@ fun! s:LocalListing()
elseif g:netrw_sort_by =~ "^s"
" sort by size (handles file sizes up to 1 quintillion bytes, US)
+" call Decho("implementing g:netrw_sort_by=".g:netrw_sort_by." (size)")
" call Decho("getfsize(".filename.")=".getfsize(filename),'~'.expand("<slnum>"))
let sz = getfsize(filename)
if g:netrw_sizestyle =~# "[hH]"
@@ -10960,6 +11054,7 @@ fun! s:LocalListing()
else
" sort by name
+" call Decho("implementing g:netrw_sort_by=".g:netrw_sort_by." (name)")
" call Decho("exe NetrwKeepj put ='".pfile."'",'~'.expand("<slnum>"))
sil! NetrwKeepj put=pfile
endif
@@ -11682,19 +11777,32 @@ endfun
" ---------------------------------------------------------------------
" s:NetrwCursor: responsible for setting cursorline/cursorcolumn based upon g:netrw_cursor {{{2
-fun! s:NetrwCursor()
+fun! s:NetrwCursor(editfile)
if !exists("w:netrw_liststyle")
let w:netrw_liststyle= g:netrw_liststyle
endif
" call Dfunc("s:NetrwCursor() ft<".&ft."> liststyle=".w:netrw_liststyle." g:netrw_cursor=".g:netrw_cursor." s:netrw_usercuc=".s:netrw_usercuc." s:netrw_usercul=".s:netrw_usercul)
+" call Decho("(s:NetrwCursor) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
+
if &ft != "netrw"
" if the current window isn't a netrw directory listing window, then use user cursorline/column
" settings. Affects when netrw is used to read/write a file using scp/ftp/etc.
" call Decho("case ft!=netrw: use user cul,cuc",'~'.expand("<slnum>"))
- let &l:cursorline = s:netrw_usercul
- let &l:cursorcolumn = s:netrw_usercuc
+ elseif g:netrw_cursor == 8
+ if w:netrw_liststyle == s:WIDELIST
+ setl cursorline
+ setl cursorcolumn
+ else
+ setl cursorline
+ endif
+ elseif g:netrw_cursor == 7
+ setl cursorline
+ elseif g:netrw_cursor == 6
+ if w:netrw_liststyle == s:WIDELIST
+ setl cursorline
+ endif
elseif g:netrw_cursor == 4
" all styles: cursorline, cursorcolumn
" call Decho("case g:netrw_cursor==4: setl cul cuc",'~'.expand("<slnum>"))
@@ -11711,26 +11819,22 @@ fun! s:NetrwCursor()
else
" call Decho("case g:netrw_cursor==3 and not wide: setl cul (use user's cuc)",'~'.expand("<slnum>"))
setl cursorline
- let &l:cursorcolumn = s:netrw_usercuc
endif
elseif g:netrw_cursor == 2
" thin-long-tree: cursorline, user's cursorcolumn
" wide : cursorline, user's cursorcolumn
" call Decho("case g:netrw_cursor==2: setl cuc (use user's cul)",'~'.expand("<slnum>"))
- let &l:cursorcolumn = s:netrw_usercuc
setl cursorline
elseif g:netrw_cursor == 1
" thin-long-tree: user's cursorline, user's cursorcolumn
" wide : cursorline, user's cursorcolumn
- let &l:cursorcolumn = s:netrw_usercuc
if w:netrw_liststyle == s:WIDELIST
" call Decho("case g:netrw_cursor==2 and wide: setl cul (use user's cuc)",'~'.expand("<slnum>"))
setl cursorline
else
" call Decho("case g:netrw_cursor==2 and not wide: (use user's cul,cuc)",'~'.expand("<slnum>"))
- let &l:cursorline = s:netrw_usercul
endif
else
@@ -11740,6 +11844,7 @@ fun! s:NetrwCursor()
let &l:cursorcolumn = s:netrw_usercuc
endif
+" call Decho("(s:NetrwCursor) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
" call Dret("s:NetrwCursor : l:cursorline=".&l:cursorline." l:cursorcolumn=".&l:cursorcolumn)
endfun
@@ -11753,6 +11858,7 @@ fun! s:RestoreCursorline()
if exists("s:netrw_usercuc")
let &l:cursorcolumn = s:netrw_usercuc
endif
+" call Decho("(s:RestoreCursorline) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
" call Dret("s:RestoreCursorline : restored cul=".&l:cursorline." cuc=".&l:cursorcolumn)
endfun
@@ -11788,11 +11894,37 @@ fun! s:NetrwDelete(path)
endfun
" ---------------------------------------------------------------------
+" s:NetrwBufRemover: removes a buffer that: {{{2s
+" has buffer-id > 1
+" is unlisted
+" is unnamed
+" does not appear in any window
+fun! s:NetrwBufRemover(bufid)
+" call Dfunc("s:NetrwBufRemover(".a:bufid.")")
+" call Decho("buf#".a:bufid." ".((a:bufid > 1)? ">" : "≯")." must be >1 for removal","~".expand("<slnum>"))
+" call Decho("buf#".a:bufid." is ".(buflisted(a:bufid)? "listed" : "unlisted"),"~".expand("<slnum>"))
+" call Decho("buf#".a:bufid." has name <".bufname(a:bufid).">","~".expand("<slnum>"))
+" call Decho("buf#".a:bufid." has winid#".bufwinid(a:bufid),"~".expand("<slnum>"))
+
+ if a:bufid > 1 && !buflisted(a:bufid) && bufname(a:bufid) == "" && bufwinid(a:bufid) == -1
+" call Decho("(s:NetrwBufRemover) removing buffer#".a:bufid,"~".expand("<slnum>"))
+ exe "bd! ".a:bufid
+ endif
+
+" call Dret("s:NetrwBufRemover")
+endfun
+
+" ---------------------------------------------------------------------
" s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2
fun! s:NetrwEnew(...)
" call Dfunc("s:NetrwEnew() a:0=".a:0." win#".winnr()." winnr($)=".winnr("$")." bufnr($)=".bufnr("$")." expand(%)<".expand("%").">")
" call Decho("curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>"))
+ " Clean out the last buffer:
+ " Check if the last buffer has # > 1, is unlisted, is unnamed, and does not appear in a window
+ " If so, delete it.
+ call s:NetrwBufRemover(bufnr("$"))
+
" grab a function-local-variable copy of buffer variables
" call Decho("make function-local copy of netrw variables",'~'.expand("<slnum>"))
if exists("b:netrw_bannercnt") |let netrw_bannercnt = b:netrw_bannercnt |endif
diff --git a/runtime/autoload/netrwSettings.vim b/runtime/autoload/netrwSettings.vim
index bed5cfc455..61c0ef739e 100644
--- a/runtime/autoload/netrwSettings.vim
+++ b/runtime/autoload/netrwSettings.vim
@@ -1,7 +1,7 @@
" netrwSettings.vim: makes netrw settings simpler
-" Date: Nov 09, 2016
+" Date: Aug 12, 2021
" Maintainer: Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
-" Version: 16
+" Version: 17 ASTRO-ONLY
" Copyright: Copyright (C) 1999-2007 Charles E. Campbell {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
@@ -19,7 +19,7 @@
if exists("g:loaded_netrwSettings") || &cp
finish
endif
-let g:loaded_netrwSettings = "v16"
+let g:loaded_netrwSettings = "v17"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of netrwSettings needs vim 7.0"
@@ -31,7 +31,7 @@ endif
" NetrwSettings: {{{1
fun! netrwSettings#NetrwSettings()
" this call is here largely just to insure that netrw has been loaded
- call netrw#SavePosn()
+ call netrw#WinPath("")
if !exists("g:loaded_netrw")
echohl WarningMsg | echomsg "***sorry*** netrw needs to be loaded prior to using NetrwSettings" | echohl None
return
diff --git a/runtime/autoload/phpcomplete.vim b/runtime/autoload/phpcomplete.vim
index 377baa8432..f9aa15c827 100644
--- a/runtime/autoload/phpcomplete.vim
+++ b/runtime/autoload/phpcomplete.vim
@@ -9,7 +9,7 @@
"
" let g:phpcomplete_relax_static_constraint = 1/0 [default 0]
" Enables completion for non-static methods when completing for static context (::).
-" This generates E_STRICT level warning, but php calls these methods nontheless.
+" This generates E_STRICT level warning, but php calls these methods nonetheless.
"
" let g:phpcomplete_complete_for_unknown_classes = 1/0 [default 0]
" Enables completion of variables and functions in "everything under the sun" fashion
@@ -28,7 +28,7 @@
" This option controls the number of characters the user needs to type before
" the tags will be searched for namespaces and classes in typed out namespaces in
" "use ..." context. Setting this to 0 is not recommended because that means the code
-" have to scan every tag, and vim's taglist() function runs extremly slow with a
+" have to scan every tag, and vim's taglist() function runs extremely slow with a
" "match everything" pattern.
"
" let g:phpcomplete_parse_docblock_comments = 1/0 [default 0]
@@ -268,7 +268,7 @@ function! phpcomplete#CompleteUse(base) " {{{
call add(no_namespace_matches, {'word': namespace_for_class.'\'.tag.name, 'kind': tag.kind, 'menu': tag.filename, 'info': tag.filename })
endif
endfor
- " if it seems that the tags file have namespace informations we can safely throw
+ " if it seems that the tags file have namespace information we can safely throw
" away namespaceless tag matches since we can be sure they are invalid
if patched_ctags_detected
no_namespace_matches = []
@@ -810,7 +810,7 @@ function! phpcomplete#CompleteClassName(base, kinds, current_namespace, imports)
endif
endfor
- " resolve the typed in part with namespaces (if theres a \ in it)
+ " resolve the typed in part with namespaces (if there's a \ in it)
let [tag_match_pattern, namespace_for_class] = phpcomplete#ExpandClassName(a:base, a:current_namespace, a:imports)
let tags = []
@@ -926,11 +926,11 @@ function! s:getNextCharWithPos(filelines, current_pos) " {{{
endfunction " }}}
function! phpcomplete#EvaluateModifiers(modifiers, required_modifiers, prohibited_modifiers) " {{{
- " if theres no modifier, and no modifier is allowed and no modifier is required
+ " if there's no modifier, and no modifier is allowed and no modifier is required
if len(a:modifiers) == 0 && len(a:required_modifiers) == 0
return 1
else
- " check if every requred modifier is present
+ " check if every required modifier is present
for required_modifier in a:required_modifiers
if index(a:modifiers, required_modifier) == -1
return 0
@@ -1258,7 +1258,7 @@ function! phpcomplete#GetCurrentInstruction(line_number, col_number, phpbegin) "
endif
endif
- " save the coma position for later use if theres a "naked" , possibly separating a parameter and it is not in a parented part
+ " save the coma position for later use if there's a "naked" , possibly separating a parameter and it is not in a parented part
if first_coma_break_pos == -1 && current_char == ','
let first_coma_break_pos = len(instruction)
endif
@@ -1304,7 +1304,7 @@ function! phpcomplete#GetCurrentInstruction(line_number, col_number, phpbegin) "
" there were a "naked" coma in the instruction
if first_coma_break_pos != -1
- if instruction !~? '^use' && instruction !~? '^class' " use ... statements and class delcarations should not be broken up by comas
+ if instruction !~? '^use' && instruction !~? '^class' " use ... statements and class declarations should not be broken up by comas
let pos = (-1 * first_coma_break_pos) + 1
let instruction = instruction[pos :]
endif
@@ -1316,7 +1316,7 @@ function! phpcomplete#GetCurrentInstruction(line_number, col_number, phpbegin) "
" clear everything up until the first (
let instruction = substitute(instruction, '^\(if\|while\|foreach\|for\)\s*(\s*', '', '')
- " lets iterate trough the instruction until we can find the pair for the opening (
+ " lets iterate through the instruction until we can find the pair for the opening (
let i = 0
let depth = 1
while i < len(instruction)
@@ -1424,7 +1424,7 @@ function! phpcomplete#GetCallChainReturnType(classname_candidate, class_candidat
let parts = split(substitute(type, '^\\', '', ''), '\')
let class_candidate_namespace = join(parts[0:-2], '\')
let classname_candidate = parts[-1]
- " check for renamed namepsace in imports
+ " check for renamed namespace in imports
if has_key(classstructure.imports, class_candidate_namespace)
let class_candidate_namespace = classstructure.imports[class_candidate_namespace].name
endif
@@ -2023,7 +2023,7 @@ function! phpcomplete#GetCachedClassContents(classlocation, class_name) " {{{
if getftime(classstructure.file) != classstructure.mtime
let valid = 0
" we could break here, but the time required for checking probably worth
- " the the memory we can free by checking every file in the cached hirearchy
+ " the memory we can free by checking every file in the cached hierarchy
call phpcomplete#ClearCachedClassContents(classstructure.file)
endif
endfor
@@ -2037,7 +2037,7 @@ function! phpcomplete#GetCachedClassContents(classlocation, class_name) " {{{
call remove(s:cache_classstructures, cache_key)
call phpcomplete#ClearCachedClassContents(full_file_path)
- " fall trough for the read from files path
+ " fall through for the read from files path
endif
else
call phpcomplete#ClearCachedClassContents(full_file_path)
@@ -2590,7 +2590,7 @@ function! phpcomplete#GetCurrentNameSpace(file_lines) " {{{
let search_line = line
let use_line = line
- " add lines from the file until theres no ';' in them
+ " add lines from the file until there's no ';' in them
while search_line !~? ';' && l > 0
" file lines are reversed so we need to go backwards
let l -= 1
@@ -2622,7 +2622,7 @@ function! phpcomplete#GetCurrentNameSpace(file_lines) " {{{
" find kind flags from tags or built in methods for the objects we extracted
" they can be either classes, interfaces or namespaces, no other thing is importable in php
for [key, import] in items(imports)
- " if theres a \ in the name we have it's definitely not a built in thing, look for tags
+ " if there's a \ in the name we have it's definitely not a built in thing, look for tags
if import.name =~ '\\'
let patched_ctags_detected = 0
let [classname, namespace_for_classes] = phpcomplete#ExpandClassName(import.name, '\', {})
@@ -2679,10 +2679,10 @@ function! phpcomplete#GetCurrentNameSpace(file_lines) " {{{
let import['kind'] = 'i'
let import['builtin'] = 1
else
- " or can be a tag with exactly matchign name
+ " or can be a tag with exactly matching name
let tags = phpcomplete#GetTaglist('^'.import['name'].'$')
for tag in tags
- " search for the first matchin namespace, class, interface with no namespace
+ " search for the first matching namespace, class, interface with no namespace
if !has_key(tag, 'namespace') && (tag.kind == 'n' || tag.kind == 'c' || tag.kind == 'i' || tag.kind == 't')
call extend(import, tag)
let import['builtin'] = 0
@@ -2900,7 +2900,7 @@ for [ext, data] in items(php_builtin['functions'])
call extend(g:php_builtin_functions, data)
endfor
-" Built in classs
+" Built in class
let g:php_builtin_classes = {}
for [ext, data] in items(php_builtin['classes'])
call extend(g:php_builtin_classes, data)
@@ -2918,10 +2918,10 @@ for [ext, data] in items(php_builtin['constants'])
call extend(g:php_constants, data)
endfor
-" When the classname not found or found but the tags dosen't contain that
-" class we will try to complate any method of any builtin class. To speed up
+" When the classname not found or found but the tags doesn't contain that
+" class we will try to complete any method of any builtin class. To speed up
" that lookup we compile a 'ClassName::MethodName':'info' dictionary from the
-" builtin class informations
+" builtin class information
let g:php_builtin_object_functions = {}
" When completing for 'everyting imaginable' (no class context, not a
diff --git a/runtime/autoload/python3complete.vim b/runtime/autoload/python3complete.vim
index 1d7f5d18f5..192e9e6df8 100644
--- a/runtime/autoload/python3complete.vim
+++ b/runtime/autoload/python3complete.vim
@@ -173,7 +173,7 @@ class Completer(object):
pass
if len(arg_text) == 0:
# The doc string sometimes contains the function signature
- # this works for alot of C modules that are part of the
+ # this works for a lot of C modules that are part of the
# standard library
doc = func_obj.__doc__
if doc:
diff --git a/runtime/autoload/pythoncomplete.vim b/runtime/autoload/pythoncomplete.vim
index 575c23e6d3..e9233e1d49 100644
--- a/runtime/autoload/pythoncomplete.vim
+++ b/runtime/autoload/pythoncomplete.vim
@@ -191,7 +191,7 @@ class Completer(object):
pass
if len(arg_text) == 0:
# The doc string sometimes contains the function signature
- # this works for alot of C modules that are part of the
+ # this works for a lot of C modules that are part of the
# standard library
doc = func_obj.__doc__
if doc:
diff --git a/runtime/autoload/sqlcomplete.vim b/runtime/autoload/sqlcomplete.vim
index ea0d8c2de9..adbdbab894 100644
--- a/runtime/autoload/sqlcomplete.vim
+++ b/runtime/autoload/sqlcomplete.vim
@@ -17,7 +17,7 @@
" and complete it.
"
" Version 16.0 (Dec 2015)
-" - NF: If reseting the cache and table, procedure or view completion
+" - NF: If resetting the cache and table, procedure or view completion
" had been used via dbext, have dbext delete or recreate the
" dictionary so that new objects are picked up for the
" next completion.
@@ -554,7 +554,7 @@ function! sqlcomplete#PreCacheSyntax(...)
let syn_group_arr = g:omni_sql_precache_syntax_groups
endif
" For each group specified in the list, precache all
- " the sytnax items.
+ " the syntax items.
if !empty(syn_group_arr)
for group_name in syn_group_arr
let syn_items = extend( syn_items, s:SQLCGetSyntaxList(group_name) )
@@ -577,7 +577,7 @@ function! sqlcomplete#ResetCacheSyntax(...)
let syn_group_arr = g:omni_sql_precache_syntax_groups
endif
" For each group specified in the list, precache all
- " the sytnax items.
+ " the syntax items.
if !empty(syn_group_arr)
for group_name in syn_group_arr
let list_idx = index(s:syn_list, group_name, 0, &ignorecase)
@@ -843,7 +843,7 @@ function! s:SQLCGetColumns(table_name, list_type)
let curline = line(".")
let curcol = col(".")
- " Do not let searchs wrap
+ " Do not let searches wrap
setlocal nowrapscan
" If . was entered, look at the word just before the .
" We are looking for something like this:
@@ -863,7 +863,7 @@ function! s:SQLCGetColumns(table_name, list_type)
" Search forward until one of the following:
" 1. Another select/update/delete statement
" 2. A ; at the end of a line (the delimiter)
- " 3. The end of the file (incase no delimiter)
+ " 3. The end of the file (in case no delimiter)
" Yank the visually selected text into the "y register.
exec 'silent! normal! vl/\c\(\<select\>\|\<update\>\|\<delete\>\|;\s*$\|\%$\)'."\n".'"yy'
diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim
index b6c4c660b8..e495e8262a 100644
--- a/runtime/autoload/tar.vim
+++ b/runtime/autoload/tar.vim
@@ -778,7 +778,7 @@ fun! tar#Vimuntar(...)
elseif executable("gzip")
silent exe "!gzip -d ".shellescape(tartail)
else
- echoerr "unable to decompress<".tartail."> on this sytem"
+ echoerr "unable to decompress<".tartail."> on this system"
if simplify(curdir) != simplify(tarhome)
" remove decompressed tarball, restore directory
" call Decho("delete(".tartail.".tar)")
diff --git a/runtime/autoload/tohtml.vim b/runtime/autoload/tohtml.vim
index 76092f0f93..66f1cb46cb 100644
--- a/runtime/autoload/tohtml.vim
+++ b/runtime/autoload/tohtml.vim
@@ -693,7 +693,7 @@ func! tohtml#GetUserSettings() "{{{
let user_settings = {}
" Define the correct option if the old option name exists and we haven't
- " already defined the correct one. Maybe I'll put out a warnig message about
+ " already defined the correct one. Maybe I'll put out a warning message about
" this sometime and remove the old option entirely at some even later time,
" but for now just silently accept the old option.
if exists('g:use_xhtml') && !exists("g:html_use_xhtml")
diff --git a/runtime/autoload/xmlcomplete.vim b/runtime/autoload/xmlcomplete.vim
index 4c1ac4f6b5..55fb031e68 100644
--- a/runtime/autoload/xmlcomplete.vim
+++ b/runtime/autoload/xmlcomplete.vim
@@ -199,7 +199,7 @@ function! xmlcomplete#CompleteTags(findstart, base)
" 1. Events attributes
if context =~ '\s'
- " If attr contains =\s*[\"'] we catched value of attribute
+ " If attr contains =\s*[\"'] we catch value of attribute
if attr =~ "=\s*[\"']" || attr =~ "=\s*$"
" Let do attribute specific completion
let attrname = matchstr(attr, '.*\ze\s*=')
diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim
index f6b876df05..9588bbf4a2 100644
--- a/runtime/autoload/zip.vim
+++ b/runtime/autoload/zip.vim
@@ -81,7 +81,7 @@ fun! zip#Browse(zipfile)
" sanity checks
if !exists("*fnameescape")
if &verbose > 1
- echoerr "the zip plugin is not available (your vim doens't support fnameescape())"
+ echoerr "the zip plugin is not available (your vim doesn't support fnameescape())"
endif
return
endif
diff --git a/runtime/compiler/fpc.vim b/runtime/compiler/fpc.vim
index fb4f424986..de8e2fe3dc 100644
--- a/runtime/compiler/fpc.vim
+++ b/runtime/compiler/fpc.vim
@@ -12,6 +12,6 @@ if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif
-" NOTE: compiler must be runned with -vb to write whole source path, not only file
+" NOTE: compiler must be run with -vb to write whole source path, not only file
" name.
CompilerSet errorformat=%f(%l\\,%c)\ %m
diff --git a/runtime/compiler/scdoc.vim b/runtime/compiler/scdoc.vim
new file mode 100644
index 0000000000..2f6edc6322
--- /dev/null
+++ b/runtime/compiler/scdoc.vim
@@ -0,0 +1,16 @@
+" scdoc compiler for Vim
+" Compiler: scdoc
+" Maintainer: Greg Anders <greg@gpanders.com>
+" Last Updated: 2019-10-24
+
+if exists('current_compiler')
+ finish
+endif
+let current_compiler = 'scdoc'
+
+if exists(':CompilerSet') != 2
+ command -nargs=* CompilerSet setlocal <args>
+endif
+
+CompilerSet makeprg=scdoc\ <\ %\ 2>&1
+CompilerSet errorformat=Error\ at\ %l:%c:\ %m,%-G%.%#
diff --git a/runtime/compiler/spectral.vim b/runtime/compiler/spectral.vim
new file mode 100644
index 0000000000..bd13c51f43
--- /dev/null
+++ b/runtime/compiler/spectral.vim
@@ -0,0 +1,17 @@
+" Vim compiler file
+" Compiler: Spectral for YAML
+" Maintainer: Romain Lafourcade <romainlafourcade@gmail.com>
+" Last Change: 2021 July 21
+
+if exists("current_compiler")
+ finish
+endif
+let current_compiler = "spectral"
+
+if exists(":CompilerSet") != 2
+ command -nargs=* CompilerSet setlocal <args>
+endif
+
+CompilerSet makeprg=spectral\ lint\ %\ -f\ text
+CompilerSet errorformat=%f:%l:%c\ %t%.%\\{-}\ %m
+
diff --git a/runtime/compiler/tex.vim b/runtime/compiler/tex.vim
index e43be8dbd6..65e15cf6e2 100644
--- a/runtime/compiler/tex.vim
+++ b/runtime/compiler/tex.vim
@@ -18,7 +18,7 @@ endif
if exists('b:tex_ignore_makefile') || exists('g:tex_ignore_makefile') ||
\(!filereadable('Makefile') && !filereadable('makefile'))
" If buffer-local variable 'tex_flavor' exists, it defines TeX flavor,
- " otherwize the same for global variable with same name, else it will be
+ " otherwise the same for global variable with same name, else it will be
" LaTeX
if exists("b:tex_flavor")
let current_compiler = b:tex_flavor
diff --git a/runtime/compiler/yamllint.vim b/runtime/compiler/yamllint.vim
new file mode 100644
index 0000000000..889b04b63c
--- /dev/null
+++ b/runtime/compiler/yamllint.vim
@@ -0,0 +1,16 @@
+" Vim compiler file
+" Compiler: Yamllint for YAML
+" Maintainer: Romain Lafourcade <romainlafourcade@gmail.com>
+" Last Change: 2021 July 21
+
+if exists("current_compiler")
+ finish
+endif
+let current_compiler = "yamllint"
+
+if exists(":CompilerSet") != 2
+ command -nargs=* CompilerSet setlocal <args>
+endif
+
+CompilerSet makeprg=yamllint\ -f\ parsable
+
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index dae7986fdb..df345e4981 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -134,6 +134,14 @@ lines, 0-based columns):
|nvim_win_get_cursor()|
|nvim_win_set_cursor()|
+Exception: the following API functions use |extmarks| indexing (0-based
+indices, end-inclusive):
+
+ |nvim_buf_del_extmark()|
+ |nvim_buf_get_extmark_by_id()|
+ |nvim_buf_get_extmarks()|
+ |nvim_buf_set_extmark()|
+
*api-fast*
Most API functions are "deferred": they are queued on the main loop and
processed sequentially with normal input. So if the editor is waiting for
@@ -436,36 +444,76 @@ Example: create a float with scratch buffer: >
>
==============================================================================
-Extended marks *api-extended-marks*
+Extended marks *api-extended-marks* *extmarks*
Extended marks (extmarks) represent buffer annotations that track text changes
-in the buffer. They could be used to represent cursors, folds, misspelled
-words, and anything else that needs to track a logical location in the buffer
-over time.
+in the buffer. They can represent cursors, folds, misspelled words, anything
+that needs to track a logical location in the buffer over time. |api-indexing|
+
+Extmark position works like "bar" cursor: it exists between characters. Thus
+the maximum extmark index on a line is 1 more than the character index: >
+
+ f o o b a r line contents
+ 0 1 2 3 4 5 character positions (0-based)
+ 0 1 2 3 4 5 6 extmark positions (0-based)
+
+Extmarks have "forward gravity": if you place the cursor directly on an
+extmark position and enter some text, the extmark migrates forward. >
+
+ f o o|b a r line (| = cursor)
+ 3 extmark
+
+ f o o z|b a r line (| = cursor)
+ 4 extmark (after typing "z")
+
+If an extmark is on the last index of a line and you inputsa newline at that
+point, the extmark will accordingly migrate to the next line: >
+
+ f o o z b a r| line (| = cursor)
+ 7 extmark
+
+ f o o z b a r first line
+ extmarks (none present)
+ | second line (| = cursor)
+ 0 extmark (after typing <CR>)
+
Example:
-We will set an extmark at the first row and third column. |api-indexing| is
-zero-indexed, so we use row=0 and column=2. Passing id=0 creates a new mark
-and returns the id: >
+Let's set an extmark at the first row (row=0) and third column (column=2).
+|api-indexing| Passing id=0 creates a new mark and returns the id: >
+ 01 2345678
+ 0 ex|ample..
+< ^ extmark position
+>
let g:mark_ns = nvim_create_namespace('myplugin')
- let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 0, 2, {})
-
-We can get a mark by its id: >
+ let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 2, {})
+<
+We can get the mark by its id: >
- echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id)
+ echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id, {})
=> [0, 2]
-We can get all marks in a buffer for our namespace (or by a range): >
+We can get all marks in a buffer by |namespace| (or by a range): >
echo nvim_buf_get_extmarks(0, g:mark_ns, 0, -1, {})
=> [[1, 0, 2]]
-Deleting all text surrounding an extmark does not remove the extmark. To
-remove an extmark use |nvim_buf_del_extmark()|.
+Deleting all surrounding text does NOT remove an extmark! To remove extmarks
+use |nvim_buf_del_extmark()|. Deleting "x" in our example: >
+
+ 0 12345678
+ 0 e|ample..
+< ^ extmark position
+>
+ echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id, {})
+ => [0, 1]
+<
+ Note: Extmark "gravity" decides how it will shift after a text edit.
+ See |nvim_buf_set_extmark()|
-Namespaces allow your plugin to manage only its own extmarks, ignoring those
+Namespaces allow any plugin to manage only its own extmarks, ignoring those
created by another plugin.
Extmark positions changed by an edit will be restored on undo/redo. Creating
@@ -779,10 +827,9 @@ nvim_feedkeys({keys}, {mode}, {escape_csi}) *nvim_feedkeys()*
On execution error: does not fail, but updates v:errmsg.
- If you need to input sequences like <C-o> use
- |nvim_replace_termcodes| to replace the termcodes and then
- pass the resulting string to nvim_feedkeys. You'll also want
- to enable escape_csi.
+ To input sequences like <C-o> use |nvim_replace_termcodes()|
+ (typically with escape_csi=true) to replace the keycodes. Then
+ pass the result to nvim_feedkeys().
Example: >
:let key = nvim_replace_termcodes("<C-o>", v:true, v:false, v:true)
@@ -2072,7 +2119,7 @@ nvim_buf_get_commands({buffer}, {opts}) *nvim_buf_get_commands()*
*nvim_buf_get_extmark_by_id()*
nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
- Returns position for a given extmark id
+ Gets the position (0-indexed) of an extmark {id}.
Parameters: ~
{buffer} Buffer handle, or 0 for current buffer
@@ -2082,7 +2129,8 @@ nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
• details: Whether to include the details dict
Return: ~
- (row, col) tuple or empty list () if extmark id was absent
+ 0-indexed (row, col) tuple or empty list () if extmark id
+ was absent
*nvim_buf_get_extmarks()*
nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
@@ -2122,10 +2170,12 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
Parameters: ~
{buffer} Buffer handle, or 0 for current buffer
{ns_id} Namespace id from |nvim_create_namespace()|
- {start} Start of range, given as (row, col) or valid
- extmark id (whose position defines the bound)
- {end} End of range, given as (row, col) or valid
- extmark id (whose position defines the bound)
+ {start} Start of range, given as 0-indexed (row, col) or
+ valid extmark id (whose position defines the
+ bound)
+ {end} End of range (inclusive), given as 0-indexed
+ (row, col) or valid extmark id (whose position
+ defines the bound)
{opts} Optional parameters. Keys:
• limit: Maximum number of marks to return
• details Whether to include the details dict
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 960148d506..7a53f17a78 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -499,8 +499,10 @@ CursorMoved After the cursor was moved in Normal or Visual
mode or to another window. Also when the text
of the cursor line has been changed, e.g. with
"x", "rx" or "p".
- Not triggered when there is typeahead or when
- an operator is pending.
+ Not triggered when there is typeahead, while
+ executing a script file, when an operator is
+ pending, or when moving to another window while
+ remaining at the same cursor position.
For an example see |match-parens|.
Note: Cannot be skipped with |:noautocmd|.
Careful: This is triggered very often, don't
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 70a465f636..6b46ac9cf2 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -153,7 +153,12 @@ CTRL-R {register} *c_CTRL-R* *c_<C-R>*
too.
When the result is a Float it's automatically
converted to a String.
- See |registers| about registers.
+ Note that when you only want to move the
+ cursor and not insert anything, you must make
+ sure the expression evaluates to an empty
+ string. E.g.: >
+ <C-R><C-R>=setcmdpos(2)[-1]<CR>
+< See |registers| about registers.
Implementation detail: When using the |expression| register
and invoking setcmdpos(), this sets the position before
inserting the resulting string. Use CTRL-R CTRL-R to set the
diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt
index 861aed4884..d1f26c8c81 100644
--- a/runtime/doc/deprecated.txt
+++ b/runtime/doc/deprecated.txt
@@ -55,6 +55,50 @@ Functions ~
without stopping the job. Use chanclose(id) to close
any socket.
+LSP Diagnostics ~
+
+For each of the functions below, use the corresponding function in
+|vim.diagnostic| instead (unless otherwise noted). For example, use
+|vim.diagnostic.get()| instead of |vim.lsp.diagnostic.get()|.
+
+*vim.lsp.diagnostic.clear()* Use |vim.diagnostic.hide()| instead.
+*vim.lsp.diagnostic.disable()*
+*vim.lsp.diagnostic.display()* Use |vim.diagnostic.show()| instead.
+*vim.lsp.diagnostic.enable()*
+*vim.lsp.diagnostic.get()*
+*vim.lsp.diagnostic.get_all()* Use |vim.diagnostic.get()| instead.
+*vim.lsp.diagnostic.get_count()* Use |vim.diagnostic.get()| instead.
+*vim.lsp.diagnostic.get_line_diagnostics()*
+ Use |vim.diagnostic.get()| instead.
+*vim.lsp.diagnostic.get_next()*
+*vim.lsp.diagnostic.get_next_pos()*
+*vim.lsp.diagnostic.get_prev()*
+*vim.lsp.diagnostic.get_prev_pos()*
+*vim.lsp.diagnostic.get_virtual_text_chunks_for_line()*
+ Use |vim.diagnostic.get_virt_text_chunks()| instead.
+*vim.lsp.diagnostic.goto_next()*
+*vim.lsp.diagnostic.goto_prev()*
+*vim.lsp.diagnostic.redraw()* Use |vim.diagnostic.show()| instead.
+*vim.lsp.diagnostic.reset()*
+*vim.lsp.diagnostic.save()* Use |vim.diagnostic.set()| instead.
+*vim.lsp.diagnostic.set_loclist()* Use |vim.diagnostic.setloclist()| instead.
+*vim.lsp.diagnostic.set_qflist()* Use |vim.diagnostic.setqflist()| instead.
+*vim.lsp.diagnostic.show_line_diagnostics()*
+*vim.lsp.diagnostic.show_position_diagnostics()*
+
+The following are deprecated without replacement. These functions are moved
+internally and are no longer exposed as part of the API. Instead, use
+|vim.diagnostic.config()| and |vim.diagnostic.show()|.
+
+*vim.lsp.diagnostic.set_signs()*
+*vim.lsp.diagnostic.set_underline()*
+*vim.lsp.diagnostic.set_virtual_text()*
+
+LSP Utility Functions ~
+
+*vim.lsp.util.set_qflist()* Use |setqflist()| instead.
+*vim.lsp.util.set_loclist()* Use |setloclist()| instead.
+
Lua ~
*vim.register_keystroke_callback()* Use |vim.on_key()| instead.
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
new file mode 100644
index 0000000000..f4975b187f
--- /dev/null
+++ b/runtime/doc/diagnostic.txt
@@ -0,0 +1,483 @@
+*diagnostic.txt* Diagnostics
+
+
+ NVIM REFERENCE MANUAL
+
+
+Diagnostic framework *vim.diagnostic*
+
+Nvim provides a framework for displaying errors or warnings from external
+tools, otherwise known as "diagnostics". These diagnostics can come from a
+variety of sources, such as linters or LSP servers. The diagnostic framework
+is an extension to existing error handling functionality such as the
+|quickfix| list.
+
+ Type |gO| to see the table of contents.
+
+==============================================================================
+QUICKSTART *diagnostic-quickstart*
+
+Anything that reports diagnostics is referred to below as a "diagnostic
+producer". Diagnostic producers need only follow a few simple steps to
+report diagnostics:
+
+1. Create a namespace |nvim_create_namespace()|. Note that the namespace must
+ have a name. Anonymous namespaces WILL NOT WORK.
+2. (Optional) Configure options for the diagnostic namespace
+ |vim.diagnostic.config()|.
+3. Generate diagnostics.
+4. Set the diagnostics for the buffer |vim.diagnostic.set()|.
+5. Repeat from step 3.
+
+Generally speaking, the API is split between functions meant to be used by
+diagnostic producers and those meant for diagnostic consumers (i.e. end users
+who want to read and view the diagnostics for a buffer). The APIs for
+producers require a {namespace} as their first argument, while those for
+consumers generally do not require a namespace (though often one may be
+optionally supplied). A good rule of thumb is that if a method is meant to
+modify the diagnostics for a buffer (e.g. |vim.diagnostic.set()|) then it
+requires a namespace.
+
+ *diagnostic-structure*
+A diagnostic is a Lua table with the following keys:
+
+ lnum: The starting line of the diagnostic
+ end_lnum: The final line of the diagnostic
+ col: The starting column of the diagnostic
+ end_col: The final column of the diagnostic
+ severity: The severity of the diagnostic |vim.diagnostic.severity|
+ message: The diagnostic text
+
+Diagnostics use the same indexing as the rest of the Nvim API (i.e. 0-based
+rows and columns). |api-indexing|
+
+ *vim.diagnostic.severity* *diagnostic-severity*
+The "severity" key in a diagnostic is one of the values defined in
+`vim.diagnostic.severity`:
+
+ vim.diagnostic.severity.ERROR
+ vim.diagnostic.severity.WARN
+ vim.diagnostic.severity.INFO
+ vim.diagnostic.severity.HINT
+
+Functions that take a severity as an optional parameter (e.g.
+|vim.diagnostic.get()|) accept one of two forms:
+
+1. A single |vim.diagnostic.severity| value: >
+
+ vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
+
+2. A table with a "min" or "max" key (or both): >
+
+ vim.diagnostic.get(0, { severity = {min=vim.diagnostic.severity.WARN})
+
+The latter form allows users to specify a range of severities.
+
+==============================================================================
+HIGHLIGHTS *diagnostic-highlights*
+
+All highlights defined for diagnostics begin with `Diagnostic` followed by
+the type of highlight (e.g., `Sign`, `Underline`, etc.) and the severity (e.g.
+`Error`, `Warn`, etc.)
+
+Sign, underline and virtual text highlights (by default) are linked to their
+corresponding default highlight.
+
+For example, the default highlighting for |hl-DiagnosticSignError| is linked
+to |hl-DiagnosticError|. To change the default (and therefore the linked
+highlights), use the |:highlight| command: >
+
+ highlight DiagnosticError guifg="BrightRed"
+<
+ *hl-DiagnosticError*
+DiagnosticError
+ Used as the base highlight group.
+ Other Diagnostic highlights link to this by default (except Underline)
+
+ *hl-DiagnosticWarn*
+DiagnosticWarn
+ Used as the base highlight group.
+ Other Diagnostic highlights link to this by default (except Underline)
+
+ *hl-DiagnosticInfo*
+DiagnosticInfo
+ Used as the base highlight group.
+ Other Diagnostic highlights link to this by default (except Underline)
+
+ *hl-DiagnosticHint*
+DiagnosticHint
+ Used as the base highlight group.
+ Other Diagnostic highlights link to this by default (except Underline)
+
+ *hl-DiagnosticVirtualTextError*
+DiagnosticVirtualTextError
+ Used for "Error" diagnostic virtual text.
+
+ *hl-DiagnosticVirtualTextWarn*
+DiagnosticVirtualTextWarn
+ Used for "Warn" diagnostic virtual text.
+
+ *hl-DiagnosticVirtualTextInfo*
+DiagnosticVirtualTextInfo
+ Used for "Info" diagnostic virtual text.
+
+ *hl-DiagnosticVirtualTextHint*
+DiagnosticVirtualTextHint
+ Used for "Hint" diagnostic virtual text.
+
+ *hl-DiagnosticUnderlineError*
+DiagnosticUnderlineError
+ Used to underline "Error" diagnostics.
+
+ *hl-DiagnosticUnderlineWarn*
+DiagnosticUnderlineWarn
+ Used to underline "Warn" diagnostics.
+
+ *hl-DiagnosticUnderlineInfo*
+DiagnosticUnderlineInfo
+ Used to underline "Info" diagnostics.
+
+ *hl-DiagnosticUnderlineHint*
+DiagnosticUnderlineHint
+ Used to underline "Hint" diagnostics.
+
+ *hl-DiagnosticFloatingError*
+DiagnosticFloatingError
+ Used to color "Error" diagnostic messages in diagnostics float.
+ See |vim.diagnostic.show_line_diagnostics()|
+
+ *hl-DiagnosticFloatingWarn*
+DiagnosticFloatingWarn
+ Used to color "Warn" diagnostic messages in diagnostics float.
+
+ *hl-DiagnosticFloatingInfo*
+DiagnosticFloatingInfo
+ Used to color "Info" diagnostic messages in diagnostics float.
+
+ *hl-DiagnosticFloatingHint*
+DiagnosticFloatingHint
+ Used to color "Hint" diagnostic messages in diagnostics float.
+
+ *hl-DiagnosticSignError*
+DiagnosticSignError
+ Used for "Error" signs in sign column.
+
+ *hl-DiagnosticSignWarn*
+DiagnosticSignWarn
+ Used for "Warn" signs in sign column.
+
+ *hl-DiagnosticSignInfo*
+DiagnosticSignInfo
+ Used for "Info" signs in sign column.
+
+ *hl-DiagnosticSignHint*
+DiagnosticSignHint
+ Used for "Hint" signs in sign column.
+
+==============================================================================
+SIGNS *diagnostic-signs*
+
+Signs are defined for each diagnostic severity. The default text for each sign
+is the first letter of the severity name (for example, "E" for ERROR). Signs
+can be customized using the following: >
+
+ sign define DiagnosticSignError text=E texthl=DiagnosticSignError linehl= numhl=
+ sign define DiagnosticSignWarning text=W texthl=DiagnosticSignWarning linehl= numhl=
+ sign define DiagnosticSignInformation text=I texthl=DiagnosticSignInformation linehl= numhl=
+ sign define DiagnosticSignHint text=H texthl=DiagnosticSignHint linehl= numhl=
+
+==============================================================================
+EVENTS *diagnostic-events*
+
+ *DiagnosticsChanged*
+DiagnosticsChanged After diagnostics have changed.
+
+Example: >
+ autocmd User DiagnosticsChanged lua vim.diagnostic.setqflist({open = false })
+<
+
+==============================================================================
+Lua module: vim.diagnostic *diagnostic-api*
+
+config({opts}, {namespace}) *vim.diagnostic.config()*
+ Configure diagnostic options globally or for a specific
+ diagnostic namespace.
+
+ Note:
+ Each of the configuration options below accepts one of the
+ following:
+ • `false` : Disable this feature
+ • `true` : Enable this feature, use default settings.
+ • `table` : Enable this feature with overrides.
+ • `function` : Function with signature (namespace, bufnr)
+ that returns any of the above.
+
+ Parameters: ~
+ {opts} table Configuration table with the following
+ keys:
+ • underline: (default true) Use underline for
+ diagnostics
+ • virtual_text: (default true) Use virtual
+ text for diagnostics
+ • signs: (default true) Use signs for
+ diagnostics
+ • update_in_insert: (default false) Update
+ diagnostics in Insert mode (if false,
+ diagnostics are updated on InsertLeave)
+ • severity_sort: (default false) Sort
+ diagnostics by severity. This affects the
+ order in which signs and virtual text are
+ displayed
+ {namespace} number|nil Update the options for the given
+ namespace. When omitted, update the global
+ diagnostic options.
+
+disable({bufnr}, {namespace}) *vim.diagnostic.disable()*
+ Disable diagnostics in the given buffer.
+
+ Parameters: ~
+ {bufnr} number|nil Buffer number. Defaults to the
+ current buffer.
+ {namespace} number|nil Only disable diagnostics for the
+ given namespace.
+
+enable({bufnr}, {namespace}) *vim.diagnostic.enable()*
+ Enable diagnostics in the given buffer.
+
+ Parameters: ~
+ {bufnr} number|nil Buffer number. Defaults to the
+ current buffer.
+ {namespace} number|nil Only enable diagnostics for the
+ given namespace.
+
+get({bufnr}, {opts}) *vim.diagnostic.get()*
+ Get current diagnostics.
+
+ Parameters: ~
+ {bufnr} number|nil Buffer number to get diagnistics from.
+ Use 0 for current buffer or nil for all buffers.
+ {opts} table|nil A table with the following keys:
+ • namespace: (number) Limit diagnostics to the
+ given namespace.
+ • lnum: (number) Limit diagnostics to the given
+ line number.
+ • severity: See |diagnostic-severity|.
+
+ Return: ~
+ table A list of diagnostic items |diagnostic-structure|.
+
+get_next({opts}) *vim.diagnostic.get_next()*
+ Get the next diagnostic closest to the cursor position.
+
+ Parameters: ~
+ {opts} table See |vim.diagnostic.goto_next()|
+
+ Return: ~
+ table Next diagnostic
+
+get_next_pos({opts}) *vim.diagnostic.get_next_pos()*
+ Return the position of the next diagnostic in the current
+ buffer.
+
+ Parameters: ~
+ {opts} table See |vim.diagnostic.goto_next()|
+
+ Return: ~
+ table Next diagnostic position as a (row, col) tuple.
+
+get_prev({opts}) *vim.diagnostic.get_prev()*
+ Get the previous diagnostic closest to the cursor position.
+
+ Parameters: ~
+ {opts} table See |vim.diagnostic.goto_next()|
+
+ Return: ~
+ table Previous diagnostic
+
+get_prev_pos({opts}) *vim.diagnostic.get_prev_pos()*
+ Return the position of the previous diagnostic in the current
+ buffer.
+
+ Parameters: ~
+ {opts} table See |vim.diagnostic.goto_next()|
+
+ Return: ~
+ table Previous diagnostic position as a (row, col) tuple.
+
+ *vim.diagnostic.get_virt_text_chunks()*
+get_virt_text_chunks({line_diags}, {opts})
+ Get virtual text chunks to display using
+ |nvim_buf_set_extmark()|.
+
+ Parameters: ~
+ {line_diags} table The diagnostics associated with the
+ line.
+ {opts} table|nil Configuration table with the
+ following keys:
+ • prefix: (string) Prefix to display before
+ virtual text on line.
+ • spacing: (number) Number of spaces to
+ insert before virtual text.
+
+ Return: ~
+ an array of [text, hl_group] arrays. This can be passed
+ directly to the {virt_text} option of
+ |nvim_buf_set_extmark()|.
+
+goto_next({opts}) *vim.diagnostic.goto_next()*
+ Move to the next diagnostic.
+
+ Parameters: ~
+ {opts} table|nil Configuration table with the following
+ keys:
+ • namespace: (number) Only consider diagnostics
+ from the given namespace.
+ • cursor_position: (cursor position) Cursor
+ position as a (row, col) tuple. See
+ |nvim_win_get_cursor()|. Defaults to the current
+ cursor position.
+ • wrap: (boolean, default true) Whether to loop
+ around file or not. Similar to 'wrapscan'.
+ • severity: See |diagnostic-severity|.
+ • enable_popup: (boolean, default true) Call
+ |vim.diagnostic.show_line_diagnostics()| on
+ jump.
+ • popup_opts: (table) Table to pass as {opts}
+ parameter to
+ |vim.diagnostic.show_line_diagnostics()|
+ • win_id: (number, default 0) Window ID
+
+goto_prev({opts}) *vim.diagnostic.goto_prev()*
+ Move to the previous diagnostic in the current buffer.
+
+ Parameters: ~
+ {opts} table See |vim.diagnostic.goto_next()|
+
+hide({namespace}, {bufnr}) *vim.diagnostic.hide()*
+ Hide currently displayed diagnostics.
+
+ This only clears the decorations displayed in the buffer.
+ Diagnostics can be redisplayed with |vim.diagnostic.show()|.
+ To completely remove diagnostics, use
+ |vim.diagnostic.reset()|.
+
+ To hide diagnostics and prevent them from re-displaying, use
+ |vim.diagnostic.disable()|.
+
+ Parameters: ~
+ {namespace} number The diagnostic namespace
+ {bufnr} number|nil Buffer number. Defaults to the
+ current buffer.
+
+reset({namespace}, {bufnr}) *vim.diagnostic.reset()*
+ Remove all diagnostics from the given namespace.
+
+ Unlike |vim.diagnostic.hide()|, this function removes all
+ saved diagnostics. They cannot be redisplayed using
+ |vim.diagnostic.show()|. To simply remove diagnostic
+ decorations in a way that they can be re-displayed, use
+ |vim.diagnostic.hide()|.
+
+ Parameters: ~
+ {namespace} number
+ {bufnr} number|nil Remove diagnostics for the given
+ buffer. When omitted, diagnostics are removed
+ for all buffers.
+
+set({namespace}, {bufnr}, {diagnostics}, {opts}) *vim.diagnostic.set()*
+ Set diagnostics for the given namespace and buffer.
+
+ Parameters: ~
+ {namespace} number The diagnostic namespace
+ {bufnr} number Buffer number
+ {diagnostics} table A list of diagnostic items
+ |diagnostic-structure|
+ {opts} table|nil Display options to pass to
+ |vim.diagnostic.show()|
+
+setloclist({opts}) *vim.diagnostic.setloclist()*
+ Add buffer diagnostics to the location list.
+
+ Parameters: ~
+ {opts} table|nil Configuration table with the following
+ keys:
+ • namespace: (number) Only add diagnostics from
+ the given namespace.
+ • winnr: (number, default 0) Window number to set
+ location list for.
+ • open: (boolean, default true) Open the location
+ list after setting.
+ • title: (string) Title of the location list.
+ Defaults to "Diagnostics".
+ • severity: See |diagnostic-severity|.
+
+setqflist({opts}) *vim.diagnostic.setqflist()*
+ Add all diagnostics to the quickfix list.
+
+ Parameters: ~
+ {opts} table|nil Configuration table with the following
+ keys:
+ • namespace: (number) Only add diagnostics from
+ the given namespace.
+ • open: (boolean, default true) Open quickfix list
+ after setting.
+ • title: (string) Title of quickfix list. Defaults
+ to "Diagnostics".
+ • severity: See |diagnostic-severity|.
+
+ *vim.diagnostic.show()*
+show({namespace}, {bufnr}, {diagnostics}, {opts})
+ Display diagnostics for the given namespace and buffer.
+
+ Parameters: ~
+ {namespace} number Diagnostic namespace
+ {bufnr} number|nil Buffer number. Defaults to the
+ current buffer.
+ {diagnostics} table|nil The diagnostics to display. When
+ omitted, use the saved diagnostics for the
+ given namespace and buffer. This can be
+ used to display a list of diagnostics
+ without saving them or to display only a
+ subset of diagnostics.
+ {opts} table|nil Display options. See
+ |vim.diagnostic.config()|.
+
+ *vim.diagnostic.show_line_diagnostics()*
+show_line_diagnostics({opts}, {bufnr}, {lnum})
+ Open a floating window with the diagnostics from the given
+ line.
+
+ Parameters: ~
+ {opts} table Configuration table. See
+ |vim.diagnostic.show_position_diagnostics()|.
+ {bufnr} number|nil Buffer number. Defaults to the current
+ buffer.
+ {lnum} number|nil Line number. Defaults to line number
+ of cursor.
+
+ Return: ~
+ A ({popup_bufnr}, {win_id}) tuple
+
+ *vim.diagnostic.show_position_diagnostics()*
+show_position_diagnostics({opts}, {bufnr}, {position})
+ Open a floating window with the diagnostics at the given
+ position.
+
+ Parameters: ~
+ {opts} table|nil Configuration table with the same
+ keys as |vim.lsp.util.open_floatin_preview()|
+ in addition to the following:
+ • namespace: (number) Limit diagnostics to the
+ given namespace
+ • severity: See |diagnostic-severity|.
+ • show_header: (boolean, default true) Show
+ "Diagnostics:" header
+ {bufnr} number|nil Buffer number. Defaults to the
+ current buffer.
+ {position} table|nil The (0,0)-indexed position. Defaults
+ to the current cursor position.
+
+ Return: ~
+ A ({popup_bufnr}, {win_id}) tuple
+
+ vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 5d889983e3..99e48e602b 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -14,18 +14,17 @@ Using expressions is introduced in chapter 41 of the user manual |usr_41.txt|.
1. Variables *variables*
1.1 Variable types ~
- *E712*
-There are six types of variables:
+ *E712* *E896* *E897* *E899*
+There are seven types of variables:
*Number* *Integer*
Number A 32 or 64 bit signed number. |expr-number|
The number of bits is available in |v:numbersize|.
- Examples: -123 0x10 0177 0b1011
+ Examples: -123 0x10 0177 0o177 0b1011
Float A floating point number. |floating-point-format| *Float*
Examples: 123.456 1.15e-6 -1.1e3
- *E928*
String A NUL terminated string of 8-bit unsigned characters (bytes).
|expr-string| Examples: "ab\txx\"--" 'x-z''a,c'
@@ -35,7 +34,7 @@ Funcref A reference to a function |Funcref|.
like a Partial.
Example: function("Callback", [arg], myDict)
-List An ordered sequence of items |List|.
+List An ordered sequence of items, see |List| for details.
Example: [1, 2, ['a', 'b']]
Dictionary An associative, unordered array: Each entry has a key and a
@@ -44,6 +43,11 @@ Dictionary An associative, unordered array: Each entry has a key and a
{'blue': "#0000ff", 'red': "#ff0000"}
#{blue: "#0000ff", red: "#ff0000"}
+Blob Binary Large Object. Stores any sequence of bytes. See |Blob|
+ for details.
+ Example: 0zFF00ED015DAF
+ 0z is an empty Blob.
+
The Number and String types are converted automatically, depending on how they
are used.
@@ -54,14 +58,15 @@ the Number. Examples:
Number -1 --> String "-1" ~
*octal*
Conversion from a String to a Number is done by converting the first digits to
-a number. Hexadecimal "0xf9", Octal "017", and Binary "0b10" numbers are
-recognized. If the String doesn't start with digits, the result is zero.
-Examples:
+a number. Hexadecimal "0xf9", Octal "017" or "0o17", and Binary "0b10"
+numbers are recognized. If the String doesn't start with digits, the result
+is zero. Examples:
String "456" --> Number 456 ~
String "6bar" --> Number 6 ~
String "foo" --> Number 0 ~
String "0xf1" --> Number 241 ~
String "0100" --> Number 64 ~
+ String "0o100" --> Number 64 ~
String "0b101" --> Number 5 ~
String "-8" --> Number -8 ~
String "+8" --> Number 0 ~
@@ -97,6 +102,7 @@ Note that " " and "0" are also non-empty strings, thus considered to be TRUE.
A List, Dictionary or Float is not a Number or String, thus evaluate to FALSE.
*E745* *E728* *E703* *E729* *E730* *E731*
+ *E974* *E975* *E976*
|List|, |Dictionary|, |Funcref|, and |Blob| types are not automatically
converted.
@@ -366,8 +372,8 @@ Changing the order of items in a list: >
For loop ~
-The |:for| loop executes commands for each item in a list. A variable is set
-to each item in the list in sequence. Example: >
+The |:for| loop executes commands for each item in a |List| or |Blob|.
+A variable is set to each item in the sequence. Example with a List: >
:for item in mylist
: call Doit(item)
:endfor
@@ -400,6 +406,8 @@ It is also possible to put remaining items in a List variable: >
: endif
:endfor
+For a Blob one byte at a time is used.
+
List functions ~
*E714*
@@ -594,7 +602,137 @@ Functions that can be used with a Dictionary: >
:call map(dict, '">> " . v:val') " prepend ">> " to each item
-1.5 More about variables ~
+1.5 Blobs ~
+ *blob* *Blob* *Blobs* *E978*
+A Blob is a binary object. It can be used to read an image from a file and
+send it over a channel, for example.
+
+A Blob mostly behaves like a |List| of numbers, where each number has the
+value of an 8-bit byte, from 0 to 255.
+
+
+Blob creation ~
+
+A Blob can be created with a |blob-literal|: >
+ :let b = 0zFF00ED015DAF
+Dots can be inserted between bytes (pair of hex characters) for readability,
+they don't change the value: >
+ :let b = 0zFF00.ED01.5DAF
+
+A blob can be read from a file with |readfile()| passing the {type} argument
+set to "B", for example: >
+ :let b = readfile('image.png', 'B')
+
+
+Blob index ~
+ *blob-index* *E979*
+A byte in the Blob can be accessed by putting the index in square brackets
+after the Blob. Indexes are zero-based, thus the first byte has index zero. >
+ :let myblob = 0z00112233
+ :let byte = myblob[0] " get the first byte: 0x00
+ :let byte = myblob[2] " get the third byte: 0x22
+
+A negative index is counted from the end. Index -1 refers to the last byte in
+the Blob, -2 to the last but one byte, etc. >
+ :let last = myblob[-1] " get the last byte: 0x33
+
+To avoid an error for an invalid index use the |get()| function. When an item
+is not available it returns -1 or the default value you specify: >
+ :echo get(myblob, idx)
+ :echo get(myblob, idx, 999)
+
+
+Blob iteration ~
+
+The |:for| loop executes commands for each byte of a Blob. The loop variable is
+set to each byte in the Blob. Example: >
+ :for byte in 0z112233
+ : call Doit(byte)
+ :endfor
+This calls Doit() with 0x11, 0x22 and 0x33.
+
+
+Blob concatenation ~
+
+Two blobs can be concatenated with the "+" operator: >
+ :let longblob = myblob + 0z4455
+ :let myblob += 0z6677
+
+To change a blob in-place see |blob-modification| below.
+
+
+Part of a blob ~
+
+A part of the Blob can be obtained by specifying the first and last index,
+separated by a colon in square brackets: >
+ :let myblob = 0z00112233
+ :let shortblob = myblob[1:2] " get 0z1122
+ :let shortblob = myblob[2:-1] " get 0z2233
+
+Omitting the first index is similar to zero. Omitting the last index is
+similar to -1. >
+ :let endblob = myblob[2:] " from item 2 to the end: 0z2233
+ :let shortblob = myblob[2:2] " Blob with one byte: 0z22
+ :let otherblob = myblob[:] " make a copy of the Blob
+
+If the first index is beyond the last byte of the Blob or the second byte is
+before the first byte, the result is an empty Blob. There is no error
+message.
+
+If the second index is equal to or greater than the length of the Blob the
+length minus one is used: >
+ :echo myblob[2:8] " result: 0z2233
+
+
+Blob modification ~
+ *blob-modification*
+To change a specific byte of a blob use |:let| this way: >
+ :let blob[4] = 0x44
+
+When the index is just one beyond the end of the Blob, it is appended. Any
+higher index is an error.
+
+To change a sequence of bytes the [:] notation can be used: >
+ let blob[1:3] = 0z445566
+The length of the replaced bytes must be exactly the same as the value
+provided. *E972*
+
+To change part of a blob you can specify the first and last byte to be
+modified. The value must at least have the number of bytes in the range: >
+ :let blob[3:5] = [3, 4, 5]
+
+You can also use the functions |add()|, |remove()| and |insert()|.
+
+
+Blob identity ~
+
+Blobs can be compared for equality: >
+ if blob == 0z001122
+And for equal identity: >
+ if blob is otherblob
+< *blob-identity* *E977*
+When variable "aa" is a Blob and you assign it to another variable "bb", both
+variables refer to the same Blob. Then the "is" operator returns true.
+
+When making a copy using [:] or |copy()| the values are the same, but the
+identity is different: >
+ :let blob = 0z112233
+ :let blob2 = blob
+ :echo blob == blob2
+< 1 >
+ :echo blob is blob2
+< 1 >
+ :let blob3 = blob[:]
+ :echo blob == blob3
+< 1 >
+ :echo blob is blob3
+< 0
+
+Making a copy of a Blob is done with the |copy()| function. Using [:] also
+works, as explained above.
+
+
+1.6 More about variables ~
*more-variables*
If you need to know the type of a variable or expression, use the |type()|
function.
@@ -645,8 +783,9 @@ Expression syntax summary, from least to most significant:
etc. As above, append ? for ignoring case, # for
matching case
- expr5 is expr5 same |List| instance
- expr5 isnot expr5 different |List| instance
+ expr5 is expr5 same |List|, |Dictionary| or |Blob| instance
+ expr5 isnot expr5 different |List|, |Dictionary| or |Blob|
+ instance
|expr5| expr6
expr6 + expr6 ... number addition, list or blob concatenation
@@ -817,12 +956,12 @@ Dictionary and arguments, use |get()| to get the function name: >
if get(Part1, 'name') == get(Part2, 'name')
" Part1 and Part2 refer to the same function
-When using "is" or "isnot" with a |List| or a |Dictionary| this checks if the
-expressions are referring to the same |List| or |Dictionary| instance. A copy
-of a |List| is different from the original |List|. When using "is" without
-a |List| or a |Dictionary| it is equivalent to using "equal", using "isnot"
-equivalent to using "not equal". Except that a different type means the
-values are different: >
+Using "is" or "isnot" with a |List|, |Dictionary| or |Blob| checks whether
+the expressions are referring to the same |List|, |Dictionary| or |Blob|
+instance. A copy of a |List| is different from the original |List|. When
+using "is" without a |List|, |Dictionary| or |Blob|, it is equivalent to
+using "equal", using "isnot" is equivalent to using "not equal". Except that
+a different type means the values are different: >
echo 4 == '4'
1
echo 4 is '4'
@@ -1012,6 +1151,12 @@ just above. Also see |sublist| below. Examples: >
:let l = mylist[4:4] " List with one item
:let l = mylist[:] " shallow copy of a List
+If expr8 is a |Blob| this results in a new |Blob| with the bytes in the
+indexes expr1a and expr1b, inclusive. Examples: >
+ :let b = 0zDEADBEEF
+ :let bs = b[1:2] " 0zADBE
+ :let bs = b[] " copy of 0zDEADBEEF
+
Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an
error.
@@ -1085,7 +1230,7 @@ number number constant *expr-number*
*hex-number* *octal-number* *binary-number*
Decimal, Hexadecimal (starting with 0x or 0X), Binary (starting with 0b or 0B)
-and Octal (starting with 0).
+and Octal (starting with 0, 0o or 0O).
*floating-point-format*
Floating point numbers can be written in two forms:
@@ -1180,6 +1325,14 @@ encodings. Use "\u00ff" to store character 255 correctly as UTF-8.
Note that "\000" and "\x00" force the end of the string.
+blob-literal *blob-literal* *E973*
+------------
+
+Hexadecimal starting with 0z or 0Z, with an arbitrary number of bytes.
+The sequence must be an even number of hex characters. Example: >
+ :let b = 0zFF00ED015DAF
+
+
literal-string *literal-string* *E115*
---------------
'string' string constant *expr-'*
@@ -1317,7 +1470,17 @@ The lambda expression is also useful for jobs and timers: >
Handler called
Handler called
-Note how execute() is used to execute an Ex command. That's ugly though.
+Note that it is possible to cause memory to be used and not freed if the
+closure is referenced by the context it depends on: >
+ function Function()
+ let x = 0
+ let F = {-> x}
+ endfunction
+The closure uses "x" from the function scope, and "F" in that same scope
+refers to the closure. This cycle results in the memory not being freed.
+Recommendation: don't do this.
+
+Notice how execute() is used to execute an Ex command. That's ugly though.
Lambda expressions have internal names like '<lambda>42'. If you get an error
@@ -1722,7 +1885,8 @@ v:fcs_choice What should happen after a |FileChangedShell| event was
Vim behaves like it is empty, there is no warning message.
*v:fname* *fname-variable*
-v:fname The file name set by 'includeexpr'. Empty otherwise.
+v:fname When evaluating 'includeexpr': the file name that was
+ detected. Empty otherwise.
*v:fname_in* *fname_in-variable*
v:fname_in The name of the input file. Valid while evaluating:
@@ -1996,19 +2160,21 @@ v:swapcommand Normal mode command to be executed after a file has been
For ":edit +cmd file" the value is ":cmd\r".
*v:t_TYPE* *v:t_bool* *t_bool-variable*
-v:t_bool Value of Boolean type. Read-only. See: |type()|
+v:t_bool Value of |Boolean| type. Read-only. See: |type()|
*v:t_dict* *t_dict-variable*
-v:t_dict Value of Dictionary type. Read-only. See: |type()|
+v:t_dict Value of |Dictionary| type. Read-only. See: |type()|
*v:t_float* *t_float-variable*
-v:t_float Value of Float type. Read-only. See: |type()|
+v:t_float Value of |Float| type. Read-only. See: |type()|
*v:t_func* *t_func-variable*
-v:t_func Value of Funcref type. Read-only. See: |type()|
+v:t_func Value of |Funcref| type. Read-only. See: |type()|
*v:t_list* *t_list-variable*
-v:t_list Value of List type. Read-only. See: |type()|
+v:t_list Value of |List| type. Read-only. See: |type()|
*v:t_number* *t_number-variable*
-v:t_number Value of Number type. Read-only. See: |type()|
+v:t_number Value of |Number| type. Read-only. See: |type()|
*v:t_string* *t_string-variable*
-v:t_string Value of String type. Read-only. See: |type()|
+v:t_string Value of |String| type. Read-only. See: |type()|
+ *v:t_blob* *t_blob-variable*
+v:t_blob Value of |Blob| type. Read-only. See: |type()|
*v:termresponse* *termresponse-variable*
v:termresponse The escape sequence returned by the terminal for the DA
@@ -2092,7 +2258,7 @@ USAGE RESULT DESCRIPTION ~
abs({expr}) Float or Number absolute value of {expr}
acos({expr}) Float arc cosine of {expr}
-add({list}, {item}) List append {item} to |List| {list}
+add({object}, {item}) List/Blob append {item} to {object}
and({expr}, {expr}) Number bitwise AND
api_info() Dict api metadata
append({lnum}, {string}) Number append {string} below line {lnum}
@@ -2179,8 +2345,8 @@ cursor({list}) Number move cursor to position in {list}
debugbreak({pid}) Number interrupt process being debugged
deepcopy({expr} [, {noref}]) any make a full copy of {expr}
delete({fname} [, {flags}]) Number delete the file or directory {fname}
-deletebufline({expr}, {first}[, {last}])
- Number delete lines from buffer {expr}
+deletebufline({buf}, {first}[, {last}])
+ Number delete lines from buffer {buf}
dictwatcheradd({dict}, {pattern}, {callback})
Start watching a dictionary
dictwatcherdel({dict}, {pattern}, {callback})
@@ -2232,12 +2398,12 @@ garbagecollect([{atexit}]) none free memory, breaking cyclic references
get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def}
get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def}
get({func}, {what}) any get property of funcref/partial {func}
-getbufinfo([{expr}]) List information about buffers
-getbufline({expr}, {lnum} [, {end}])
- List lines {lnum} to {end} of buffer {expr}
-getbufvar({expr}, {varname} [, {def}])
- any variable {varname} in buffer {expr}
-getchangelist({expr}) List list of change list items
+getbufinfo([{buf}]) List information about buffers
+getbufline({buf}, {lnum} [, {end}])
+ List lines {lnum} to {end} of buffer {buf}
+getbufvar({buf}, {varname} [, {def}])
+ any variable {varname} in buffer {buf}
+getchangelist([{buf}]) List list of change list items
getchar([expr]) Number or String
get one character from the user
getcharmod() Number modifiers for the last typed character
@@ -2263,7 +2429,7 @@ getline({lnum}) String line {lnum} of current buffer
getline({lnum}, {end}) List lines {lnum} to {end} of current buffer
getloclist({nr}) List list of location list items
getloclist({nr}, {what}) Dict get specific location list properties
-getmarklist([{expr}]) List list of global/local marks
+getmarklist([{buf}]) List list of global/local marks
getmatches([{win}]) List list of current matches
getpid() Number process ID of Vim
getpos({expr}) List position of cursor, mark, etc.
@@ -2304,8 +2470,8 @@ hlID({name}) Number syntax ID of highlight group {name}
hostname() String name of the machine Vim is running on
iconv({expr}, {from}, {to}) String convert encoding of {expr}
indent({lnum}) Number indent of line {lnum}
-index({list}, {expr} [, {start} [, {ic}]])
- Number index in {list} where {expr} appears
+index({object}, {expr} [, {start} [, {ic}]])
+ Number index in {object} where {expr} appears
input({prompt} [, {text} [, {completion}]])
String get input from the user
inputlist({textlist}) Number let the user pick from a choice list
@@ -2313,8 +2479,8 @@ inputrestore() Number restore typeahead
inputsave() Number save and clear typeahead
inputsecret({prompt} [, {text}])
String like input() but hiding the text
-insert({list}, {item} [, {idx}])
- List insert {item} in {list} [before {idx}]
+insert({object}, {item} [, {idx}])
+ List insert {item} in {object} [before {idx}]
interrupt() none interrupt script execution
invert({expr}) Number bitwise invert
isdirectory({directory}) Number |TRUE| if {directory} is a directory
@@ -2373,8 +2539,8 @@ min({expr}) Number minimum value of items in {expr}
mkdir({name} [, {path} [, {prot}]])
Number create directory {name}
mode([expr]) String current editing mode
-msgpackdump({list}) List dump a list of objects to msgpack
-msgpackparse({list}) List parse msgpack to a list of objects
+msgpackdump({list} [, {type}]) List/Blob dump objects to msgpack
+msgpackparse({data}) List parse msgpack to a list of objects
nextnonblank({lnum}) Number line nr of non-blank line >= {lnum}
nr2char({expr}[, {utf8}]) String single char with ASCII/UTF8 value {expr}
nvim_...({args}...) any call nvim |api| functions
@@ -2396,7 +2562,7 @@ pyxeval({expr}) any evaluate |python_x| expression
range({expr} [, {max} [, {stride}]])
List items from {expr} to {max}
readdir({dir} [, {expr}]) List file names in {dir} selected by {expr}
-readfile({fname} [, {binary} [, {max}]])
+readfile({fname} [, {type} [, {max}]])
List get list of lines from file {fname}
reg_executing() String get the executing register name
reg_recording() String get the recording register name
@@ -2413,7 +2579,10 @@ remote_read({serverid} [, {timeout}])
remote_send({server}, {string} [, {idvar}])
String send key sequence
remote_startserver({name}) none become server {name}
-remove({list}, {idx} [, {end}]) any remove items {idx}-{end} from {list}
+remove({list}, {idx} [, {end}]) any/List
+ remove items {idx}-{end} from {list}
+remove({blob}, {idx} [, {end}]) Number/Blob
+ remove bytes {idx}-{end} from {blob}
remove({dict}, {key}) any remove entry {key} from {dict}
rename({from}, {to}) Number rename (move) file from {from} to {to}
repeat({expr}, {count}) String repeat {expr} {count} times
@@ -2447,7 +2616,7 @@ serverlist() String get a list of available servers
setbufline( {expr}, {lnum}, {line})
Number set line {lnum} to {line} in buffer
{expr}
-setbufvar({expr}, {varname}, {val}) set {varname} in buffer {expr} to {val}
+setbufvar({buf}, {varname}, {val}) set {varname} in buffer {buf} to {val}
setcharsearch({dict}) Dict set character search from {dict}
setcmdpos({pos}) Number set cursor position in command-line
setenv({name}, {val}) none set environment variable
@@ -2477,11 +2646,11 @@ shiftwidth([{col}]) Number effective value of 'shiftwidth'
sign_define({name} [, {dict}]) Number define or update a sign
sign_define({list}) List define or update a list of signs
sign_getdefined([{name}]) List get a list of defined signs
-sign_getplaced([{expr} [, {dict}]])
+sign_getplaced([{buf} [, {dict}]])
List get a list of placed signs
-sign_jump({id}, {group}, {expr})
+sign_jump({id}, {group}, {buf})
Number jump to a sign
-sign_place({id}, {group}, {name}, {expr} [, {dict}])
+sign_place({id}, {group}, {name}, {buf} [, {dict}])
Number place a sign
sign_placelist({list}) List place a list of signs
sign_undefine([{name}]) Number undefine a sign
@@ -2505,10 +2674,11 @@ split({expr} [, {pat} [, {keepempty}]])
sqrt({expr}) Float square root of {expr}
stdioopen({dict}) Number open stdio in a headless instance.
stdpath({what}) String/List returns the standard path(s) for {what}
-str2float({expr}) Float convert String to Float
+str2float({expr} [, {quoted}]) Float convert String to Float
str2list({expr} [, {utf8}]) List convert each character of {expr} to
ASCII/UTF8 value
-str2nr({expr} [, {base}]) Number convert String to Number
+str2nr({expr} [, {base} [, {quoted}]])
+ Number convert String to Number
strchars({expr} [, {skipcc}]) Number character length of the String {expr}
strcharpart({str}, {start} [, {len}])
String {len} characters of {str} at
@@ -2534,7 +2704,7 @@ submatch({nr} [, {list}]) String or List
substitute({expr}, {pat}, {sub}, {flags})
String all {pat} in {expr} replaced with {sub}
swapinfo({fname}) Dict information about swap file {fname}
-swapname({expr}) String swap file of buffer {expr}
+swapname({buf}) String swap file of buffer {buf}
synID({lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col}
synIDattr({synID}, {what} [, {mode}])
String attribute {what} of syntax ID {synID}
@@ -2600,8 +2770,8 @@ winrestview({dict}) none restore view of current window
winsaveview() Dict save view of current window
winwidth({nr}) Number width of window {nr}
wordcount() Dict get byte/char/word statistics
-writefile({list}, {fname} [, {flags}])
- Number write list of lines to file {fname}
+writefile({object}, {fname} [, {flags}])
+ Number write |Blob| or |List| of lines to file
xor({expr}, {expr}) Number bitwise XOR
@@ -2635,13 +2805,14 @@ acos({expr}) *acos()*
Can also be used as a |method|: >
Compute()->acos()
-add({list}, {expr}) *add()*
- Append the item {expr} to |List| {list}. Returns the
- resulting |List|. Examples: >
+add({object}, {expr}) *add()*
+ Append the item {expr} to |List| or |Blob| {object}. Returns
+ the resulting |List| or |Blob|. Examples: >
:let alist = add([1, 2, 3], item)
:call add(mylist, "woodstock")
< Note that when {expr} is a |List| it is appended as a single
item. Use |extend()| to concatenate |Lists|.
+ When {object} is a |Blob| then {expr} must be a number.
Use |insert()| to add an item at another position.
Can also be used as a |method|: >
@@ -2667,6 +2838,7 @@ append({lnum}, {text}) *append()*
Otherwise append {text} as one text line below line {lnum} in
the current buffer.
{lnum} can be zero to insert a line before the first one.
+ {lnum} is used like with |getline()|.
Returns 1 for failure ({lnum} out of range or out of memory),
0 for success. Example: >
:let failed = append(line('$'), "# THE END")
@@ -2675,13 +2847,13 @@ append({lnum}, {text}) *append()*
< Can also be used as a |method| after a List: >
mylist->append(lnum)
-appendbufline({expr}, {lnum}, {text}) *appendbufline()*
+appendbufline({buf}, {lnum}, {text}) *appendbufline()*
Like |append()| but append the text in buffer {expr}.
This function works only for loaded buffers. First call
|bufload()| if needed.
- For the use of {expr}, see |bufname()|.
+ For the use of {buf}, see |bufname()|.
{lnum} is used like with |append()|. Note that using |line()|
would use the current buffer, not the one appending to.
@@ -2689,7 +2861,7 @@ appendbufline({expr}, {lnum}, {text}) *appendbufline()*
On success 0 is returned, on failure 1 is returned.
- If {expr} is not a valid buffer or {lnum} is not valid, an
+ If {buf} is not a valid buffer or {lnum} is not valid, an
error message is given. Example: >
:let failed = appendbufline(13, 0, "# THE START")
<
@@ -2809,7 +2981,7 @@ browsedir({title}, {initdir})
browsing is not possible, an empty string is returned.
bufadd({name}) *bufadd()*
- Add a buffer to the buffer list with {name}.
+ Add a buffer to the buffer list with String {name}.
If a buffer for file {name} already exists, return that buffer
number. Otherwise return the buffer number of the newly
created buffer. When {name} is an empty string then a new
@@ -2818,13 +2990,13 @@ bufadd({name}) *bufadd()*
< Can also be used as a |method|: >
let bufnr = 'somename'->bufadd()
-bufexists({expr}) *bufexists()*
+bufexists({buf}) *bufexists()*
The result is a Number, which is |TRUE| if a buffer called
- {expr} exists.
- If the {expr} argument is a number, buffer numbers are used.
+ {buf} exists.
+ If the {buf} argument is a number, buffer numbers are used.
Number zero is the alternate buffer for the current window.
- If the {expr} argument is a string it must match a buffer name
+ If the {buf} argument is a string it must match a buffer name
exactly. The name can be:
- Relative to the current directory.
- A full path.
@@ -2843,41 +3015,42 @@ bufexists({expr}) *bufexists()*
Can also be used as a |method|: >
let exists = 'somename'->bufexists()
-buflisted({expr}) *buflisted()*
+buflisted({buf}) *buflisted()*
The result is a Number, which is |TRUE| if a buffer called
- {expr} exists and is listed (has the 'buflisted' option set).
- The {expr} argument is used like with |bufexists()|.
+ {buf} exists and is listed (has the 'buflisted' option set).
+ The {buf} argument is used like with |bufexists()|.
Can also be used as a |method|: >
let listed = 'somename'->buflisted()
-bufload({expr}) *bufload()*
- Ensure the buffer {expr} is loaded. When the buffer name
+bufload({buf}) *bufload()*
+ Ensure the buffer {buf} is loaded. When the buffer name
refers to an existing file then the file is read. Otherwise
the buffer will be empty. If the buffer was already loaded
then there is no change.
If there is an existing swap file for the file of the buffer,
there will be no dialog, the buffer will be loaded anyway.
- The {expr} argument is used like with |bufexists()|.
+ The {buf} argument is used like with |bufexists()|.
Can also be used as a |method|: >
eval 'somename'->bufload()
-bufloaded({expr}) *bufloaded()*
+bufloaded({buf}) *bufloaded()*
The result is a Number, which is |TRUE| if a buffer called
- {expr} exists and is loaded (shown in a window or hidden).
- The {expr} argument is used like with |bufexists()|.
+ {buf} exists and is loaded (shown in a window or hidden).
+ The {buf} argument is used like with |bufexists()|.
Can also be used as a |method|: >
let loaded = 'somename'->bufloaded()
-bufname([{expr}]) *bufname()*
- The result is the name of a buffer, as it is displayed by the
- ":ls" command.
- If {expr} is omitted the current buffer is used.
- If {expr} is a Number, that buffer number's name is given.
+bufname([{buf}]) *bufname()*
+ The result is the name of a buffer. Mostly as it is displayed
+ by the `:ls` command, but not using special names such as
+ "[No Name]".
+ If {buf} is omitted the current buffer is used.
+ If {buf} is a Number, that buffer number's name is given.
Number zero is the alternate buffer for the current window.
- If {expr} is a String, it is used as a |file-pattern| to match
+ If {buf} is a String, it is used as a |file-pattern| to match
with the buffer names. This is always done like 'magic' is
set and 'cpoptions' is empty. When there is more than one
match an empty string is returned.
@@ -2890,7 +3063,7 @@ bufname([{expr}]) *bufname()*
Listed buffers are found first. If there is a single match
with a listed buffer, that one is returned. Next unlisted
buffers are searched for.
- If the {expr} is a String, but you want to use it as a buffer
+ If the {buf} is a String, but you want to use it as a buffer
number, force it to be a Number by adding zero to it: >
:echo bufname("3" + 0)
< Can also be used as a |method|: >
@@ -2904,9 +3077,9 @@ bufname([{expr}]) *bufname()*
bufname("file2") name of buffer where "file2" matches.
*bufnr()*
-bufnr([{expr} [, {create}]])
+bufnr([{buf} [, {create}]])
The result is the number of a buffer, as it is displayed by
- the ":ls" command. For the use of {expr}, see |bufname()|
+ the `:ls` command. For the use of {buf}, see |bufname()|
above.
If the buffer doesn't exist, -1 is returned. Or, if the
{create} argument is present and TRUE, a new, unlisted,
@@ -2921,10 +3094,10 @@ bufnr([{expr} [, {create}]])
Can also be used as a |method|: >
echo bufref->bufnr()
-bufwinid({expr}) *bufwinid()*
+bufwinid({buf}) *bufwinid()*
The result is a Number, which is the |window-ID| of the first
- window associated with buffer {expr}. For the use of {expr},
- see |bufname()| above. If buffer {expr} doesn't exist or
+ window associated with buffer {buf}. For the use of {buf},
+ see |bufname()| above. If buffer {buf} doesn't exist or
there is no such window, -1 is returned. Example: >
echo "A window containing buffer 1 is " . (bufwinid(1))
@@ -2934,10 +3107,10 @@ bufwinid({expr}) *bufwinid()*
Can also be used as a |method|: >
FindBuffer()->bufwinid()
-bufwinnr({expr}) *bufwinnr()*
+bufwinnr({buf}) *bufwinnr()*
Like |bufwinid()| but return the window number instead of the
|window-ID|.
- If buffer {expr} doesn't exist or there is no such window, -1
+ If buffer {buf} doesn't exist or there is no such window, -1
is returned. Example: >
echo "A window containing buffer 1 is " . (bufwinnr(1))
@@ -2960,7 +3133,7 @@ byte2line({byte}) *byte2line()*
GetOffset()->byte2line()
byteidx({expr}, {nr}) *byteidx()*
- Return byte index of the {nr}'th character in the string
+ Return byte index of the {nr}'th character in the String
{expr}. Use zero for the first character, it then returns
zero.
If there are no multibyte characters the returned value is
@@ -3052,8 +3225,8 @@ chansend({id}, {data}) *chansend()*
written if the write succeeded, 0 otherwise.
See |channel-bytes| for more information.
- {data} may be a string, string convertible, or a list. If
- {data} is a list, the items will be joined by newlines; any
+ {data} may be a string, string convertible, |Blob|, or a list.
+ If {data} is a list, the items will be joined by newlines; any
newlines in an item will be sent as NUL. To send a final
newline, include a final empty string. Example: >
:call chansend(id, ["abc", "123\n456", ""])
@@ -3064,8 +3237,9 @@ chansend({id}, {data}) *chansend()*
messages, use |rpcnotify()| and |rpcrequest()| instead.
-char2nr({expr} [, {utf8}]) *char2nr()*
- Return number value of the first char in {expr}. Examples: >
+char2nr({string} [, {utf8}]) *char2nr()*
+ Return number value of the first char in {string}.
+ Examples: >
char2nr(" ") returns 32
char2nr("ABC") returns 65
char2nr("á") returns 225
@@ -3085,10 +3259,10 @@ charidx({string}, {idx} [, {countcc}])
The index of the first character is zero.
If there are no multibyte characters the returned value is
equal to {idx}.
- When {countcc} is omitted or zero, then composing characters
- are not counted separately, their byte length is added to the
- preceding base character.
- When {countcc} is set to 1, then composing characters are
+ When {countcc} is omitted or |FALSE|, then composing characters
+ are not counted separately, their byte length is
+ added to the preceding base character.
+ When {countcc} is |TRUE|, then composing characters are
counted as separate characters.
Returns -1 if the arguments are invalid or if {idx} is greater
than the index of the last byte in {string}. An error is
@@ -3174,6 +3348,7 @@ complete({startcol}, {matches}) *complete()* *E785*
match.
{matches} must be a |List|. Each |List| item is one match.
See |complete-items| for the kind of items that are possible.
+ "longest" in 'completeopt' is ignored.
Note that the after calling this function you need to avoid
inserting anything that would cause completion to stop.
The match can be selected with CTRL-N and CTRL-P as usual with
@@ -3215,8 +3390,8 @@ complete_check() *complete_check()*
Only to be used by the function specified with the
'completefunc' option.
- *complete_info()*
-complete_info([{what}])
+
+complete_info([{what}]) *complete_info()*
Returns a |Dictionary| with information about Insert mode
completion. See |ins-completion|.
The items are:
@@ -3230,7 +3405,9 @@ complete_info([{what}])
See |complete-items|.
selected Selected item index. First index is zero.
Index is -1 if no item is selected (showing
- typed text only)
+ typed text only, or the last completion after
+ no item is selected when using the <Up> or
+ <Down> keys)
inserted Inserted string. [NOT IMPLEMENT YET]
*complete_info_mode*
@@ -3293,10 +3470,10 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
< For the console, the first letter of each choice is used as
the default shortcut key. Case is ignored.
- The optional {default} argument is the number of the choice
- that is made if the user hits <CR>. Use 1 to make the first
- choice the default one. Use 0 to not set a default. If
- {default} is omitted, 1 is used.
+ The optional {type} String argument gives the type of dialog.
+ It can be one of these values: "Error", "Question", "Info",
+ "Warning" or "Generic". Only the first character is relevant.
+ When {type} is omitted, "Generic" is used.
The optional {type} argument gives the type of dialog. This
is only used for the icon of the Win32 GUI. It can be one of
@@ -3500,7 +3677,7 @@ deepcopy({expr}[, {noref}]) *deepcopy()* *E698*
Can also be used as a |method|: >
GetObject()->deepcopy()
-delete({fname} [, {flags}]) *delete()*
+delete({fname} [, {flags}]) *delete()*
Without {flags} or with {flags} empty: Deletes the file by the
name {fname}. This also works when {fname} is a symbolic link.
A symbolic link itself is deleted, not what it points to.
@@ -3520,19 +3697,19 @@ delete({fname} [, {flags}]) *delete()*
Can also be used as a |method|: >
GetName()->delete()
-deletebufline({expr}, {first}[, {last}]) *deletebufline()*
- Delete lines {first} to {last} (inclusive) from buffer {expr}.
+deletebufline({buf}, {first}[, {last}]) *deletebufline()*
+ Delete lines {first} to {last} (inclusive) from buffer {buf}.
If {last} is omitted then delete line {first} only.
On success 0 is returned, on failure 1 is returned.
This function works only for loaded buffers. First call
|bufload()| if needed.
- For the use of {expr}, see |bufname()| above.
+ For the use of {buf}, see |bufname()| above.
{first} and {last} are used like with |setline()|. Note that
when using |line()| this refers to the current buffer. Use "$"
- to refer to the last line in buffer {expr}.
+ to refer to the last line in buffer {buf}.
Can also be used as a |method|: >
GetBuffer()->deletebufline(1)
@@ -3622,9 +3799,13 @@ diff_hlID({lnum}, {col}) *diff_hlID()*
empty({expr}) *empty()*
Return the Number 1 if {expr} is empty, zero otherwise.
- A |List| or |Dictionary| is empty when it does not have any
- items. A Number is empty when its value is zero. Special
- variable is empty when it is |v:false| or |v:null|.
+ - A |List| or |Dictionary| is empty when it does not have any
+ items.
+ - A |String| is empty when its length is zero.
+ - A |Number| and |Float| are empty when their value is zero.
+ - |v:false| and |v:null| are empty, |v:true| is not.
+ - A |Blob| is empty when its length is zero.
+
Can also be used as a |method|: >
mylist->empty()
@@ -3647,8 +3828,8 @@ escape({string}, {chars}) *escape()*
*eval()*
eval({string}) Evaluate {string} and return the result. Especially useful to
turn the result of |string()| back into the original value.
- This works for Numbers, Floats, Strings and composites of
- them. Also works for |Funcref|s that refer to existing
+ This works for Numbers, Floats, Strings, Blobs and composites
+ of them. Also works for |Funcref|s that refer to existing
functions.
Can also be used as a |method|: >
@@ -3823,21 +4004,21 @@ debugbreak({pid}) *debugbreak()*
Can also be used as a |method|: >
GetPid()->debugbreak()
-expand({expr} [, {nosuf} [, {list}]]) *expand()*
- Expand wildcards and the following special keywords in {expr}.
- 'wildignorecase' applies.
+expand({string} [, {nosuf} [, {list}]]) *expand()*
+ Expand wildcards and the following special keywords in
+ {string}. 'wildignorecase' applies.
If {list} is given and it is |TRUE|, a List will be returned.
Otherwise the result is a String and when there are several
matches, they are separated by <NL> characters.
If the expansion fails, the result is an empty string. A name
- for a non-existing file is not included, unless {expr} does
+ for a non-existing file is not included, unless {string} does
not start with '%', '#' or '<', see below.
- When {expr} starts with '%', '#' or '<', the expansion is done
- like for the |cmdline-special| variables with their associated
- modifiers. Here is a short overview:
+ When {string} starts with '%', '#' or '<', the expansion is
+ done like for the |cmdline-special| variables with their
+ associated modifiers. Here is a short overview:
% current file name
# alternate file name
@@ -3886,7 +4067,7 @@ expand({expr} [, {nosuf} [, {list}]]) *expand()*
buffer with no name, results in the current directory, with a
'/' added.
- When {expr} does not start with '%', '#' or '<', it is
+ When {string} does not start with '%', '#' or '<', it is
expanded like a file name is expanded on the command line.
'suffixes' and 'wildignore' are used, unless the optional
{nosuf} argument is given and it is |TRUE|.
@@ -4020,16 +4201,19 @@ filewritable({file}) *filewritable()*
filter({expr1}, {expr2}) *filter()*
- {expr1} must be a |List| or a |Dictionary|.
+ {expr1} must be a |List|, |Blob|, or a |Dictionary|.
For each item in {expr1} evaluate {expr2} and when the result
- is zero remove the item from the |List| or |Dictionary|.
+ is zero remove the item from the |List| or |Dictionary|. For a
+ |Blob| each byte is removed.
+
{expr2} must be a |string| or |Funcref|.
If {expr2} is a |string|, inside {expr2} |v:val| has the value
of the current item. For a |Dictionary| |v:key| has the key
of the current item and for a |List| |v:key| has the index of
- the current item.
- For a |Dictionary| |v:key| has the key of the current item.
+ the current item. For a |Blob| |v:key| has the index of the
+ current byte.
+
Examples: >
call filter(mylist, 'v:val !~ "OLD"')
< Removes the items where "OLD" appears. >
@@ -4060,11 +4244,11 @@ filter({expr1}, {expr2}) *filter()*
|Dictionary| to remain unmodified make a copy first: >
:let l = filter(copy(mylist), 'v:val =~ "KEEP"')
-< Returns {expr1}, the |List| or |Dictionary| that was filtered.
- When an error is encountered while evaluating {expr2} no
- further items in {expr1} are processed. When {expr2} is a
- Funcref errors inside a function are ignored, unless it was
- defined with the "abort" flag.
+< Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
+ filtered. When an error is encountered while evaluating
+ {expr2} no further items in {expr1} are processed. When
+ {expr2} is a Funcref errors inside a function are ignored,
+ unless it was defined with the "abort" flag.
Can also be used as a |method|: >
mylist->filter(expr2)
@@ -4073,14 +4257,17 @@ finddir({name} [, {path} [, {count}]]) *finddir()*
Find directory {name} in {path}. Supports both downwards and
upwards recursive directory searches. See |file-searching|
for the syntax of {path}.
+
Returns the path of the first found match. When the found
directory is below the current directory a relative path is
returned. Otherwise a full path is returned.
If {path} is omitted or empty then 'path' is used.
+
If the optional {count} is given, find {count}'s occurrence of
{name} in {path} instead of the first one.
When {count} is negative return all the matches in a |List|.
- This is quite similar to the ex-command |:find|.
+
+ This is quite similar to the ex-command `:find`.
findfile({name} [, {path} [, {count}]]) *findfile()*
Just like |finddir()|, but find a file instead of a directory.
@@ -4338,6 +4525,10 @@ get({list}, {idx} [, {default}]) *get()*
omitted.
Can also be used as a |method|: >
mylist->get(idx)
+get({blob}, {idx} [, {default}])
+ Get byte {idx} from |Blob| {blob}. When this byte is not
+ available return {default}. Return -1 when {default} is
+ omitted.
get({dict}, {key} [, {default}])
Get item with key {key} from |Dictionary| {dict}. When this
item is not available return {default}. Return zero when
@@ -4354,7 +4545,7 @@ get({func}, {what})
"args" The list with arguments
*getbufinfo()*
-getbufinfo([{expr}])
+getbufinfo([{buf}])
getbufinfo([{dict}])
Get information about buffers as a List of Dictionaries.
@@ -4368,8 +4559,8 @@ getbufinfo([{dict}])
bufloaded include only loaded buffers.
bufmodified include only modified buffers.
- Otherwise, {expr} specifies a particular buffer to return
- information for. For the use of {expr}, see |bufname()|
+ Otherwise, {buf} specifies a particular buffer to return
+ information for. For the use of {buf}, see |bufname()|
above. If the buffer is found the returned List has one item.
Otherwise the result is an empty list.
@@ -4422,12 +4613,12 @@ getbufinfo([{dict}])
<
*getbufline()*
-getbufline({expr}, {lnum} [, {end}])
+getbufline({buf}, {lnum} [, {end}])
Return a |List| with the lines starting from {lnum} to {end}
- (inclusive) in the buffer {expr}. If {end} is omitted, a
+ (inclusive) in the buffer {buf}. If {end} is omitted, a
|List| with only the line {lnum} is returned.
- For the use of {expr}, see |bufname()| above.
+ For the use of {buf}, see |bufname()| above.
For {lnum} and {end} "$" can be used for the last line of the
buffer. Otherwise a number must be used.
@@ -4446,10 +4637,11 @@ getbufline({expr}, {lnum} [, {end}])
Example: >
:let lines = getbufline(bufnr("myfile"), 1, "$")
-getbufvar({expr}, {varname} [, {def}]) *getbufvar()*
+getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
The result is the value of option or local buffer variable
- {varname} in buffer {expr}. Note that the name without "b:"
+ {varname} in buffer {buf}. Note that the name without "b:"
must be used.
+ The {varname} argument is a string.
When {varname} is empty returns a |Dictionary| with all the
buffer-local variables.
When {varname} is equal to "&" returns a |Dictionary| with all
@@ -4459,16 +4651,16 @@ getbufvar({expr}, {varname} [, {def}]) *getbufvar()*
This also works for a global or buffer-local option, but it
doesn't work for a global variable, window-local variable or
window-local option.
- For the use of {expr}, see |bufname()| above.
+ For the use of {buf}, see |bufname()| above.
When the buffer or variable doesn't exist {def} or an empty
string is returned, there is no error message.
Examples: >
:let bufmodified = getbufvar(1, "&mod")
:echo "todo myvar = " . getbufvar("todo", "myvar")
<
-getchangelist({expr}) *getchangelist()*
- Returns the |changelist| for the buffer {expr}. For the use
- of {expr}, see |bufname()| above. If buffer {expr} doesn't
+getchangelist({buf}) *getchangelist()*
+ Returns the |changelist| for the buffer {buf}. For the use
+ of {buf}, see |bufname()| above. If buffer {buf} doesn't
exist, an empty list is returned.
The returned list contains two entries: a list with the change
@@ -4478,7 +4670,7 @@ getchangelist({expr}) *getchangelist()*
col column number
coladd column offset for 'virtualedit'
lnum line number
- If buffer {expr} is the current buffer, then the current
+ If buffer {buf} is the current buffer, then the current
position refers to the position in the list. For other
buffers, it is set to the length of the list.
@@ -4634,9 +4826,9 @@ getcmdwintype() *getcmdwintype()*
when not in the command-line window.
getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
- Return a list of command-line completion matches. {type}
- specifies what for. The following completion types are
- supported:
+ Return a list of command-line completion matches. The String
+ {type} argument specifies what for. The following completion
+ types are supported:
arglist file names in argument list
augroup autocmd groups
@@ -4707,9 +4899,9 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but
|winrestview()| for restoring more state.
getcwd([{winnr}[, {tabnr}]]) *getcwd()*
- With no arguments the result is a String, which is the name of
- the current effective working directory. With {winnr} or
- {tabnr} the working directory of that scope is returned.
+ With no arguments, returns the name of the effective
+ |current-directory|. With {winnr} or {tabnr} the working
+ directory of that scope is returned.
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing argument implies 0.
Thus the following are equivalent: >
@@ -4720,8 +4912,11 @@ getcwd([{winnr}[, {tabnr}]]) *getcwd()*
{winnr} can be the window number or the |window-ID|.
getenv({name}) *getenv()*
- Return the value of environment variable {name}.
- When the variable does not exist |v:null| is returned. That
+ Return the value of environment variable {name}. The {name}
+ argument is a string, without a leading '$'. Example: >
+ myHome = getenv('HOME')
+
+< When the variable does not exist |v:null| is returned. That
is different from a variable set to an empty string.
See also |expr-env|.
@@ -4729,8 +4924,8 @@ getfontname([{name}]) *getfontname()*
Without an argument returns the name of the normal font being
used. Like what is used for the Normal highlight group
|hl-Normal|.
- With an argument a check is done whether {name} is a valid
- font name. If not then an empty string is returned.
+ With an argument a check is done whether String {name} is a
+ valid font name. If not then an empty string is returned.
Otherwise the actual font name is returned, or {name} if the
GUI does not support obtaining the real name.
Only works when the GUI is running, thus not in your vimrc or
@@ -4859,12 +5054,12 @@ getloclist({nr},[, {what}]) *getloclist()*
:echo getloclist(5, {'filewinid': 0})
-getmarklist([{expr}]) *getmarklist()*
- Without the {expr} argument returns a |List| with information
+getmarklist([{buf}]) *getmarklist()*
+ Without the {buf} argument returns a |List| with information
about all the global marks. |mark|
- If the optional {expr} argument is specified, returns the
- local marks defined in buffer {expr}. For the use of {expr},
+ If the optional {buf} argument is specified, returns the
+ local marks defined in buffer {buf}. For the use of {buf},
see |bufname()|.
Each item in the returned List is a |Dict| with the following:
@@ -4906,8 +5101,8 @@ getpid() Return a Number which is the process ID of the Vim process.
This is a unique number, until Vim exits.
*getpos()*
-getpos({expr}) Get the position for {expr}. For possible values of {expr}
- see |line()|. For getting the cursor position see
+getpos({expr}) Get the position for String {expr}. For possible values of
+ {expr} see |line()|. For getting the cursor position see
|getcurpos()|.
The result is a |List| with four numbers:
[bufnum, lnum, col, off]
@@ -5033,6 +5228,7 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()*
{regname}. Example: >
:let cliptext = getreg('*')
< When {regname} was not set the result is an empty string.
+ The {regname} argument is a string.
getreg('=') returns the last evaluated value of the expression
register. (For use in maps.)
@@ -5058,7 +5254,8 @@ getregtype([{regname}]) *getregtype()*
"<CTRL-V>{width}" for |blockwise-visual| text
"" for an empty or unknown register
<CTRL-V> is one character with value 0x16.
- If {regname} is not specified, |v:register| is used.
+ The {regname} argument is a string. If {regname} is not
+ specified, |v:register| is used.
gettabinfo([{tabnr}]) *gettabinfo()*
If {tabnr} is not specified, then information about all the
@@ -5077,8 +5274,8 @@ gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
Get the value of a tab-local variable {varname} in tab page
{tabnr}. |t:var|
Tabs are numbered starting with one.
- When {varname} is empty a dictionary with all tab-local
- variables is returned.
+ The {varname} argument is a string. When {varname} is empty a
+ dictionary with all tab-local variables is returned.
Note that the name without "t:" must be used.
When the tab or variable doesn't exist {def} or an empty
string is returned, there is no error message.
@@ -5086,8 +5283,8 @@ gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
Get the value of window-local variable {varname} in window
{winnr} in tab page {tabnr}.
- When {varname} is empty a dictionary with all window-local
- variables is returned.
+ The {varname} argument is a string. When {varname} is empty a
+ dictionary with all window-local variables is returned.
When {varname} is equal to "&" get the values of all
window-local options in a |Dictionary|.
Otherwise, when {varname} starts with "&" get the value of a
@@ -5242,22 +5439,22 @@ glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
See |expand()| for expanding special Vim variables. See
|system()| for getting the raw output of an external command.
-glob2regpat({expr}) *glob2regpat()*
+glob2regpat({string}) *glob2regpat()*
Convert a file pattern, as used by glob(), into a search
pattern. The result can be used to match with a string that
is a file name. E.g. >
if filename =~ glob2regpat('Make*.mak')
< This is equivalent to: >
if filename =~ '^Make.*\.mak$'
-< When {expr} is an empty string the result is "^$", match an
+< When {string} is an empty string the result is "^$", match an
empty string.
Note that the result depends on the system. On MS-Windows
a backslash usually means a path separator.
*globpath()*
globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
- Perform glob() on all directories in {path} and concatenate
- the results. Example: >
+ Perform glob() for String {expr} on all directories in {path}
+ and concatenate the results. Example: >
:echo globpath(&rtp, "syntax/c.vim")
<
{path} is a comma-separated list of directory names. Each
@@ -5351,7 +5548,8 @@ has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The
has_key({dict}, {key}) *has_key()*
The result is a Number, which is TRUE if |Dictionary| {dict}
- has an entry with key {key}. FALSE otherwise.
+ has an entry with key {key}. FALSE otherwise. The {key}
+ argument is a string.
Can also be used as a |method|: >
mydict->has_key(key)
@@ -5376,6 +5574,7 @@ hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
that contains {what} in somewhere in the rhs (what it is
mapped to) and this mapping exists in one of the modes
indicated by {mode}.
+ The arguments {what} and {mode} are strings.
When {abbr} is there and it is |TRUE| use abbreviations
instead of mappings. Don't forget to specify Insert and/or
Command-line mode.
@@ -5496,8 +5695,8 @@ hostname() *hostname()*
which Vim is currently running. Machine names greater than
256 characters long are truncated.
-iconv({expr}, {from}, {to}) *iconv()*
- The result is a String, which is the text {expr} converted
+iconv({string}, {from}, {to}) *iconv()*
+ The result is a String, which is the text {string} converted
from encoding {from} to encoding {to}.
When the conversion completely fails an empty string is
returned. When some characters could not be converted they
@@ -5516,17 +5715,21 @@ indent({lnum}) The result is a Number, which is indent of line {lnum} in the
When {lnum} is invalid -1 is returned.
-index({list}, {expr} [, {start} [, {ic}]]) *index()*
- Return the lowest index in |List| {list} where the item has a
- value equal to {expr}. There is no automatic conversion, so
- the String "4" is different from the Number 4. And the number
- 4 is different from the Float 4.0. The value of 'ignorecase'
- is not used here, case always matters.
+index({object}, {expr} [, {start} [, {ic}]]) *index()*
+ If {object} is a |List| return the lowest index where the item
+ has a value equal to {expr}. There is no automatic
+ conversion, so the String "4" is different from the Number 4.
+ And the Number 4 is different from the Float 4.0. The value
+ of 'ignorecase' is not used here, case always matters.
+
+ If {object} is a |Blob| return the lowest index where the byte
+ value is equal to {expr}.
+
If {start} is given then start looking at the item with index
{start} (may be negative for an item relative to the end).
When {ic} is given and it is |TRUE|, ignore case. Otherwise
case must match.
- -1 is returned when {expr} is not found in {list}.
+ -1 is returned when {expr} is not found in {object}.
Example: >
:let idx = index(words, "the")
:if index(numbers, 123) >= 0
@@ -5685,13 +5888,16 @@ inputsecret({prompt} [, {text}]) *inputsecret()*
typed on the command-line in response to the issued prompt.
NOTE: Command-line completion is not supported.
-insert({list}, {item} [, {idx}]) *insert()*
- Insert {item} at the start of |List| {list}.
+insert({object}, {item} [, {idx}]) *insert()*
+ When {object} is a |List| or a |Blob| insert {item} at the start
+ of it.
+
If {idx} is specified insert {item} before the item with index
{idx}. If {idx} is zero it goes before the first item, just
like omitting {idx}. A negative {idx} is also possible, see
|list-index|. -1 inserts just before the last item.
- Returns the resulting |List|. Examples: >
+
+ Returns the resulting |List| or |Blob|. Examples: >
:let mylist = insert([2, 3, 5], 1)
:call insert(mylist, 4, -1)
:call insert(mylist, 6, len(mylist))
@@ -5742,8 +5948,9 @@ isinf({expr}) *isinf()*
islocked({expr}) *islocked()* *E786*
The result is a Number, which is |TRUE| when {expr} is the
name of a locked variable.
- {expr} must be the name of a variable, |List| item or
- |Dictionary| entry, not the variable itself! Example: >
+ The string argument {expr} must be the name of a variable,
+ |List| item or |Dictionary| entry, not the variable itself!
+ Example: >
:let alist = [0, ['a', 'b'], 2, 3]
:lockvar 1 alist
:echo islocked('alist') " 1
@@ -5754,16 +5961,16 @@ islocked({expr}) *islocked()* *E786*
id({expr}) *id()*
Returns a |String| which is a unique identifier of the
- container type (|List|, |Dict| and |Partial|). It is
+ container type (|List|, |Dict|, |Blob| and |Partial|). It is
guaranteed that for the mentioned types `id(v1) ==# id(v2)`
returns true iff `type(v1) == type(v2) && v1 is v2`.
- Note that |v:_null_string|, |v:_null_list|, and |v:_null_dict|
- have the same `id()` with different types because they are
- internally represented as a NULL pointers. `id()` returns a
- hexadecimal representanion of the pointers to the containers
- (i.e. like `0x994a40`), same as `printf("%p", {expr})`,
- but it is advised against counting on the exact format of
- return value.
+ Note that |v:_null_string|, |v:_null_list|, |v:_null_dict| and
+ |v:_null_blob| have the same `id()` with different types
+ because they are internally represented as NULL pointers.
+ `id()` returns a hexadecimal representanion of the pointers to
+ the containers (i.e. like `0x994a40`), same as `printf("%p",
+ {expr})`, but it is advised against counting on the exact
+ format of the return value.
It is not guaranteed that `id(no_longer_existing_container)`
will not be equal to some other `id()`: new containers may
@@ -5773,8 +5980,13 @@ items({dict}) *items()*
Return a |List| with all the key-value pairs of {dict}. Each
|List| item is a list with two items: the key of a {dict}
entry and the value of this entry. The |List| is in arbitrary
- order.
- Can also be used as a |method|: >
+ order. Also see |keys()| and |values()|.
+ Example: >
+ for [key, value] in items(mydict)
+ echo key . ': ' . value
+ endfor
+
+< Can also be used as a |method|: >
mydict->items()
isnan({expr}) *isnan()*
@@ -5941,10 +6153,12 @@ json_encode({expr}) *json_encode()*
surrogate pairs (such strings are not valid UTF-8 strings).
Non-printable characters are converted into "\u1234" escapes
or special escapes like "\t", other are dumped as-is.
+ |Blob|s are converted to arrays of the individual bytes.
keys({dict}) *keys()*
Return a |List| with all the keys of {dict}. The |List| is in
- arbitrary order.
+ arbitrary order. Also see |items()| and |values()|.
+
Can also be used as a |method|: >
mydict->keys()
@@ -6016,7 +6230,8 @@ libcallnr({libname}, {funcname}, {argument})
<
*line()*
line({expr}) The result is a Number, which is the line number of the file
- position given with {expr}. The accepted positions are:
+ position given with {expr}. The {expr} argument is a string.
+ The accepted positions are:
. the cursor position
$ the last line in the current buffer
'x position of mark x (if the mark is not set, 0 is
@@ -6047,8 +6262,8 @@ line2byte({lnum}) *line2byte()*
line just below the last line: >
line2byte(line("$") + 1)
< This is the buffer size plus one. If 'fileencoding' is empty
- it is the file size plus one.
- When {lnum} is invalid -1 is returned.
+ it is the file size plus one. {lnum} is used like with
+ |getline()|. When {lnum} is invalid -1 is returned.
Also see |byte2line()|, |go| and |:goto|.
lispindent({lnum}) *lispindent()*
@@ -6107,14 +6322,17 @@ luaeval({expr}[, {expr}])
to Vim data structures. See |lua-eval| for more details.
map({expr1}, {expr2}) *map()*
- {expr1} must be a |List| or a |Dictionary|.
+ {expr1} must be a |List|, |Blob| or |Dictionary|.
Replace each item in {expr1} with the result of evaluating
- {expr2}. {expr2} must be a |string| or |Funcref|.
+ {expr2}. For a |Blob| each byte is replaced.
+
+ {expr2} must be a |string| or |Funcref|.
If {expr2} is a |string|, inside {expr2} |v:val| has the value
- of the current item. For a |Dictionary| |v:key| has the key
+ of the current item. For a |Dictionary| |v:key| has the key
of the current item and for a |List| |v:key| has the index of
- the current item.
+ the current item. For a |Blob| |v:key| has the index of the
+ current byte.
Example: >
:call map(mylist, '"> " . v:val . " <"')
< This puts "> " before and " <" after each item in "mylist".
@@ -6144,11 +6362,11 @@ map({expr1}, {expr2}) *map()*
|Dictionary| to remain unmodified make a copy first: >
:let tlist = map(copy(mylist), ' v:val . "\t"')
-< Returns {expr1}, the |List| or |Dictionary| that was filtered.
- When an error is encountered while evaluating {expr2} no
- further items in {expr1} are processed. When {expr2} is a
- Funcref errors inside a function are ignored, unless it was
- defined with the "abort" flag.
+< Returns {expr1}, the |List|, |Blob| or |Dictionary| that was
+ filtered. When an error is encountered while evaluating
+ {expr2} no further items in {expr1} are processed. When
+ {expr2} is a Funcref errors inside a function are ignored,
+ unless it was defined with the "abort" flag.
Can also be used as a |method|: >
mylist->map(expr2)
@@ -6553,9 +6771,9 @@ mkdir({name} [, {path} [, {prot}]])
If {path} is "p" then intermediate directories are created as
necessary. Otherwise it must be "".
If {prot} is given it is used to set the protection bits of
- the new directory. The default is 0755 (rwxr-xr-x: r/w for
- the user readable for others). Use 0700 to make it unreadable
- for others.
+ the new directory. The default is 0o755 (rwxr-xr-x: r/w for
+ the user, readable for others). Use 0o700 to make it
+ unreadable for others.
{prot} is applied for all parts of {name}. Thus if you create
/tmp/foo/bar then /tmp/foo will be created with 0700. Example: >
@@ -6616,11 +6834,15 @@ mode([expr]) Return a string that indicates the current mode.
the leading character(s).
Also see |visualmode()|.
-msgpackdump({list}) *msgpackdump()*
- Convert a list of VimL objects to msgpack. Returned value is
- |readfile()|-style list. Example: >
+msgpackdump({list} [, {type}]) *msgpackdump()*
+ Convert a list of VimL objects to msgpack. Returned value is a
+ |readfile()|-style list. When {type} contains "B", a |Blob| is
+ returned instead. Example: >
call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
-< This will write the single 0x80 byte to `fname.mpack` file
+< or, using a |Blob|: >
+ call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
+<
+ This will write the single 0x80 byte to a `fname.mpack` file
(dictionary with zero items is represented by 0x80 byte in
messagepack).
@@ -6628,11 +6850,12 @@ msgpackdump({list}) *msgpackdump()*
1. |Funcref|s cannot be dumped.
2. Containers that reference themselves cannot be dumped.
3. Dictionary keys are always dumped as STR strings.
- 4. Other strings are always dumped as BIN strings.
+ 4. Other strings and |Blob|s are always dumped as BIN strings.
5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
-msgpackparse({list}) *msgpackparse()*
- Convert a |readfile()|-style list to a list of VimL objects.
+msgpackparse({data}) *msgpackparse()*
+ Convert a |readfile()|-style list or a |Blob| to a list of
+ VimL objects.
Example: >
let fname = expand('~/.config/nvim/shada/main.shada')
let mpack = readfile(fname, 'b')
@@ -6642,7 +6865,7 @@ msgpackparse({list}) *msgpackparse()*
Limitations:
1. Mapping ordering is not preserved unless messagepack
- mapping is dumped using generic mapping
+ mapping is dumped using generic mapping
(|msgpack-special-map|).
2. Since the parser aims to preserve all data untouched
(except for 1.) some strings are parsed to
@@ -6686,9 +6909,9 @@ msgpackparse({list}) *msgpackparse()*
zero byte or if string is a mapping key and mapping is
being represented as special dictionary for other
reasons.
- binary |readfile()|-style list of strings. This value will
- appear in |msgpackparse()| output if binary string
- contains zero byte.
+ binary |String|, or |Blob| if binary string contains zero
+ byte. This value cannot appear in |msgpackparse()|
+ output since blobs were introduced.
array |List|. This value cannot appear in |msgpackparse()|
output.
*msgpack-special-map*
@@ -6710,6 +6933,7 @@ nextnonblank({lnum}) *nextnonblank()*
if getline(nextnonblank(1)) =~ "Java"
< When {lnum} is invalid or there is no non-blank line at or
below it, zero is returned.
+ {lnum} is used like with |getline()|.
See also |prevnonblank()|.
nr2char({expr} [, {utf8}]) *nr2char()*
@@ -6745,8 +6969,8 @@ or({expr}, {expr}) *or()*
< Can also be used as a |method|: >
:let bits = bits->or(0x80)
-pathshorten({expr}) *pathshorten()*
- Shorten directory names in the path {expr} and return the
+pathshorten({path}) *pathshorten()*
+ Shorten directory names in the path {path} and return the
result. The tail, the file name, is kept as-is. The other
components in the path are reduced to single letters. Leading
'~' and '.' characters are kept. Example: >
@@ -6789,6 +7013,7 @@ prevnonblank({lnum}) *prevnonblank()*
let ind = indent(prevnonblank(v:lnum - 1))
< When {lnum} is invalid or there is no non-blank line at or
above it, zero is returned.
+ {lnum} is used like with |getline()|.
Also see |nextnonblank()|.
@@ -7131,16 +7356,18 @@ readdir({directory} [, {expr}])
echo s:tree(".")
<
*readfile()*
-readfile({fname} [, {binary} [, {max}]])
+readfile({fname} [, {type} [, {max}]])
Read file {fname} and return a |List|, each line of the file
as an item. Lines are broken at NL characters. Macintosh
files separated with CR will result in a single long line
(unless a NL appears somewhere).
All NUL characters are replaced with a NL character.
- When {binary} contains "b" binary mode is used:
+ When {type} contains "b" binary mode is used:
- When the last line ends in a NL an extra empty list item is
added.
- No CR characters are removed.
+ When {type} contains "B" a |Blob| is returned with the binary
+ data of the file unmodified.
Otherwise:
- CR characters that appear before a NL are removed.
- Whether the last line ends in a NL or not does not matter.
@@ -7198,7 +7425,8 @@ reltimefloat({time}) *reltimefloat()*
call MyFunction()
let seconds = reltimefloat(reltime(start))
See the note of reltimestr() about overhead.
- Also see |profiling|.
+ Also see |profiling|.
+ If there is an error an empty string is returned
reltimestr({time}) *reltimestr()*
Return a String that represents the time value of {time}.
@@ -7212,6 +7440,7 @@ reltimestr({time}) *reltimestr()*
can use split() to remove it. >
echo split(reltimestr(reltime(start)))[0]
< Also see |profiling|.
+ If there is an error an empty string is returned
*remote_expr()* *E449*
remote_expr({server}, {string} [, {idvar} [, {timeout}]])
@@ -7242,6 +7471,7 @@ remote_expr({server}, {string} [, {idvar} [, {timeout}]])
remote_foreground({server}) *remote_foreground()*
Move the Vim server with the name {server} to the foreground.
+ The {server} argument is a string.
This works like: >
remote_expr({server}, "foreground()")
< Except that on Win32 systems the client does the work, to work
@@ -7317,6 +7547,17 @@ remove({list}, {idx} [, {end}]) *remove()*
< Can also be used as a |method|: >
mylist->remove(idx)
+remove({blob}, {idx} [, {end}])
+ Without {end}: Remove the byte at {idx} from |Blob| {blob} and
+ return the byte.
+ With {end}: Remove bytes from {idx} to {end} (inclusive) and
+ return a |Blob| with these bytes. When {idx} points to the same
+ byte as {end} a |Blob| with one byte is returned. When {end}
+ points to a byte before {idx} this is an error.
+ Example: >
+ :echo "last byte: " . remove(myblob, -1)
+ :call remove(mylist, 0, 9)
+
remove({dict}, {key})
Remove the entry from {dict} with key {key} and return it.
Example: >
@@ -7360,9 +7601,11 @@ resolve({filename}) *resolve()* *E655*
path name) and also keeps a trailing path separator.
*reverse()*
-reverse({list}) Reverse the order of items in {list} in-place. Returns
- {list}.
- If you want a list to remain unmodified make a copy first: >
+reverse({object})
+ Reverse the order of items in {object} in-place.
+ {object} can be a |List| or a |Blob|.
+ Returns {object}.
+ If you want an object to remain unmodified make a copy first: >
:let revlist = reverse(copy(mylist))
< Can also be used as a |method|: >
mylist->reverse()
@@ -7456,6 +7699,10 @@ screenpos({winid}, {lnum}, {col}) *screenpos()*
The "curscol" value is where the cursor would be placed. For
a Tab it would be the same as "endcol", while for a double
width character it would be the same as "col".
+ The |conceal| feature is ignored here, the column numbers are
+ as if 'conceallevel' is zero. You can set the cursor to the
+ right position and use |screencol()| to get the value with
+ |conceal| taken into account.
screenrow() *screenrow()*
The result is a Number, which is the current screen row of the
@@ -7860,8 +8107,8 @@ serverstop({address}) *serverstop()*
If |v:servername| is stopped it is set to the next available
address returned by |serverlist()|.
-setbufline({expr}, {lnum}, {text}) *setbufline()*
- Set line {lnum} to {text} in buffer {expr}. This works like
+setbufline({buf}, {lnum}, {text}) *setbufline()*
+ Set line {lnum} to {text} in buffer {buf}. This works like
|setline()| for the specified buffer.
This function works only for loaded buffers. First call
@@ -7874,23 +8121,24 @@ setbufline({expr}, {lnum}, {text}) *setbufline()*
to set multiple lines. If the list extends below the last
line then those lines are added.
- For the use of {expr}, see |bufname()| above.
+ For the use of {buf}, see |bufname()| above.
{lnum} is used like with |setline()|.
When {lnum} is just below the last line the {text} will be
added below the last line.
On success 0 is returned, on failure 1 is returned.
- If {expr} is not a valid buffer or {lnum} is not valid, an
+ If {buf} is not a valid buffer or {lnum} is not valid, an
error message is given.
-setbufvar({expr}, {varname}, {val}) *setbufvar()*
- Set option or local variable {varname} in buffer {expr} to
+setbufvar({buf}, {varname}, {val}) *setbufvar()*
+ Set option or local variable {varname} in buffer {buf} to
{val}.
This also works for a global or local window option, but it
doesn't work for a global or local window variable.
For a local window option the global value is unchanged.
- For the use of {expr}, see |bufname()| above.
+ For the use of {buf}, see |bufname()| above.
+ The {varname} argument is a string.
Note that the variable name without "b:" must be used.
Examples: >
:call setbufvar(1, "&mod", 1)
@@ -7933,8 +8181,10 @@ setcmdpos({pos}) *setcmdpos()*
command line.
setenv({name}, {val}) *setenv()*
- Set environment variable {name} to {val}.
- When {val} is |v:null| the environment variable is deleted.
+ Set environment variable {name} to {val}. Example: >
+ call setenv('HOME', '/home/myhome')
+
+< When {val} is |v:null| the environment variable is deleted.
See also |expr-env|.
setfperm({fname}, {mode}) *setfperm()* *chmod*
@@ -8005,7 +8255,7 @@ setmatches({list} [, {win}]) *setmatches()*
*setpos()*
setpos({expr}, {list})
- Set the position for {expr}. Possible values:
+ Set the position for String {expr}. Possible values:
. the cursor
'x mark x
@@ -8166,6 +8416,7 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
*setreg()*
setreg({regname}, {value} [, {options}])
Set the register {regname} to {value}.
+ The {regname} argument is a string.
{value} may be any value returned by |getreg()|, including
a |List|.
@@ -8217,6 +8468,7 @@ setreg({regname}, {value} [, {options}])
settabvar({tabnr}, {varname}, {val}) *settabvar()*
Set tab-local variable {varname} to {val} in tab page {tabnr}.
|t:var|
+ The {varname} argument is a string.
Note that the variable name without "t:" must be used.
Tabs are numbered starting with one.
This function is not available in the |sandbox|.
@@ -8301,6 +8553,10 @@ shellescape({string} [, {special}]) *shellescape()*
- The <NL> character is escaped (twice if {special} is
a ||non-zero-arg|).
+ If 'shell' contains "fish" in the tail, the "\" character will
+ be escaped because in fish it is used as an escape character
+ inside single quotes.
+
Example of use with a |:!| command: >
:exe '!dir ' . shellescape(expand('<cfile>'), 1)
< This results in a directory listing for the file under the
@@ -8462,12 +8718,14 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
func MyCompare(i1, i2)
return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
endfunc
- let sortedlist = sort(mylist, "MyCompare")
+ eval mylist->sort("MyCompare")
< A shorter compare version for this specific simple case, which
ignores overflow: >
func MyCompare(i1, i2)
return a:i1 - a:i2
endfunc
+< For a simple expression you can use a lambda: >
+ eval mylist->sort({i1, i2 -> i1 - i2})
<
*soundfold()*
soundfold({word})
@@ -8526,8 +8784,8 @@ spellsuggest({word} [, {max} [, {capital}]])
values of 'spelllang' and 'spellsuggest' are used.
-split({expr} [, {pattern} [, {keepempty}]]) *split()*
- Make a |List| out of {expr}. When {pattern} is omitted or
+split({string} [, {pattern} [, {keepempty}]]) *split()*
+ Make a |List| out of {string}. When {pattern} is omitted or
empty each white-separated sequence of characters becomes an
item.
Otherwise the string is split where {pattern} matches,
@@ -8604,13 +8862,16 @@ stdpath({what}) *stdpath()* *E6100*
:echo stdpath("config")
-str2float({expr}) *str2float()*
- Convert String {expr} to a Float. This mostly works the same
- as when using a floating point number in an expression, see
- |floating-point-format|. But it's a bit more permissive.
- E.g., "1e40" is accepted, while in an expression you need to
- write "1.0e40". The hexadecimal form "0x123" is also
- accepted, but not others, like binary or octal.
+str2float({string} [, {quoted}]) *str2float()*
+ Convert String {string} to a Float. This mostly works the
+ same as when using a floating point number in an expression,
+ see |floating-point-format|. But it's a bit more permissive.
+ E.g., "1e40" is accepted, while in an expression you need to
+ write "1.0e40". The hexadecimal form "0x123" is also
+ accepted, but not others, like binary or octal.
+ When {quoted} is present and non-zero then embedded single
+ quotes before the dot are ignored, thus "1'000.0" is a
+ thousand.
Text after the number is silently ignored.
The decimal point is always '.', no matter what the locale is
set to. A comma ends the number: "12,345.67" is converted to
@@ -8621,9 +8882,9 @@ str2float({expr}) *str2float()*
Can also be used as a |method|: >
let f = text->substitute(',', '', 'g')->str2float()
-str2list({expr} [, {utf8}]) *str2list()*
+str2list({string} [, {utf8}]) *str2list()*
Return a list containing the number values which represent
- each character in String {expr}. Examples: >
+ each character in String {string}. Examples: >
str2list(" ") returns [32]
str2list("ABC") returns [65, 66, 67]
< |list2str()| does the opposite.
@@ -8637,9 +8898,11 @@ str2list({expr} [, {utf8}]) *str2list()*
< Can also be used as a |method|: >
GetString()->str2list()
-str2nr({expr} [, {base}]) *str2nr()*
- Convert string {expr} to a number.
+str2nr({string} [, {base}]) *str2nr()*
+ Convert string {string} to a number.
{base} is the conversion base, it can be 2, 8, 10 or 16.
+ When {quoted} is present and non-zero then embedded single
+ quotes are ignored, thus "1'000'000" is a million.
When {base} is omitted base 10 is used. This also means that
a leading zero doesn't cause octal conversion to be used, as
@@ -8647,15 +8910,15 @@ str2nr({expr} [, {base}]) *str2nr()*
let nr = str2nr('123')
<
When {base} is 16 a leading "0x" or "0X" is ignored. With a
- different base the result will be zero. Similarly, when {base}
- is 8 a leading "0" is ignored, and when {base} is 2 a leading
- "0b" or "0B" is ignored.
+ different base the result will be zero. Similarly, when
+ {base} is 8 a leading "0", "0o" or "0O" is ignored, and when
+ {base} is 2 a leading "0b" or "0B" is ignored.
Text after the number is silently ignored.
-strchars({expr} [, {skipcc}]) *strchars()*
+strchars({string} [, {skipcc}]) *strchars()*
The result is a Number, which is the number of characters
- in String {expr}.
+ in String {string}.
When {skipcc} is omitted or zero, composing characters are
counted separately.
When {skipcc} set to 1, Composing characters are ignored.
@@ -8686,16 +8949,16 @@ strcharpart({src}, {start} [, {len}]) *strcharpart()*
strcharpart('abc', -1, 2)
< results in 'a'.
-strdisplaywidth({expr} [, {col}]) *strdisplaywidth()*
+strdisplaywidth({string} [, {col}]) *strdisplaywidth()*
The result is a Number, which is the number of display cells
- String {expr} occupies on the screen when it starts at {col}
+ String {string} occupies on the screen when it starts at {col}
(first column is zero). When {col} is omitted zero is used.
Otherwise it is the screen column where to start. This
matters for Tab characters.
The option settings of the current window are used. This
matters for anything that's displayed differently, such as
'tabstop' and 'display'.
- When {expr} contains characters with East Asian Width Class
+ When {string} contains characters with East Asian Width Class
Ambiguous, this function's return value depends on 'ambiwidth'.
Also see |strlen()|, |strwidth()| and |strchars()|.
@@ -8743,14 +9006,15 @@ stridx({haystack}, {needle} [, {start}]) *stridx()*
*string()*
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
- Float, String or a composition of them, then the result can be
- parsed back with |eval()|.
+ Float, String, Blob or a composition of them, then the result
+ can be parsed back with |eval()|.
{expr} type result ~
String 'string'
Number 123
Float 123.123456 or 1.123456e8 or
`str2float('inf')`
Funcref `function('name')`
+ Blob 0z00112233.44556677.8899
List [item, item]
Dictionary {key: value, key: value}
Note that in String values the ' character is doubled.
@@ -8767,9 +9031,9 @@ string({expr}) Return {expr} converted to a String. If {expr} is a Number,
Can also be used as a |method|: >
mylist->string()
- *strlen()*
-strlen({expr}) The result is a Number, which is the length of the String
- {expr} in bytes.
+strlen({string}) *strlen()*
+ The result is a Number, which is the length of the String
+ {string} in bytes.
If the argument is a Number it is first converted to a String.
For other types an error is given.
If you want to count the number of multibyte characters use
@@ -8845,8 +9109,8 @@ strridx({haystack}, {needle} [, {start}]) *strridx()*
When used with a single character it works similar to the C
function strrchr().
-strtrans({expr}) *strtrans()*
- The result is a String, which is {expr} with all unprintable
+strtrans({string}) *strtrans()*
+ The result is a String, which is {string} with all unprintable
characters translated into printable characters |'isprint'|.
Like they are shown in a window. Example: >
echo strtrans(@a)
@@ -8856,11 +9120,11 @@ strtrans({expr}) *strtrans()*
Can also be used as a |method|: >
GetString()->strtrans()
-strwidth({expr}) *strwidth()*
+strwidth({string}) *strwidth()*
The result is a Number, which is the number of display cells
- String {expr} occupies. A Tab character is counted as one
+ String {string} occupies. A Tab character is counted as one
cell, alternatively use |strdisplaywidth()|.
- When {expr} contains characters with East Asian Width Class
+ When {string} contains characters with East Asian Width Class
Ambiguous, this function's return value depends on 'ambiwidth'.
Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
@@ -8893,10 +9157,10 @@ submatch({nr} [, {list}]) *submatch()* *E935*
< This finds the first number in the line and adds one to it.
A line break is included as a newline character.
-substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
- The result is a String, which is a copy of {expr}, in which
+substitute({string}, {pat}, {sub}, {flags}) *substitute()*
+ The result is a String, which is a copy of {string}, in which
the first match of {pat} is replaced with {sub}.
- When {flags} is "g", all matches of {pat} in {expr} are
+ When {flags} is "g", all matches of {pat} in {string} are
replaced. Otherwise {flags} should be "".
This works like the ":substitute" command (without any flags).
@@ -8912,7 +9176,7 @@ substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
|sub-replace-special|. For example, to replace something with
"\n" (two characters), use "\\\\n" or '\\n'.
- When {pat} does not match in {expr}, {expr} is returned
+ When {pat} does not match in {string}, {string} is returned
unmodified.
Example: >
@@ -8955,12 +9219,12 @@ swapinfo({fname}) *swapinfo()*
Not a swap file: does not contain correct block ID
Magic number mismatch: Info in first block is invalid
-swapname({expr}) *swapname()*
- The result is the swap file path of the buffer {expr}.
- For the use of {expr}, see |bufname()| above.
- If buffer {expr} is the current buffer, the result is equal to
+swapname({buf}) *swapname()*
+ The result is the swap file path of the buffer {buf}.
+ For the use of {buf}, see |bufname()| above.
+ If buffer {buf} is the current buffer, the result is equal to
|:swapname| (unless there is no swap file).
- If buffer {expr} has no swap file, returns an empty string.
+ If buffer {buf} has no swap file, returns an empty string.
synID({lnum}, {col}, {trans}) *synID()*
The result is a Number, which is the syntax ID at the position
@@ -8972,7 +9236,7 @@ synID({lnum}, {col}, {trans}) *synID()*
line. 'synmaxcol' applies, in a longer line zero is returned.
Note that when the position is after the last character,
that's where the cursor can be in Insert mode, synID() returns
- zero.
+ zero. {lnum} is used like with |getline()|.
When {trans} is |TRUE|, transparent items are reduced to the
item that they reveal. This is useful when wanting to know
@@ -9037,7 +9301,7 @@ synconcealed({lnum}, {col}) *synconcealed()*
The result is a |List| with currently three items:
1. The first item in the list is 0 if the character at the
position {lnum} and {col} is not part of a concealable
- region, 1 if it is.
+ region, 1 if it is. {lnum} is used like with |getline()|.
2. The second item in the list is a string. If the first item
is 1, the second item contains the text which will be
displayed in place of the concealed text, depending on the
@@ -9061,8 +9325,9 @@ synconcealed({lnum}, {col}) *synconcealed()*
synstack({lnum}, {col}) *synstack()*
Return a |List|, which is the stack of syntax items at the
- position {lnum} and {col} in the current window. Each item in
- the List is an ID like what |synID()| returns.
+ position {lnum} and {col} in the current window. {lnum} is
+ used like with |getline()|. Each item in the List is an ID
+ like what |synID()| returns.
The first item in the List is the outer region, following are
items contained in that one. The last one is what |synID()|
returns, unless not the whole item is highlighted or it is a
@@ -9078,11 +9343,23 @@ synstack({lnum}, {col}) *synstack()*
valid positions.
system({cmd} [, {input}]) *system()* *E677*
- Get the output of {cmd} as a |string| (use |systemlist()| to
- get a |List|). {cmd} is treated exactly as in |jobstart()|.
- Not to be used for interactive commands.
+ Gets the output of {cmd} as a |string| (|systemlist()| returns
+ a |List|) and sets |v:shell_error| to the error code.
+ {cmd} is treated as in |jobstart()|:
+ If {cmd} is a List it runs directly (no 'shell').
+ If {cmd} is a String it runs in the 'shell', like this: >
+ :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
+
+< Not to be used for interactive commands.
- If {input} is a string it is written to a pipe and passed as
+ Result is a String, filtered to avoid platform-specific quirks:
+ - <CR><NL> is replaced with <NL>
+ - NUL characters are replaced with SOH (0x01)
+
+ Example: >
+ :echo system(['ls', expand('%:h')])
+
+< If {input} is a string it is written to a pipe and passed as
stdin to the command. The string is written as-is, line
separators are not changed.
If {input} is a |List| it is written to the pipe as
@@ -9095,7 +9372,7 @@ system({cmd} [, {input}]) *system()* *E677*
*E5677*
Note: system() cannot write to or read from backgrounded ("&")
shell commands, e.g.: >
- :echo system("cat - &", "foo"))
+ :echo system("cat - &", "foo")
< which is equivalent to: >
$ echo foo | bash -c 'cat - &'
< The pipes are disconnected (unless overridden by shell
@@ -9104,29 +9381,12 @@ system({cmd} [, {input}]) *system()* *E677*
Note: Use |shellescape()| or |::S| with |expand()| or
|fnamemodify()| to escape special characters in a command
- argument. Newlines in {cmd} may cause the command to fail.
- The characters in 'shellquote' and 'shellxquote' may also
- cause trouble.
-
- Result is a String. Example: >
- :let files = system("ls " . shellescape(expand('%:h')))
- :let files = system('ls ' . expand('%:h:S'))
-
-< To make the result more system-independent, the shell output
- is filtered to replace <CR> with <NL> for Macintosh, and
- <CR><NL> with <NL> for DOS-like systems.
- To avoid the string being truncated at a NUL, all NUL
- characters are replaced with SOH (0x01).
-
- The command executed is constructed using several options when
- {cmd} is a string: 'shell' 'shellcmdflag' {cmd}
-
- The resulting error code can be found in |v:shell_error|.
+ argument. 'shellquote' and 'shellxquote' must be properly
+ configured. Example: >
+ :echo system('ls '..shellescape(expand('%:h')))
+ :echo system('ls '..expand('%:h:S'))
- Note that any wrong value in the options mentioned above may
- make the function fail. It has also been reported to fail
- when using a security agent application.
- Unlike ":!cmd" there is no automatic check for changed files.
+< Unlike ":!cmd" there is no automatic check for changed files.
Use |:checktime| to force a check.
Can also be used as a |method|: >
@@ -9427,6 +9687,7 @@ type({expr}) *type()*
Float: 5 (|v:t_float|)
Boolean: 6 (|v:true| and |v:false|)
Null: 7 (|v:null|)
+ Blob: 10 (|v:t_blob|)
For backward compatibility, this method can be used: >
:if type(myvar) == type(0)
:if type(myvar) == type("")
@@ -9511,7 +9772,7 @@ uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
values({dict}) *values()*
Return a |List| with all the values of {dict}. The |List| is
- in arbitrary order.
+ in arbitrary order. Also see |items()| and |keys()|.
Can also be used as a |method|: >
mydict->values()
@@ -9659,7 +9920,7 @@ win_screenpos({nr}) *win_screenpos()*
[1, 1], unless there is a tabline, then it is [2, 1].
{nr} can be the window number or the |window-ID|. Use zero
for the current window.
- Return [0, 0] if the window cannot be found in the current
+ Returns [0, 0] if the window cannot be found in the current
tabpage.
win_splitmove({nr}, {target} [, {options}]) *win_splitmove()*
@@ -9871,14 +10132,17 @@ wordcount() *wordcount()*
*writefile()*
-writefile({list}, {fname} [, {flags}])
- Write |List| {list} to file {fname}. Each list item is
- separated with a NL. Each list item must be a String or
- Number.
+writefile({object}, {fname} [, {flags}])
+ When {object} is a |List| write it to file {fname}. Each list
+ item is separated with a NL. Each list item must be a String
+ or Number.
When {flags} contains "b" then binary mode is used: There will
not be a NL after the last list item. An empty item at the
end does cause the last line in the file to end in a NL.
+ When {object} is a |Blob| write the bytes to file {fname}
+ unmodified.
+
When {flags} contains "a" then append mode is used, lines are
appended to the file: >
:call writefile(["foo"], "event.log", "a")
@@ -10394,7 +10658,10 @@ This does NOT work: >
This cannot be used to set a byte in a String. You
can do that like this: >
:let var = var[0:2] . 'X' . var[4:]
-<
+< When {var-name} is a |Blob| then {idx} can be the
+ length of the blob, in which case one byte is
+ appended.
+
*E711* *E719*
:let {var-name}[{idx1}:{idx2}] = {expr1} *E708* *E709* *E710*
Set a sequence of items in a |List| to the result of
@@ -10405,14 +10672,15 @@ This does NOT work: >
When the selected range of items is partly past the
end of the list, items will be added.
- *:let+=* *:let-=* *:letstar=*
- *:let/=* *:let%=* *:let.=* *E734*
+ *:let+=* *:let-=* *:letstar=*
+ *:let/=* *:let%=* *:let.=* *:let..=* *E734*
:let {var} += {expr1} Like ":let {var} = {var} + {expr1}".
:let {var} -= {expr1} Like ":let {var} = {var} - {expr1}".
:let {var} *= {expr1} Like ":let {var} = {var} * {expr1}".
:let {var} /= {expr1} Like ":let {var} = {var} / {expr1}".
:let {var} %= {expr1} Like ":let {var} = {var} % {expr1}".
:let {var} .= {expr1} Like ":let {var} = {var} . {expr1}".
+:let {var} ..= {expr1} Like ":let {var} = {var} .. {expr1}".
These fail if {var} was not set yet and when the type
of {var} and {expr1} don't fit the operator.
@@ -10630,10 +10898,18 @@ text...
:const x = 1
< is equivalent to: >
:let x = 1
- :lockvar 1 x
+ :lockvar! x
< This is useful if you want to make sure the variable
- is not modified.
- *E995*
+ is not modified. If the value is a List or Dictionary
+ literal then the items also cannot be changed: >
+ const ll = [1, 2, 3]
+ let ll[1] = 5 " Error!
+< Nested references are not locked: >
+ let lvar = ['a']
+ const lconst = [0, lvar]
+ let lconst[0] = 2 " Error!
+ let lconst[1][0] = 'b' " OK
+< *E995*
|:const| does not allow to for changing a variable. >
:let x = 1
:const x = 2 " Error!
@@ -10750,28 +11026,34 @@ text...
NOTE: The ":append" and ":insert" commands don't work
properly inside a ":while" and ":for" loop.
-:for {var} in {list} *:for* *E690* *E732*
+:for {var} in {object} *:for* *E690* *E732*
:endfo[r] *:endfo* *:endfor*
Repeat the commands between ":for" and ":endfor" for
- each item in {list}. Variable {var} is set to the
- value of each item.
- When an error is detected for a command inside the
- loop, execution continues after the "endfor".
- Changing {list} inside the loop affects what items are
- used. Make a copy if this is unwanted: >
+ each item in {object}. {object} can be a |List| or
+ a |Blob|. Variable {var} is set to the value of each
+ item. When an error is detected for a command inside
+ the loop, execution continues after the "endfor".
+ Changing {object} inside the loop affects what items
+ are used. Make a copy if this is unwanted: >
:for item in copy(mylist)
-< When not making a copy, Vim stores a reference to the
- next item in the list, before executing the commands
- with the current item. Thus the current item can be
- removed without effect. Removing any later item means
- it will not be found. Thus the following example
- works (an inefficient way to make a list empty): >
+<
+ When {object} is a |List| and not making a copy, Vim
+ stores a reference to the next item in the |List|
+ before executing the commands with the current item.
+ Thus the current item can be removed without effect.
+ Removing any later item means it will not be found.
+ Thus the following example works (an inefficient way
+ to make a |List| empty): >
for item in mylist
call remove(mylist, 0)
endfor
-< Note that reordering the list (e.g., with sort() or
+< Note that reordering the |List| (e.g., with sort() or
reverse()) may have unexpected effects.
+ When {object} is a |Blob|, Vim always makes a copy to
+ iterate over. Unlike with |List|, modifying the
+ |Blob| does not affect the iteration.
+
:for [{var1}, {var2}, ...] in {listlist}
:endfo[r]
Like ":for" above, but each item in {listlist} must be
@@ -12031,7 +12313,7 @@ displayed.
*except-several-errors*
When several errors appear in a single command, the first error message is
-usually the most specific one and therefor converted to the error exception.
+usually the most specific one and therefore converted to the error exception.
Example: >
echo novar
causes >
diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt
index 8e2cb2f728..80c934d13b 100644
--- a/runtime/doc/fold.txt
+++ b/runtime/doc/fold.txt
@@ -535,6 +535,8 @@ nest, the nested fold is one character right of the fold it's contained in.
A closed fold is indicated with a '+'.
+These characters can be changed with the 'fillchars' option.
+
Where the fold column is too narrow to display all nested folds, digits are
shown to indicate the nesting level.
diff --git a/runtime/doc/if_perl.txt b/runtime/doc/if_perl.txt
index ddcf220844..3787ca69ba 100644
--- a/runtime/doc/if_perl.txt
+++ b/runtime/doc/if_perl.txt
@@ -189,6 +189,9 @@ VIM::Eval({expr}) Evaluates {expr} and returns (success, value) in list
A |List| is turned into a string by joining the items
and inserting line breaks.
+ *perl-Blob*
+VIM::Blob({expr}) Return Blob literal string 0zXXXX from scalar value.
+
==============================================================================
3. VIM::Buffer objects *perl-buffer*
diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt
index 9a279ad880..baa7bc1992 100644
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -155,6 +155,7 @@ commands in CTRL-X submode *i_CTRL-X_index*
|i_CTRL-X_CTRL-Y| CTRL-X CTRL-Y scroll down
|i_CTRL-X_CTRL-U| CTRL-X CTRL-U complete with 'completefunc'
|i_CTRL-X_CTRL-V| CTRL-X CTRL-V complete like in : command line
+|i_CTRL-X_CTRL-Z| CTRL-X CTRL-Z stop completion, keeping the text as-is
|i_CTRL-X_CTRL-]| CTRL-X CTRL-] complete tags
|i_CTRL-X_s| CTRL-X s spelling suggestions
@@ -1096,8 +1097,9 @@ tag command action in Command-line editing mode ~
==============================================================================
5. Terminal mode *terminal-mode-index*
-In a |terminal| buffer all keys except |CTRL-\_CTRL-N| are forwarded to the
-terminal job. Use CTRL-\_CTRL-N to go to Normal mode.
+In a |terminal| buffer all keys except CTRL-\ are forwarded to the terminal
+job. If CTRL-\ is pressed, the next key is forwarded unless it is CTRL-N.
+Use |CTRL-\_CTRL-N| to go to Normal mode.
You found it, Arthur! *holy-grail*
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index bb00c77ca8..bfc1c235ea 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -622,6 +622,8 @@ Completion can be done for:
12. Spelling suggestions |i_CTRL-X_s|
13. keywords in 'complete' |i_CTRL-N| |i_CTRL-P|
+Additionally, |i_CTRL-X_CTRL-Z| stops completion without changing the text.
+
All these, except CTRL-N and CTRL-P, are done in CTRL-X mode. This is a
sub-mode of Insert and Replace modes. You enter CTRL-X mode by typing CTRL-X
and one of the CTRL-X commands. You exit CTRL-X mode by typing a key that is
@@ -1022,6 +1024,12 @@ CTRL-P Find previous match for words that start with the
other contexts unless a double CTRL-X is used.
+Stop completion *compl-stop*
+
+ *i_CTRL-X_CTRL-Z*
+CTRL-X CTRL-Z Stop completion without changing the text.
+
+
FUNCTIONS FOR FINDING COMPLETIONS *complete-functions*
This applies to 'completefunc' and 'omnifunc'.
@@ -1053,7 +1061,8 @@ On the second invocation the arguments are:
The function must return a List with the matching words. These matches
usually include the "a:base" text. When there are no matches return an empty
-List.
+List. Note that the cursor may have moved since the first invocation, the
+text may have been changed.
In order to return more information than the matching words, return a Dict
that contains the List. The Dict can have these items:
@@ -1124,7 +1133,7 @@ match to the total list. These matches should then not appear in the returned
list! Call |complete_check()| now and then to allow the user to press a key
while still searching for matches. Stop searching when it returns non-zero.
- *E839* *E840*
+ *E840*
The function is allowed to move the cursor, it is restored afterwards.
The function is not allowed to move to another window or delete text.
diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt
index f739e2e88b..2baf3a247f 100644
--- a/runtime/doc/intro.txt
+++ b/runtime/doc/intro.txt
@@ -454,9 +454,10 @@ Ex mode Like Command-line mode, but after entering a command
command line. |Ex-mode|
*Terminal-mode*
-Terminal mode In Terminal mode all input (except |c_CTRL-\_CTRL-N|)
- is sent to the process running in the current
- |terminal| buffer.
+Terminal mode In Terminal mode all input (except CTRL-\) is sent to
+ the process running in the current |terminal| buffer.
+ If CTRL-\ is pressed, the next key is sent unless it
+ is CTRL-N (|CTRL-\_CTRL-N|).
If the 'showmode' option is on "-- TERMINAL --" is shown
at the bottom of the window.
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index e76e224596..48d65a22b6 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -424,121 +424,6 @@ LspReferenceRead used for highlighting "read" references
LspReferenceWrite used for highlighting "write" references
- *lsp-highlight-diagnostics*
-All highlights defined for diagnostics begin with `LspDiagnostics` followed by
-the type of highlight (e.g., `Sign`, `Underline`, etc.) and then the Severity
-of the highlight (e.g. `Error`, `Warning`, etc.)
-
-Sign, underline and virtual text highlights (by default) are linked to their
-corresponding LspDiagnosticsDefault highlight.
-
-For example, the default highlighting for |hl-LspDiagnosticsSignError| is
-linked to |hl-LspDiagnosticsDefaultError|. To change the default (and
-therefore the linked highlights), use the |:highlight| command: >
-
- highlight LspDiagnosticsDefaultError guifg="BrightRed"
-<
-
- *hl-LspDiagnosticsDefaultError*
-LspDiagnosticsDefaultError
- Used as the base highlight group.
- Other LspDiagnostic highlights link to this by default (except Underline)
-
- *hl-LspDiagnosticsDefaultWarning*
-LspDiagnosticsDefaultWarning
- Used as the base highlight group.
- Other LspDiagnostic highlights link to this by default (except Underline)
-
- *hl-LspDiagnosticsDefaultInformation*
-LspDiagnosticsDefaultInformation
- Used as the base highlight group.
- Other LspDiagnostic highlights link to this by default (except Underline)
-
- *hl-LspDiagnosticsDefaultHint*
-LspDiagnosticsDefaultHint
- Used as the base highlight group.
- Other LspDiagnostic highlights link to this by default (except Underline)
-
- *hl-LspDiagnosticsVirtualTextError*
-LspDiagnosticsVirtualTextError
- Used for "Error" diagnostic virtual text.
- See |vim.lsp.diagnostic.set_virtual_text()|
-
- *hl-LspDiagnosticsVirtualTextWarning*
-LspDiagnosticsVirtualTextWarning
- Used for "Warning" diagnostic virtual text.
- See |vim.lsp.diagnostic.set_virtual_text()|
-
- *hl-LspDiagnosticsVirtualTextInformation*
-LspDiagnosticsVirtualTextInformation
- Used for "Information" diagnostic virtual text.
- See |vim.lsp.diagnostic.set_virtual_text()|
-
- *hl-LspDiagnosticsVirtualTextHint*
-LspDiagnosticsVirtualTextHint
- Used for "Hint" diagnostic virtual text.
- See |vim.lsp.diagnostic.set_virtual_text()|
-
- *hl-LspDiagnosticsUnderlineError*
-LspDiagnosticsUnderlineError
- Used to underline "Error" diagnostics.
- See |vim.lsp.diagnostic.set_underline()|
-
- *hl-LspDiagnosticsUnderlineWarning*
-LspDiagnosticsUnderlineWarning
- Used to underline "Warning" diagnostics.
- See |vim.lsp.diagnostic.set_underline()|
-
- *hl-LspDiagnosticsUnderlineInformation*
-LspDiagnosticsUnderlineInformation
- Used to underline "Information" diagnostics.
- See |vim.lsp.diagnostic.set_underline()|
-
- *hl-LspDiagnosticsUnderlineHint*
-LspDiagnosticsUnderlineHint
- Used to underline "Hint" diagnostics.
- See |vim.lsp.diagnostic.set_underline()|
-
- *hl-LspDiagnosticsFloatingError*
-LspDiagnosticsFloatingError
- Used to color "Error" diagnostic messages in diagnostics float.
- See |vim.lsp.diagnostic.show_line_diagnostics()|
-
- *hl-LspDiagnosticsFloatingWarning*
-LspDiagnosticsFloatingWarning
- Used to color "Warning" diagnostic messages in diagnostics float.
- See |vim.lsp.diagnostic.show_line_diagnostics()|
-
- *hl-LspDiagnosticsFloatingInformation*
-LspDiagnosticsFloatingInformation
- Used to color "Information" diagnostic messages in diagnostics float.
- See |vim.lsp.diagnostic.show_line_diagnostics()|
-
- *hl-LspDiagnosticsFloatingHint*
-LspDiagnosticsFloatingHint
- Used to color "Hint" diagnostic messages in diagnostics float.
- See |vim.lsp.diagnostic.show_line_diagnostics()|
-
- *hl-LspDiagnosticsSignError*
-LspDiagnosticsSignError
- Used for "Error" signs in sign column.
- See |vim.lsp.diagnostic.set_signs()|
-
- *hl-LspDiagnosticsSignWarning*
-LspDiagnosticsSignWarning
- Used for "Warning" signs in sign column.
- See |vim.lsp.diagnostic.set_signs()|
-
- *hl-LspDiagnosticsSignInformation*
-LspDiagnosticsSignInformation
- Used for "Information" signs in sign column.
- See |vim.lsp.diagnostic.set_signs()|
-
- *hl-LspDiagnosticsSignHint*
-LspDiagnosticsSignHint
- Used for "Hint" signs in sign column.
- See |vim.lsp.diagnostic.set_signs()|
-
*lsp-highlight-codelens*
Highlight groups related to |lsp-codelens| functionality.
@@ -561,13 +446,6 @@ LspSignatureActiveParameter
|vim.lsp.handlers.signature_help()|.
==============================================================================
-AUTOCOMMANDS *lsp-autocommands*
-
- *LspDiagnosticsChanged*
-LspDiagnosticsChanged After receiving publishDiagnostics server response
-
-
-==============================================================================
Lua module: vim.lsp *lsp-core*
buf_attach_client({bufnr}, {client_id}) *vim.lsp.buf_attach_client()*
@@ -1207,220 +1085,20 @@ workspace_symbol({query}) *vim.lsp.buf.workspace_symbol()*
==============================================================================
Lua module: vim.lsp.diagnostic *lsp-diagnostic*
- *vim.lsp.diagnostic.clear()*
-clear({bufnr}, {client_id}, {diagnostic_ns}, {sign_ns})
- Clears the currently displayed diagnostics
-
- Parameters: ~
- {bufnr} number The buffer number
- {client_id} number the client id
- {diagnostic_ns} number|nil Associated diagnostic
- namespace
- {sign_ns} number|nil Associated sign namespace
-
-disable({bufnr}, {client_id}) *vim.lsp.diagnostic.disable()*
- Disable diagnostics for the given buffer and client
-
- Parameters: ~
- {bufnr} (optional, number): Buffer handle, defaults
- to current
- {client_id} (optional, number): Disable diagnostics for
- the given client. The default is to disable
- diagnostics for all attached clients.
-
-enable({bufnr}, {client_id}) *vim.lsp.diagnostic.enable()*
- Enable diagnostics for the given buffer and client
-
- Parameters: ~
- {bufnr} (optional, number): Buffer handle, defaults
- to current
- {client_id} (optional, number): Enable diagnostics for
- the given client. The default is to enable
- diagnostics for all attached clients.
-
-get({bufnr}, {client_id}, {predicate}) *vim.lsp.diagnostic.get()*
- Return associated diagnostics for bufnr
-
- Parameters: ~
- {bufnr} number
- {client_id} number|nil If nil, then return all of the
- diagnostics. Else, return just the
- diagnostics associated with the client_id.
- {predicate} function|nil Optional function for filtering
- diagnostics
-
-get_all({client_id}) *vim.lsp.diagnostic.get_all()*
- Get all diagnostics for clients
-
- Parameters: ~
- {client_id} number Restrict included diagnostics to the
- client If nil, diagnostics of all clients are
- included.
-
- Return: ~
- table with diagnostics grouped by bufnr (bufnr:Diagnostic[])
-
- *vim.lsp.diagnostic.get_count()*
-get_count({bufnr}, {severity}, {client_id})
- Get the counts for a particular severity
-
- Useful for showing diagnostic counts in statusline. eg:
->
-
- function! LspStatus() abort
- let sl = ''
- if luaeval('not vim.tbl_isempty(vim.lsp.buf_get_clients(0))')
- let sl.='%#MyStatuslineLSP#E:'
- let sl.='%#MyStatuslineLSPErrors#%{luaeval("vim.lsp.diagnostic.get_count(0, [[Error]])")}'
- let sl.='%#MyStatuslineLSP# W:'
- let sl.='%#MyStatuslineLSPWarnings#%{luaeval("vim.lsp.diagnostic.get_count(0, [[Warning]])")}'
- else
- let sl.='%#MyStatuslineLSPErrors#off'
- endif
- return sl
- endfunction
- let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus()
-<
-
- Parameters: ~
- {bufnr} number The buffer number
- {severity} DiagnosticSeverity
- {client_id} number the client id
-
- *vim.lsp.diagnostic.get_line_diagnostics()*
-get_line_diagnostics({bufnr}, {line_nr}, {opts}, {client_id})
- Get the diagnostics by line
-
- Parameters: ~
- {bufnr} number|nil The buffer number
- {line_nr} number|nil The line number
- {opts} table|nil Configuration keys
- • severity: (DiagnosticSeverity, default nil)
- • Only return diagnostics with this
- severity. Overrides severity_limit
-
- • severity_limit: (DiagnosticSeverity, default nil)
- • Limit severity of diagnostics found.
- E.g. "Warning" means { "Error",
- "Warning" } will be valid.
- {client_id|nil} number the client id
-
- Return: ~
- table Table with map of line number to list of
- diagnostics.
-
-get_next({opts}) *vim.lsp.diagnostic.get_next()*
- Get the next diagnostic closest to the cursor_position
-
- Parameters: ~
- {opts} table See |vim.lsp.diagnostic.goto_next()|
-
- Return: ~
- table Next diagnostic
-
-get_next_pos({opts}) *vim.lsp.diagnostic.get_next_pos()*
- Return the pos, {row, col}, for the next diagnostic in the
- current buffer.
-
- Parameters: ~
- {opts} table See |vim.lsp.diagnostic.goto_next()|
-
- Return: ~
- table Next diagnostic position
-
-get_prev({opts}) *vim.lsp.diagnostic.get_prev()*
- Get the previous diagnostic closest to the cursor_position
-
- Parameters: ~
- {opts} table See |vim.lsp.diagnostic.goto_next()|
-
- Return: ~
- table Previous diagnostic
-
-get_prev_pos({opts}) *vim.lsp.diagnostic.get_prev_pos()*
- Return the pos, {row, col}, for the prev diagnostic in the
- current buffer.
-
- Parameters: ~
- {opts} table See |vim.lsp.diagnostic.goto_next()|
-
- Return: ~
- table Previous diagnostic position
-
- *vim.lsp.diagnostic.get_virtual_text_chunks_for_line()*
-get_virtual_text_chunks_for_line({bufnr}, {line}, {line_diags}, {opts})
- Default function to get text chunks to display using
- |nvim_buf_set_extmark()|.
-
- Parameters: ~
- {bufnr} number The buffer to display the virtual
- text in
- {line} number The line number to display the
- virtual text on
- {line_diags} Diagnostic [] The diagnostics associated with the line
- {opts} table See {opts} from
- |vim.lsp.diagnostic.set_virtual_text()|
-
- Return: ~
- an array of [text, hl_group] arrays. This can be passed
- directly to the {virt_text} option of
- |nvim_buf_set_extmark()|.
-
-goto_next({opts}) *vim.lsp.diagnostic.goto_next()*
- Move to the next diagnostic
-
- Parameters: ~
- {opts} table|nil Configuration table. Keys:
- • {client_id}: (number)
- • If nil, will consider all clients attached to
- buffer.
-
- • {cursor_position}: (Position, default current
- position)
- • See |nvim_win_get_cursor()|
-
- • {wrap}: (boolean, default true)
- • Whether to loop around file or not. Similar to
- 'wrapscan'
-
- • {severity}: (DiagnosticSeverity)
- • Exclusive severity to consider. Overrides
- {severity_limit}
-
- • {severity_limit}: (DiagnosticSeverity)
- • Limit severity of diagnostics found. E.g.
- "Warning" means { "Error", "Warning" } will be
- valid.
-
- • {enable_popup}: (boolean, default true)
- • Call
- |vim.lsp.diagnostic.show_line_diagnostics()|
- on jump
-
- • {popup_opts}: (table)
- • Table to pass as {opts} parameter to
- |vim.lsp.diagnostic.show_line_diagnostics()|
-
- • {win_id}: (number, default 0)
- • Window ID
-
-goto_prev({opts}) *vim.lsp.diagnostic.goto_prev()*
- Move to the previous diagnostic
+get_namespace({client_id}) *vim.lsp.diagnostic.get_namespace()*
+ Get the diagnostic namespace associated with an LSP client
+ |vim.diagnostic|.
Parameters: ~
- {opts} table See |vim.lsp.diagnostic.goto_next()|
+ {client_id} number The id of the LSP client
*vim.lsp.diagnostic.on_publish_diagnostics()*
on_publish_diagnostics({_}, {result}, {ctx}, {config})
|lsp-handler| for the method "textDocument/publishDiagnostics"
- Note:
- Each of the configuration options accepts:
- • `false` : Disable this feature
- • `true` : Enable this feature, use default settings.
- • `table` : Enable this feature, use overrides.
- • `function`: Function with signature (bufnr, client_id) that
- returns any of the above.>
+ See |vim.diagnostic.config()| for configuration options.
+ Handler-specific configuration can be set using
+ |vim.lsp.with()|: >
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
@@ -1442,229 +1120,8 @@ on_publish_diagnostics({_}, {result}, {ctx}, {config})
<
Parameters: ~
- {config} table Configuration table.
- • underline: (default=true)
- • Apply underlines to diagnostics.
- • See |vim.lsp.diagnostic.set_underline()|
-
- • virtual_text: (default=true)
- • Apply virtual text to line endings.
- • See |vim.lsp.diagnostic.set_virtual_text()|
-
- • signs: (default=true)
- • Apply signs for diagnostics.
- • See |vim.lsp.diagnostic.set_signs()|
-
- • update_in_insert: (default=false)
- • Update diagnostics in InsertMode or wait
- until InsertLeave
-
- • severity_sort: (default=false)
- • Sort diagnostics (and thus signs and virtual
- text)
-
-redraw({bufnr}, {client_id}) *vim.lsp.diagnostic.redraw()*
- Redraw diagnostics for the given buffer and client
-
- This calls the "textDocument/publishDiagnostics" handler
- manually using the cached diagnostics already received from
- the server. This can be useful for redrawing diagnostics after
- making changes in diagnostics configuration.
- |lsp-handler-configuration|
-
- Parameters: ~
- {bufnr} (optional, number): Buffer handle, defaults
- to current
- {client_id} (optional, number): Redraw diagnostics for
- the given client. The default is to redraw
- diagnostics for all attached clients.
-
-reset({client_id}, {buffer_client_map}) *vim.lsp.diagnostic.reset()*
- Clear diagnotics and diagnostic cache
-
- Handles saving diagnostics from multiple clients in the same
- buffer.
-
- Parameters: ~
- {client_id} number
- {buffer_client_map} table map of buffers to active
- clients
-
-save({diagnostics}, {bufnr}, {client_id}) *vim.lsp.diagnostic.save()*
- Save diagnostics to the current buffer.
-
- Handles saving diagnostics from multiple clients in the same
- buffer.
-
- Parameters: ~
- {diagnostics} Diagnostic []
- {bufnr} number
- {client_id} number
-
-set_loclist({opts}) *vim.lsp.diagnostic.set_loclist()*
- Sets the location list
-
- Parameters: ~
- {opts} table|nil Configuration table. Keys:
- • {open}: (boolean, default true)
- • Open loclist after set
-
- • {client_id}: (number)
- • If nil, will consider all clients attached to
- buffer.
-
- • {severity}: (DiagnosticSeverity)
- • Exclusive severity to consider. Overrides
- {severity_limit}
-
- • {severity_limit}: (DiagnosticSeverity)
- • Limit severity of diagnostics found. E.g.
- "Warning" means { "Error", "Warning" } will be
- valid.
-
- • {workspace}: (boolean, default false)
- • Set the list with workspace diagnostics
-
-set_qflist({opts}) *vim.lsp.diagnostic.set_qflist()*
- Sets the quickfix list
-
- Parameters: ~
- {opts} table|nil Configuration table. Keys:
- • {open}: (boolean, default true)
- • Open quickfix list after set
-
- • {client_id}: (number)
- • If nil, will consider all clients attached to
- buffer.
-
- • {severity}: (DiagnosticSeverity)
- • Exclusive severity to consider. Overrides
- {severity_limit}
-
- • {severity_limit}: (DiagnosticSeverity)
- • Limit severity of diagnostics found. E.g.
- "Warning" means { "Error", "Warning" } will be
- valid.
-
- • {workspace}: (boolean, default true)
- • Set the list with workspace diagnostics
-
- *vim.lsp.diagnostic.set_signs()*
-set_signs({diagnostics}, {bufnr}, {client_id}, {sign_ns}, {opts})
- Set signs for given diagnostics
-
- Sign characters can be customized with the following commands:
->
-
- sign define LspDiagnosticsSignError text=E texthl=LspDiagnosticsSignError linehl= numhl=
- sign define LspDiagnosticsSignWarning text=W texthl=LspDiagnosticsSignWarning linehl= numhl=
- sign define LspDiagnosticsSignInformation text=I texthl=LspDiagnosticsSignInformation linehl= numhl=
- sign define LspDiagnosticsSignHint text=H texthl=LspDiagnosticsSignHint linehl= numhl=
-<
-
- Parameters: ~
- {diagnostics} Diagnostic []
- {bufnr} number The buffer number
- {client_id} number the client id
- {sign_ns} number|nil
- {opts} table Configuration for signs. Keys:
- • priority: Set the priority of the signs.
- • severity_limit (DiagnosticSeverity):
- • Limit severity of diagnostics found.
- E.g. "Warning" means { "Error",
- "Warning" } will be valid.
-
- *vim.lsp.diagnostic.set_underline()*
-set_underline({diagnostics}, {bufnr}, {client_id}, {diagnostic_ns}, {opts})
- Set underline for given diagnostics
-
- Underline highlights can be customized by changing the
- following |:highlight| groups.
->
-
- LspDiagnosticsUnderlineError
- LspDiagnosticsUnderlineWarning
- LspDiagnosticsUnderlineInformation
- LspDiagnosticsUnderlineHint
-<
-
- Parameters: ~
- {diagnostics} Diagnostic []
- {bufnr} number: The buffer number
- {client_id} number: The client id
- {diagnostic_ns} number|nil: The namespace
- {opts} table: Configuration table:
- • severity_limit (DiagnosticSeverity):
- • Limit severity of diagnostics found.
- E.g. "Warning" means { "Error",
- "Warning" } will be valid.
-
- *vim.lsp.diagnostic.set_virtual_text()*
-set_virtual_text({diagnostics}, {bufnr}, {client_id}, {diagnostic_ns}, {opts})
- Set virtual text given diagnostics
-
- Virtual text highlights can be customized by changing the
- following |:highlight| groups.
->
-
- LspDiagnosticsVirtualTextError
- LspDiagnosticsVirtualTextWarning
- LspDiagnosticsVirtualTextInformation
- LspDiagnosticsVirtualTextHint
-<
-
- Parameters: ~
- {diagnostics} Diagnostic []
- {bufnr} number
- {client_id} number
- {diagnostic_ns} number
- {opts} table Options on how to display virtual
- text. Keys:
- • prefix (string): Prefix to display
- before virtual text on line
- • spacing (number): Number of spaces to
- insert before virtual text
- • severity_limit (DiagnosticSeverity):
- • Limit severity of diagnostics found.
- E.g. "Warning" means { "Error",
- "Warning" } will be valid.
-
- *vim.lsp.diagnostic.show_line_diagnostics()*
-show_line_diagnostics({opts}, {buf_nr}, {line_nr}, {client_id})
- Parameters: ~
- {opts} table Configuration table
- • all opts for
- |vim.lsp.diagnostic.get_line_diagnostics()|
- and |show_diagnostics()| can be used here
- {buf_nr} number|nil The buffer number
- {line_nr} number|nil The line number
- {client_id} number|nil the client id
-
- Return: ~
- table {popup_bufnr, win_id}
-
- *vim.lsp.diagnostic.show_position_diagnostics()*
-show_position_diagnostics({opts}, {buf_nr}, {position})
- Open a floating window with the diagnostics from {position}
-
- Parameters: ~
- {opts} table|nil Configuration keys
- • severity: (DiagnosticSeverity, default nil)
- • Only return diagnostics with this
- severity. Overrides severity_limit
-
- • severity_limit: (DiagnosticSeverity, default nil)
- • Limit severity of diagnostics found. E.g.
- "Warning" means { "Error", "Warning" }
- will be valid.
-
- • all opts for |show_diagnostics()| can be
- used here
- {buf_nr} number|nil The buffer number
- {position} table|nil The (0,0)-indexed position
-
- Return: ~
- table {popup_bufnr, win_id}
+ {config} table Configuration table (see
+ |vim.diagnostic.config()|).
==============================================================================
@@ -1903,21 +1360,6 @@ create_file({change}) *vim.lsp.util.create_file()*
delete_file({change}) *vim.lsp.util.delete_file()*
TODO: Documentation
- *vim.lsp.util.diagnostics_to_items()*
-diagnostics_to_items({diagnostics_by_bufnr}, {predicate})
- Convert diagnostics grouped by bufnr to a list of items for
- use in the quickfix or location list.
-
- Parameters: ~
- {diagnostics_by_bufnr} table bufnr -> Diagnostic []
- {predicate} an optional function to filter the
- diagnostics. If present, only
- diagnostic items matching will be
- included.
-
- Return: ~
- table (A list of items)
-
*vim.lsp.util.extract_completion_items()*
extract_completion_items({result})
Can be used to extract the completion items from a `textDocument/completion` request, which may return one of `CompletionItem[]` , `CompletionList` or null.
@@ -1982,6 +1424,9 @@ locations_to_items({locations}) *vim.lsp.util.locations_to_items()*
and in sorted order, for display in quickfix and location
lists.
+ The result can be passed to the {list} argument of
+ |setqflist()| or |setloclist()|.
+
Parameters: ~
{locations} (table) list of `Location` s or
`LocationLink` s
@@ -2166,21 +1611,6 @@ set_lines({lines}, {A}, {B}, {new_lines}) *vim.lsp.util.set_lines()*
Return: ~
(table) The modified {lines} object
-set_loclist({items}, {win_id}) *vim.lsp.util.set_loclist()*
- Fills target window's location list with given list of items.
- Can be obtained with e.g. |vim.lsp.util.locations_to_items()|.
- Defaults to current window.
-
- Parameters: ~
- {items} (table) list of items
-
-set_qflist({items}) *vim.lsp.util.set_qflist()*
- Fills quickfix list with given list of items. Can be obtained
- with e.g. |vim.lsp.util.locations_to_items()|.
-
- Parameters: ~
- {items} (table) list of items
-
*vim.lsp.util.stylize_markdown()*
stylize_markdown({bufnr}, {contents}, {opts})
Converts markdown into syntax highlighted regions by stripping
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 3fd3875557..53d68fa5e6 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1,15 +1,15 @@
*lua.txt* Nvim
- NVIM REFERENCE MANUAL
+ NVIM REFERENCE MANUAL
-Lua engine *lua* *Lua*
+Lua engine *lua* *Lua*
Type |gO| to see the table of contents.
==============================================================================
-INTRODUCTION *lua-intro*
+INTRODUCTION *lua-intro*
The Lua 5.1 language is builtin and always available. Try this command to get
an idea of what lurks beneath: >
@@ -27,11 +27,12 @@ are on 'runtimepath':
~/.config/nvim/lua/foo.lua
then `require('foo')` loads "~/.config/nvim/lua/foo.lua", and
"runtime/lua/foo.lua" is not used. See |lua-require| to understand how Nvim
-finds and loads Lua modules. The conventions are similar to VimL plugins,
-with some extra features. See |lua-require-example| for a walkthrough.
+finds and loads Lua modules. The conventions are similar to those of
+Vimscript |plugin|s, with some extra features. See |lua-require-example| for
+a walkthrough.
==============================================================================
-IMPORTING LUA MODULES *lua-require*
+IMPORTING LUA MODULES *lua-require*
*lua-package-path*
Nvim automatically adjusts `package.path` and `package.cpath` according to
@@ -157,7 +158,7 @@ function without any parentheses. This is most often used to approximate
------------------------------------------------------------------------------
-LUA PLUGIN EXAMPLE *lua-require-example*
+LUA PLUGIN EXAMPLE *lua-require-example*
The following example plugin adds a command `:MakeCharBlob` which transforms
current buffer into a long `unsigned char` array. Lua contains transformation
@@ -234,7 +235,7 @@ lua/charblob.lua: >
}
==============================================================================
-COMMANDS *lua-commands*
+COMMANDS *lua-commands*
These commands execute a Lua chunk from either the command line (:lua, :luado)
or a file (:luafile) on the given line [range]. As always in Lua, each chunk
@@ -298,19 +299,20 @@ arguments separated by " " (space) instead of "\t" (tab).
:luado if bp:match(line) then return "-->\t" .. line end
<
- *:luafile*
+ *:luafile*
:[range]luafile {file}
- Execute Lua script in {file}.
- The whole argument is used as a single file name.
+ Execute Lua script in {file}.
+ The whole argument is used as the filename (like
+ |:edit|), spaces do not need to be escaped.
+ Alternatively you can |:source| Lua files.
- Examples:
- >
+ Examples: >
:luafile script.lua
:luafile %
<
==============================================================================
-luaeval() *lua-eval* *luaeval()*
+luaeval() *lua-eval* *luaeval()*
The (dual) equivalent of "vim.eval" for passing Lua values to Nvim is
"luaeval". "luaeval" takes an expression string and an optional argument used
@@ -324,8 +326,8 @@ semantically equivalent in Lua to:
end
Lua nils, numbers, strings, tables and booleans are converted to their
-respective VimL types. An error is thrown if conversion of any other Lua types
-is attempted.
+respective Vimscript types. If a Lua string contains a NUL byte, it will be
+converted to a |Blob|. Conversion of other Lua types is an error.
The magic global "_A" contains the second argument to luaeval().
@@ -348,21 +350,21 @@ cases there is the following agreement:
3. Table with string keys, at least one of which contains NUL byte, is also
considered to be a dictionary, but this time it is converted to
a |msgpack-special-map|.
- *lua-special-tbl*
+ *lua-special-tbl*
4. Table with `vim.type_idx` key may be a dictionary, a list or floating-point
value:
- - `{[vim.type_idx]=vim.types.float, [vim.val_idx]=1}` is converted to
- a floating-point 1.0. Note that by default integral Lua numbers are
- converted to |Number|s, non-integral are converted to |Float|s. This
+ - `{[vim.type_idx]=vim.types.float, [vim.val_idx]=1}` is converted to
+ a floating-point 1.0. Note that by default integral Lua numbers are
+ converted to |Number|s, non-integral are converted to |Float|s. This
variant allows integral |Float|s.
- - `{[vim.type_idx]=vim.types.dictionary}` is converted to an empty
- dictionary, `{[vim.type_idx]=vim.types.dictionary, [42]=1, a=2}` is
- converted to a dictionary `{'a': 42}`: non-string keys are ignored.
- Without `vim.type_idx` key tables with keys not fitting in 1., 2. or 3.
+ - `{[vim.type_idx]=vim.types.dictionary}` is converted to an empty
+ dictionary, `{[vim.type_idx]=vim.types.dictionary, [42]=1, a=2}` is
+ converted to a dictionary `{'a': 42}`: non-string keys are ignored.
+ Without `vim.type_idx` key tables with keys not fitting in 1., 2. or 3.
are errors.
- - `{[vim.type_idx]=vim.types.list}` is converted to an empty list. As well
- as `{[vim.type_idx]=vim.types.list, [42]=1}`: integral keys that do not
- form a 1-step sequence from 1 to N are ignored, as well as all
+ - `{[vim.type_idx]=vim.types.list}` is converted to an empty list. As well
+ as `{[vim.type_idx]=vim.types.list, [42]=1}`: integral keys that do not
+ form a 1-step sequence from 1 to N are ignored, as well as all
non-integral keys.
Examples: >
@@ -373,13 +375,13 @@ Examples: >
: endfunction
:echo Rand(1,10)
-Note: second argument to `luaeval` undergoes VimL to Lua conversion
-("marshalled"), so changes to Lua containers do not affect values in VimL.
-Return value is also always converted. When converting,
-|msgpack-special-dict|s are treated specially.
+Note: second argument to `luaeval` is converted ("marshalled") from Vimscript
+to Lua, so changes to Lua containers do not affect values in Vimscript. Return
+value is also always converted. When converting, |msgpack-special-dict|s are
+treated specially.
==============================================================================
-Vimscript v:lua interface *v:lua-call*
+Vimscript v:lua interface *v:lua-call*
From Vimscript the special `v:lua` prefix can be used to call Lua functions
which are global or accessible from global tables. The expression >
@@ -419,7 +421,7 @@ Note: `v:lua` without a call is not allowed in a Vimscript expression:
==============================================================================
-Lua standard modules *lua-stdlib*
+Lua standard modules *lua-stdlib*
The Nvim Lua "standard library" (stdlib) is the `vim` module, which exposes
various functions and sub-modules. It is always loaded, thus require("vim")
@@ -453,7 +455,7 @@ Note that underscore-prefixed functions (e.g. "_os_proc_children") are
internal/private and must not be used by plugins.
------------------------------------------------------------------------------
-VIM.LOOP *lua-loop* *vim.loop*
+VIM.LOOP *lua-loop* *vim.loop*
`vim.loop` exposes all features of the Nvim event-loop. This is a low-level
API that provides functionality for networking, filesystem, and process
@@ -464,7 +466,7 @@ management. Try this command to see available functions: >
Reference: https://github.com/luvit/luv/blob/master/docs.md
Examples: https://github.com/luvit/luv/tree/master/examples
- *E5560* *lua-loop-callbacks*
+ *E5560* *lua-loop-callbacks*
It is an error to directly invoke `vim.api` functions (except |api-fast|) in
`vim.loop` callbacks. For example, this is an error: >
@@ -500,7 +502,7 @@ Example: repeating timer
print('sleeping');
-Example: File-change detection *watch-file*
+Example: File-change detection *watch-file*
1. Save this code to a file.
2. Execute it with ":luafile %".
3. Use ":Watch %" to watch any file.
@@ -526,7 +528,7 @@ Example: File-change detection *watch-file*
"command! -nargs=1 Watch call luaeval('watch_file(_A)', expand('<args>'))")
-Example: TCP echo-server *tcp-server*
+Example: TCP echo-server *tcp-server*
1. Save this code to a file.
2. Execute it with ":luafile %".
3. Note the port number.
@@ -556,7 +558,7 @@ Example: TCP echo-server *tcp-server*
print('TCP echo-server listening on port: '..server:getsockname().port)
------------------------------------------------------------------------------
-VIM.HIGHLIGHT *lua-highlight*
+VIM.HIGHLIGHT *lua-highlight*
Nvim includes a function for highlighting a selection on yank (see for example
https://github.com/machakann/vim-highlightedyank). To enable it, add
@@ -591,21 +593,19 @@ vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {rtype}, {inclu
range is inclusive (default false).
------------------------------------------------------------------------------
-VIM.REGEX *lua-regex*
+VIM.REGEX *lua-regex*
Vim regexes can be used directly from lua. Currently they only allow
matching within a single line.
-vim.regex({re}) *vim.regex()*
+vim.regex({re}) *vim.regex()*
+ Parse the Vim regex {re} and return a regex object. Regexes are
+ "magic" and case-insensitive by default, regardless of 'magic' and
+ 'ignorecase'. The can be controlled with flags, see |/magic|.
- Parse the regex {re} and return a regex object. 'magic' and
- 'ignorecase' options are ignored, lua regexes always defaults to magic
- and ignoring case. The behavior can be changed with flags in
- the beginning of the string |/magic|.
+Methods on the regex object:
-Regex objects support the following methods:
-
-regex:match_str({str}) *regex:match_str()*
+regex:match_str({str}) *regex:match_str()*
Match the string against the regex. If the string should match the
regex precisely, surround the regex with `^` and `$`.
If the was a match, the byte indices for the beginning and end of
@@ -613,7 +613,7 @@ regex:match_str({str}) *regex:match_str()*
As any integer is truth-y, `regex:match()` can be directly used
as a condition in an if-statement.
-regex:match_line({bufnr}, {line_idx}[, {start}, {end}]) *regex:match_line()*
+regex:match_line({bufnr}, {line_idx}[, {start}, {end}]) *regex:match_line()*
Match line {line_idx} (zero-based) in buffer {bufnr}. If {start} and
{end} are supplied, match only this byte index range. Otherwise see
|regex:match_str()|. If {start} is used, then the returned byte
@@ -692,67 +692,65 @@ VIM.MPACK *lua-mpack*
The *vim.mpack* module provides packing and unpacking of lua objects to
msgpack encoded strings. |vim.NIL| and |vim.empty_dict()| are supported.
-vim.mpack.pack({obj}) *vim.mpack.pack*
+vim.mpack.pack({obj}) *vim.mpack.pack*
Packs a lua object {obj} and returns the msgpack representation as
a string
-vim.mpack.unpack({str}) *vim.mpack.unpack*
+vim.mpack.unpack({str}) *vim.mpack.unpack*
Unpacks the msgpack encoded {str} and returns a lua object
------------------------------------------------------------------------------
-VIM *lua-builtin*
+VIM *lua-builtin*
-vim.api.{func}({...}) *vim.api*
+vim.api.{func}({...}) *vim.api*
Invokes Nvim |API| function {func} with arguments {...}.
Example: call the "nvim_get_current_line()" API function: >
print(tostring(vim.api.nvim_get_current_line()))
-vim.version() *vim.version*
- Returns the version of the current neovim build.
+vim.version() *vim.version*
+ Gets the version of the current Nvim build.
-vim.in_fast_event() *vim.in_fast_event()*
+vim.in_fast_event() *vim.in_fast_event()*
Returns true if the code is executing as part of a "fast" event
handler, where most of the API is disabled. These are low-level events
(e.g. |lua-loop-callbacks|) which can be invoked whenever Nvim polls
for input. When this is `false` most API functions are callable (but
may be subject to other restrictions such as |textlock|).
-vim.NIL *vim.NIL*
- Special value used to represent NIL in msgpack-rpc and |v:null| in
- vimL interaction, and similar cases. Lua `nil` cannot be used as
- part of a lua table representing a Dictionary or Array, as it
- is equivalent to a missing value: `{"foo", nil}` is the same as
- `{"foo"}`
+vim.NIL *vim.NIL*
+ Special value representing NIL in |RPC| and |v:null| in Vimscript
+ conversion, and similar cases. Lua `nil` cannot be used as part of
+ a Lua table representing a Dictionary or Array, because it is
+ treated as missing: `{"foo", nil}` is the same as `{"foo"}`.
-vim.empty_dict() *vim.empty_dict()*
- Creates a special table which will be converted to an empty
- dictionary when converting lua values to vimL or API types. The
- table is empty, and this property is marked using a metatable. An
- empty table `{}` without this metatable will default to convert to
- an array/list.
+vim.empty_dict() *vim.empty_dict()*
+ Creates a special empty table (marked with a metatable), which Nvim
+ converts to an empty dictionary when translating Lua values to
+ Vimscript or API types. Nvim by default converts an empty table `{}`
+ without this metatable to an list/array.
- Note: if numeric keys are added to the table, the metatable will be
- ignored and the dict converted to a list/array anyway.
+ Note: if numeric keys are present in the table, Nvim ignores the
+ metatable marker and converts the dict to a list/array anyway.
-vim.rpcnotify({channel}, {method}[, {args}...]) *vim.rpcnotify()*
- Sends {event} to {channel} via |RPC| and returns immediately.
- If {channel} is 0, the event is broadcast to all channels.
+vim.rpcnotify({channel}, {method}[, {args}...]) *vim.rpcnotify()*
+ Sends {event} to {channel} via |RPC| and returns immediately. If
+ {channel} is 0, the event is broadcast to all channels.
- This function also works in a fast callback |lua-loop-callbacks|.
+ This function also works in a fast callback |lua-loop-callbacks|.
-vim.rpcrequest({channel}, {method}[, {args}...]) *vim.rpcrequest()*
- Sends a request to {channel} to invoke {method} via
- |RPC| and blocks until a response is received.
+vim.rpcrequest({channel}, {method}[, {args}...]) *vim.rpcrequest()*
+ Sends a request to {channel} to invoke {method} via |RPC| and blocks
+ until a response is received.
- Note: NIL values as part of the return value is represented as
- |vim.NIL| special value
+ Note: NIL values as part of the return value is represented as
+ |vim.NIL| special value
-vim.stricmp({a}, {b}) *vim.stricmp()*
+vim.stricmp({a}, {b}) *vim.stricmp()*
Compares strings case-insensitively. Returns 0, 1 or -1 if strings
are equal, {a} is greater than {b} or {a} is lesser than {b},
respectively.
-vim.str_utfindex({str}[, {index}]) *vim.str_utfindex()*
+vim.str_utfindex({str}[, {index}]) *vim.str_utfindex()*
Convert byte index to UTF-32 and UTF-16 indicies. If {index} is not
supplied, the length of the string is used. All indicies are zero-based.
Returns two values: the UTF-32 and UTF-16 indicies respectively.
@@ -840,40 +838,40 @@ vim.wait({time} [, {callback}, {interval}, {fast_only}]) *vim.wait()*
end
<
-vim.type_idx *vim.type_idx*
- Type index for use in |lua-special-tbl|. Specifying one of the
- values from |vim.types| allows typing the empty table (it is
- unclear whether empty Lua table represents empty list or empty array)
- and forcing integral numbers to be |Float|. See |lua-special-tbl| for
- more details.
+vim.type_idx *vim.type_idx*
+ Type index for use in |lua-special-tbl|. Specifying one of the values
+ from |vim.types| allows typing the empty table (it is unclear whether
+ empty Lua table represents empty list or empty array) and forcing
+ integral numbers to be |Float|. See |lua-special-tbl| for more
+ details.
-vim.val_idx *vim.val_idx*
- Value index for tables representing |Float|s. A table representing
- floating-point value 1.0 looks like this: >
+vim.val_idx *vim.val_idx*
+ Value index for tables representing |Float|s. A table representing
+ floating-point value 1.0 looks like this: >
{
[vim.type_idx] = vim.types.float,
[vim.val_idx] = 1.0,
}
-< See also |vim.type_idx| and |lua-special-tbl|.
-
-vim.types *vim.types*
- Table with possible values for |vim.type_idx|. Contains two sets
- of key-value pairs: first maps possible values for |vim.type_idx|
- to human-readable strings, second maps human-readable type names to
- values for |vim.type_idx|. Currently contains pairs for `float`,
- `array` and `dictionary` types.
-
- Note: one must expect that values corresponding to `vim.types.float`,
- `vim.types.array` and `vim.types.dictionary` fall under only two
- following assumptions:
- 1. Value may serve both as a key and as a value in a table. Given the
- properties of Lua tables this basically means “value is not `nil`”.
- 2. For each value in `vim.types` table `vim.types[vim.types[value]]`
- is the same as `value`.
- No other restrictions are put on types, and it is not guaranteed that
- values corresponding to `vim.types.float`, `vim.types.array` and
- `vim.types.dictionary` will not change or that `vim.types` table will
- only contain values for these three types.
+< See also |vim.type_idx| and |lua-special-tbl|.
+
+vim.types *vim.types*
+ Table with possible values for |vim.type_idx|. Contains two sets of
+ key-value pairs: first maps possible values for |vim.type_idx| to
+ human-readable strings, second maps human-readable type names to
+ values for |vim.type_idx|. Currently contains pairs for `float`,
+ `array` and `dictionary` types.
+
+ Note: one must expect that values corresponding to `vim.types.float`,
+ `vim.types.array` and `vim.types.dictionary` fall under only two
+ following assumptions:
+ 1. Value may serve both as a key and as a value in a table. Given the
+ properties of Lua tables this basically means “value is not `nil`”.
+ 2. For each value in `vim.types` table `vim.types[vim.types[value]]`
+ is the same as `value`.
+ No other restrictions are put on types, and it is not guaranteed that
+ values corresponding to `vim.types.float`, `vim.types.array` and
+ `vim.types.dictionary` will not change or that `vim.types` table will
+ only contain values for these three types.
------------------------------------------------------------------------------
LUA-VIMSCRIPT BRIDGE *lua-vimscript*
@@ -907,7 +905,7 @@ vim.fn.{func}({...}) *vim.fn*
To call autoload functions, use the syntax: >
vim.fn['some#function']({...})
<
- Unlike vim.api.|nvim_call_function| this converts directly between Vim
+ Unlike vim.api.|nvim_call_function()| this converts directly between Vim
objects and Lua objects. If the Vim function returns a float, it will
be represented directly as a Lua number. Empty lists and dictionaries
both are represented by an empty table.
@@ -966,8 +964,8 @@ vim.env *vim.env*
*lua-vim-optlocal*
*lua-vim-setlocal*
-In vimL, there is a succint and simple way to set options. For more
-information, see |set-option|. In Lua, the corresponding method is `vim.opt`.
+In Vimscript, there is an way to set options |set-option|. In Lua, the
+corresponding method is `vim.opt`.
`vim.opt` provides several conveniences for setting and controlling options
from within Lua.
@@ -975,18 +973,18 @@ from within Lua.
Examples: ~
To set a boolean toggle:
- In vimL:
+ In Vimscript:
`set number`
In Lua:
`vim.opt.number = true`
To set an array of values:
- In vimL:
+ In Vimscript:
`set wildignore=*.o,*.a,__pycache__`
In Lua, there are two ways you can do this now. One is very similar to
- the vimL way:
+ the Vimscript form:
`vim.opt.wildignore = '*.o,*.a,__pycache__'`
However, vim.opt also supports a more elegent way of setting
@@ -1019,7 +1017,7 @@ from within Lua.
vim.opt.wildignore:remove { "node_modules" }
<
To set a map of values:
- In vimL:
+ In Vimscript:
`set listchars=space:_,tab:>~`
In Lua:
@@ -1268,7 +1266,17 @@ schedule_wrap({cb}) *vim.schedule_wrap()*
deep_equal({a}, {b}) *vim.deep_equal()*
- TODO: Documentation
+ Deep compare values for equality
+
+ Tables are compared recursively unless they both provide the `eq` methamethod.
+ All other types are compared using the equality `==` operator.
+
+ Parameters: ~
+ {a} first value
+ {b} second value
+
+ Return: ~
+ `true` if values are equals, else `false` .
deepcopy({orig}) *vim.deepcopy()*
Returns a deep copy of the given object. Non-table objects are
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index 0bf58f85fc..5ad69d1122 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -47,8 +47,9 @@ Input *terminal-input*
To send input, enter |Terminal-mode| using any command that would enter "insert
mode" in a normal buffer, such as |i| or |:startinsert|. In this mode all keys
-except <C-\><C-N> are sent to the underlying program. Use <C-\><C-N> to return
-to normal-mode. |CTRL-\_CTRL-N|
+except <C-\> are sent to the underlying program. If <C-\> is pressed, the
+next key is sent unless it is <C-N>. Use <C-\><C-N> to return to normal-mode.
+|CTRL-\_CTRL-N|
Terminal-mode forces these local options:
@@ -320,6 +321,34 @@ Other commands ~
isn't one
+Events ~
+ *termdebug-events*
+Four autocommands can be used: >
+ au User TermdebugStartPre echomsg 'debugging starting'
+ au User TermdebugStartPost echomsg 'debugging started'
+ au User TermdebugStopPre echomsg 'debugging stopping'
+ au User TermdebugStopPost echomsg 'debugging stopped'
+<
+ *TermdebugStartPre*
+TermdebugStartPre Before starting debugging.
+ Not triggered if the debugger is already
+ running or |g:termdebugger| cannot be
+ executed.
+ *TermdebugStartPost*
+TermdebugStartPost After debugging has initialized.
+ If a "!" bang is passed to `:Termdebug` or
+ `:TermdebugCommand` the event is triggered
+ before running the provided command in gdb.
+ *TermdebugStopPre*
+TermdebugStopPre Before debugging ends, when gdb is terminated,
+ most likely after issuing a "quit" command in
+ the gdb window.
+ *TermdebugStopPost*
+TermdebugStopPost After debugging has ended, gdb-related windows
+ are closed, debug buffers wiped out and
+ the state before the debugging was restored.
+
+
Prompt mode ~
*termdebug-prompt*
When on MS-Windows, gdb will run in a buffer with 'buftype' set to "prompt".
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 1a703129d6..cc7524988d 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -3806,8 +3806,6 @@ A jump table for the options with a short description can be found at |Q_op|.
Only switch it off when working with old Vi scripts. In any other
situation write patterns that work when 'magic' is on. Include "\M"
when you want to |/\M|.
- In |Vim9| script the value of 'magic' is ignored, patterns behave like
- it is always set.
*'makeef'* *'mef'*
'makeef' 'mef' string (default: "")
@@ -5485,7 +5483,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'showbreak'* *'sbr'* *E595*
'showbreak' 'sbr' string (default "")
- global
+ global or local to window |global-local|
String to put at the start of lines that have been wrapped. Useful
values are "> " or "+++ ": >
:set showbreak=>\
@@ -5499,7 +5497,10 @@ A jump table for the options with a short description can be found at |Q_op|.
Note that tabs after the showbreak will be displayed differently.
If you want the 'showbreak' to appear in between line numbers, add the
"n" flag to 'cpoptions'.
-
+ A window-local value overrules a global value. If the global value is
+ set and you want no value in the current window use NONE: >
+ :setlocal showbreak=NONE
+<
*'showcmd'* *'sc'* *'noshowcmd'* *'nosc'*
'showcmd' 'sc' boolean (Vim default: on, Vi default: off)
global
@@ -5759,6 +5760,8 @@ A jump table for the options with a short description can be found at |Q_op|.
If the name "cjk" is included East Asian characters are excluded from
spell checking. This is useful when editing text that also has Asian
words.
+ Note that the "medical" dictionary does not exist, it is just an
+ example of a longer name.
*E757*
As a special case the name of a .spl file can be given as-is. The
first "_xx" in the name is removed and used as the region name
@@ -6755,6 +6758,7 @@ A jump table for the options with a short description can be found at |Q_op|.
The `g$` command will move to the end of the screen line.
It doesn't make sense to combine "all" with "onemore", but you will
not get a warning for it.
+ When combined with other words, "none" is ignored.
*'visualbell'* *'vb'* *'novisualbell'* *'novb'* *beep*
'visualbell' 'vb' boolean (default off)
diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt
index a39d1e8dc9..3ac61be6f2 100644
--- a/runtime/doc/pi_netrw.txt
+++ b/runtime/doc/pi_netrw.txt
@@ -54,6 +54,7 @@ Copyright: Copyright (C) 2017 Charles E Campbell *netrw-copyright*
Browsing With A Horizontally Split Window...........|netrw-o|
Browsing With A New Tab.............................|netrw-t|
Browsing With A Vertically Split Window.............|netrw-v|
+ Change File Permission..............................|netrw-gp|
Change Listing Style.(thin wide long tree)..........|netrw-i|
Changing To A Bookmarked Directory..................|netrw-gb|
Changing To A Predecessor Directory.................|netrw-u|
@@ -1095,6 +1096,7 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2
gf Force treatment as file |netrw-gf|
gh Quick hide/unhide of dot-files |netrw-gh|
gn Make top of tree the directory below the cursor |netrw-gn|
+ gp Change local-only file permissions |netrw-gp|
i Cycle between thin, long, wide, and tree listings |netrw-i|
I Toggle the displaying of the banner |netrw-I|
mb Bookmark current directory |netrw-mb|
@@ -1510,6 +1512,8 @@ Netrw determines which special handler by the following method:
If g:netrw_browsex_viewer == '-', then netrwFileHandlers#Invoke() will be
used instead (see |netrw_filehandler|).
+ If the viewer you wish to use does not support handling of a remote URL
+ directory, set |g:netrw_browsex_support_remote| to 0.
* for Windows 32 or 64, the URL and FileProtocolHandler dlls are used.
* for Gnome (with gnome-open): gnome-open is used.
* for KDE (with kfmclient) : kfmclient is used
@@ -2104,8 +2108,8 @@ the two directories the same, use the "cd" map (type cd). That map will
set Vim's notion of the current directory to netrw's current browsing
directory.
-|netrw-cd|: This map's name was changed from "c" to cd (see |netrw-cd|).
- This change was done to allow for |netrw-cb| and |netrw-cB| maps.
+|netrw-cd| : This map's name was changed from "c" to cd (see |netrw-cd|).
+ This change was done to allow for |netrw-cb| and |netrw-cB| maps.
Associated setting variable: |g:netrw_keepdir|
@@ -2607,13 +2611,29 @@ your browsing preferences. (see also: |netrw-settings|)
a script/function to handle the given
extension. (see |netrw_filehandler|).
+ *g:netrw_browsex_support_remote*
+ specify if the specified viewer supports a
+ remote URL. (see |netrw-handler|).
+
*g:netrw_chgperm* Unix/Linux: "chmod PERM FILENAME"
Windows: "cacls FILENAME /e /p PERM"
Used to change access permission for a file.
+ *g:netrw_clipboard* =1
+ By default, netrw will attempt to insure that
+ the clipboard's values will remain unchanged.
+ However, some users report that they have
+ speed problems with this; consequently, this
+ option, when set to zero, lets such users
+ prevent netrw from saving and restoring the
+ clipboard (the latter is done only as needed).
+ That means that if the clipboard is changed
+ (inadvertently) by normal netrw operation that
+ it will not be restored to its prior state.
+
*g:netrw_compress* ="gzip"
- Will compress marked files with this
- command
+ Will compress marked files with this
+ command
*g:Netrw_corehandler* Allows one to specify something additional
to do when handling <core> files via netrw's
@@ -2639,12 +2659,23 @@ your browsing preferences. (see also: |netrw-settings|)
=2 cul u-cuc cul u-cuc
=3 cul u-cuc cul cuc
=4 cul cuc cul cuc
+ =5 U-cul U-cuc U-cul U-cuc
+ =6 U-cul U-cuc cul U-cuc
+ =7 cul U-cuc cul U-cuc
+ =8 cul U-cuc cul cuc
Where
- u-cul : user's |'cursorline'| setting used
- u-cuc : user's |'cursorcolumn'| setting used
- cul : |'cursorline'| locally set
- cuc : |'cursorcolumn'| locally set
+ u-cul : user's |'cursorline'| initial setting used
+ u-cuc : user's |'cursorcolumn'| initial setting used
+ U-cul : user's |'cursorline'| current setting used
+ U-cuc : user's |'cursorcolumn'| current setting used
+ cul : |'cursorline'| will be locally set
+ cuc : |'cursorcolumn'| will be locally set
+
+ The "initial setting" means the values of
+ the |'cuc'| and |'cul'| settings in effect when
+ netrw last saw |g:netrw_cursor| >= 5 or when
+ netrw was initially run.
*g:netrw_decompress* = { ".gz" : "gunzip" ,
".bz2" : "bunzip2" ,
@@ -2654,7 +2685,7 @@ your browsing preferences. (see also: |netrw-settings|)
decompression programs.
*g:netrw_dirhistmax* =10: controls maximum quantity of past
- history. May be zero to supppress
+ history. May be zero to suppress
history.
(related: |netrw-qb| |netrw-u| |netrw-U|)
@@ -3141,6 +3172,9 @@ To open a new file in netrw's current directory, press "%". This map
will query the user for a new filename; an empty file by that name will
be placed in the netrw's current directory (ie. b:netrw_curdir).
+If Lexplore (|netrw-:Lexplore|) is in use, the new file will be generated
+in the |g:netrw_chgwin| window.
+
Related topics: |netrw-d|
@@ -3808,7 +3842,7 @@ netrw:
Decho.vim is provided as a "vimball"; see |vimball-intro|. You
should edit the Decho.vba.gz file and source it in: >
- vim Decho.vba.gz
+ vim Decho.vba.gz
:so %
:q
<
@@ -3876,6 +3910,32 @@ netrw:
==============================================================================
12. History *netrw-history* {{{1
+ v171: Oct 09, 2020 * included code in s:NetrwOptionsSafe()
+ to allow |'bh'| to be set to delete when
+ rather than hide when g:netrw_fastbrowse
+ was zero.
+ * Installed |g:netrw_clipboard| setting
+ * Installed option bypass for |'guioptions'|
+ a/A settings
+ * Changed popup_beval() to |popup_atcursor|()
+ in netrw#ErrorMsg (lacygoill). Apparently
+ popup_beval doesn't reliably close the
+ popup when the mouse is moved.
+ * VimEnter() now using win_execute to examine
+ buffers for an attempt to open a directory.
+ Avoids issues with popups/terminal from
+ command line. (lacygoill)
+ Jun 28, 2021 * (zeertzjq) provided a patch for use of
+ xmap,xno instead of vmap,vno in
+ netrwPlugin.vim. Avoids entanglement with
+ select mode.
+ Jul 14, 2021 * Fixed problem addressed by tst976; opening
+ a file using tree mode, going up a
+ directory, and opening a file there was
+ opening the file in the wrong directory.
+ Jul 28, 2021 * (Ingo Karkat) provided a patch fixing an
+ E488 error with netrwPlugin.vim
+ (occurred for vim versions < 8.02)
v170: Mar 11, 2020 * (reported by Reiner Herrmann) netrw+tree
would not hide with the ^\..* pattern
correctly.
@@ -3892,7 +3952,7 @@ netrw:
Jun 07, 2020 * (reported by Jo Totland) repeatedly invoking
:Lexplore and quitting it left unused
hidden buffers. Netrw will now set netrw
- buffers created by :Lexplore to |bh|=wipe.
+ buffers created by :Lexplore to |'bh'|=wipe.
v169: Dec 20, 2019 * (reported by amkarthik) that netrw's x
(|netrw-x|) would throw an error when
attempting to open a local directory.
diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt
index be895f9e4e..b785010699 100644
--- a/runtime/doc/provider.txt
+++ b/runtime/doc/provider.txt
@@ -207,6 +207,7 @@ registers. Nvim looks for these clipboard tools, in order of priority:
- lemonade (for SSH) https://github.com/pocke/lemonade
- doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/
- win32yank (Windows)
+ - termux (via termux-clipboard-set, termux-clipboard-set)
- tmux (if $TMUX is set)
*g:clipboard*
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt
index ed770434d5..5fdd5fc3c0 100644
--- a/runtime/doc/repeat.txt
+++ b/runtime/doc/repeat.txt
@@ -172,15 +172,16 @@ Using Vim scripts *using-scripts*
For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
*:so* *:source* *load-vim-script*
-:so[urce] {file} Runs |Ex| commands or Lua code (".lua" files) read
- from {file}.
+:[range]so[urce] [file] Runs |Ex| commands or Lua code (".lua" files) from
+ [file], or from the current buffer if no [file] is
+ given.
Triggers the |SourcePre| autocommand.
*:source!*
-:so[urce]! {file} Runs |Normal-mode| commands read from {file}. When
- used after |:global|, |:argdo|, |:windo|, |:bufdo|, in
+:[range]so[urce]! {file}
+ Runs |Normal-mode| commands from {file}. When used
+ after |:global|, |:argdo|, |:windo|, |:bufdo|, in
a loop or when another command follows the display
won't be updated while executing the commands.
- Cannot be used in the |sandbox|.
*:ru* *:runtime*
:ru[ntime][!] [where] {file} ..
@@ -201,10 +202,12 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
When [!] is included, all found files are sourced.
Else only the first found file is sourced.
- When [where] is omitted only 'runtimepath' is used.
+ When [where] is omitted, first 'runtimepath' is
+ searched, then directories under "start" in 'packpath'
+ are searched.
Other values:
- START search under "start" in 'packpath'
- OPT search under "opt" in 'packpath'
+ START search only under "start" in 'packpath'
+ OPT search only under "opt" in 'packpath'
PACK search under "start" and "opt" in
'packpath'
ALL first use 'runtimepath', then search
@@ -821,8 +824,12 @@ DEFINING BREAKPOINTS
Sets a breakpoint, that will break whenever the {expression}
evaluates to a different value. Example: >
:breakadd expr g:lnum
-
< Will break, whenever the global variable lnum changes.
+
+ Errors in evaluation are suppressed, you can use the name of a
+ variable that does not exist yet. This also means you will
+ not notice anything if the expression has a mistake.
+
Note if you watch a |script-variable| this will break
when switching scripts, since the script variable is only
valid in the script where it has been defined and if that
diff --git a/runtime/doc/sign.txt b/runtime/doc/sign.txt
index e8ed29c1a4..5079d900c9 100644
--- a/runtime/doc/sign.txt
+++ b/runtime/doc/sign.txt
@@ -435,13 +435,13 @@ sign_getdefined([{name}]) *sign_getdefined()*
" Get the attribute of the sign named mySign
echo sign_getdefined("mySign")
<
-sign_getplaced([{expr} [, {dict}]]) *sign_getplaced()*
+sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
Return a list of signs placed in a buffer or all the buffers.
This is similar to the |:sign-place-list| command.
- If the optional buffer name {expr} is specified, then only the
+ If the optional buffer name {buf} is specified, then only the
list of signs placed in that buffer is returned. For the use
- of {expr}, see |bufname()|. The optional {dict} can contain
+ of {buf}, see |bufname()|. The optional {dict} can contain
the following entries:
group select only signs in this group
id select sign with this identifier
@@ -496,12 +496,12 @@ sign_getplaced([{expr} [, {dict}]]) *sign_getplaced()*
echo sign_getplaced()
<
*sign_jump()*
-sign_jump({id}, {group}, {expr})
- Open the buffer {expr} or jump to the window that contains
- {expr} and position the cursor at sign {id} in group {group}.
+sign_jump({id}, {group}, {buf})
+ Open the buffer {buf} or jump to the window that contains
+ {buf} and position the cursor at sign {id} in group {group}.
This is similar to the |:sign-jump| command.
- For the use of {expr}, see |bufname()|.
+ For the use of {buf}, see |bufname()|.
Returns the line number of the sign. Returns -1 if the
arguments are invalid.
@@ -512,9 +512,9 @@ sign_jump({id}, {group}, {expr})
<
*sign_place()*
-sign_place({id}, {group}, {name}, {expr} [, {dict}])
+sign_place({id}, {group}, {name}, {buf} [, {dict}])
Place the sign defined as {name} at line {lnum} in file or
- buffer {expr} and assign {id} and {group} to sign. This is
+ buffer {buf} and assign {id} and {group} to sign. This is
similar to the |:sign-place| command.
If the sign identifier {id} is zero, then a new identifier is
@@ -525,12 +525,12 @@ sign_place({id}, {group}, {name}, {expr} [, {dict}])
and |sign-group| for more information.
{name} refers to a defined sign.
- {expr} refers to a buffer name or number. For the accepted
+ {buf} refers to a buffer name or number. For the accepted
values, see |bufname()|.
The optional {dict} argument supports the following entries:
lnum line number in the file or buffer
- {expr} where the sign is to be placed.
+ {buf} where the sign is to be placed.
For the accepted values, see |line()|.
priority priority of the sign. See
|sign-priority| for more information.
@@ -578,7 +578,7 @@ sign_placelist({list})
then a new unique identifier is allocated.
Otherwise the specified number is used. See
|sign-identifier| for more information.
- lnum line number in the buffer {expr} where the
+ lnum line number in the buffer {buf} where the
sign is to be placed. For the accepted values,
see |line()|.
name name of the sign to place. See |sign_define()|
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index a8d8d7d9b8..ebc7ff6b80 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -887,7 +887,7 @@ For Visual Basic use: >
BAAN *baan.vim* *baan-syntax*
-The baan.vim gives syntax support for BaanC of release BaanIV upto SSA ERP LN
+The baan.vim gives syntax support for BaanC of release BaanIV up to SSA ERP LN
for both 3 GL and 4 GL programming. Large number of standard defines/constants
are supported.
@@ -1096,11 +1096,13 @@ The ColdFusion syntax file is based on the HTML syntax file.
CPP *cpp.vim* *ft-cpp-syntax*
-Most of things are same as |ft-c-syntax|.
+Most things are the same as |ft-c-syntax|.
Variable Highlight ~
cpp_no_cpp11 don't highlight C++11 standard items
cpp_no_cpp14 don't highlight C++14 standard items
+cpp_no_cpp17 don't highlight C++17 standard items
+cpp_no_cpp20 don't highlight C++20 standard items
CSH *csh.vim* *ft-csh-syntax*
@@ -1384,11 +1386,17 @@ To select syntax highlighting file for Euphoria, as well as for
auto-detecting the *.e and *.E file extensions as Euphoria file type,
add the following line to your startup file: >
- :let filetype_euphoria = "euphoria3"
+ :let g:filetype_euphoria = "euphoria3"
< or >
- :let filetype_euphoria = "euphoria4"
+ :let g:filetype_euphoria = "euphoria4"
+
+Elixir and Euphoria share the *.ex file extension. If the filetype is
+specifically set as Euphoria with the g:filetype_euphoria variable, or the
+file is determined to be Euphoria based on keywords in the file, then the
+filetype will be set as Euphoria. Otherwise, the filetype will default to
+Elixir.
ERLANG *erlang.vim* *ft-erlang-syntax*
@@ -1406,6 +1414,22 @@ To enable highlighting some special atoms, put this in your vimrc: >
:let g:erlang_highlight_special_atoms = 1
+ELIXIR *elixir.vim* *ft-elixir-syntax*
+
+Elixir is a dynamic, functional language for building scalable and maintainable
+applications.
+
+The following file extensions are auto-detected as Elixir file types:
+
+ *.ex, *.exs, *.eex, *.leex, *.lock
+
+Elixir and Euphoria share the *.ex file extension. If the filetype is
+specifically set as Euphoria with the g:filetype_euphoria variable, or the
+file is determined to be Euphoria based on keywords in the file, then the
+filetype will be set as Euphoria. Otherwise, the filetype will default to
+Elixir.
+
+
FLEXWIKI *flexwiki.vim* *ft-flexwiki-syntax*
FlexWiki is an ASP.NET-based wiki package available at http://www.flexwiki.com
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index 3b59dfa908..f0bda5aaf8 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -177,7 +177,7 @@ assert_notmatch({pattern}, {actual} [, {msg}])
assert_report({msg}) *assert_report()*
- Report a test failure directly, using {msg}.
+ Report a test failure directly, using String {msg}.
Always returns one.
Can also be used as a |method|: >
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 86316b8ac5..ac10aeec88 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -296,7 +296,7 @@ for those who want to experiment with this feature and contribute to
its development.
Highlights are defined in the same query format as in the tree-sitter highlight
-crate, which some limitations and additions. Set a highlight query for a
+crate, with some limitations and additions. Set a highlight query for a
buffer with this code: >
local query = [[
diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt
index d0206ba82d..2edef0ca23 100644
--- a/runtime/doc/usr_05.txt
+++ b/runtime/doc/usr_05.txt
@@ -175,10 +175,8 @@ This switches on three very clever mechanisms:
*restore-cursor* *last-position-jump* >
- autocmd BufReadPost *
- \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
- \ | exe "normal! g`\""
- \ | endif
+ autocmd BufRead * autocmd FileType <buffer> ++once
+ \ if &ft !~# 'commit\|rebase' && line("'\"") > 1 && line("'\"") <= line("$") | exe 'normal! g`"' | endif
Another autocommand. This time it is used after reading any file. The
complicated stuff after it checks if the '" mark is defined, and jumps to it
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index a190bf2f27..c9321e8736 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -118,7 +118,8 @@ Numbers can be decimal, hexadecimal, octal or binary.
A hexadecimal number starts with "0x" or "0X". For example "0x1f" is decimal
31.
-An octal number starts with a zero and another digit. "017" is decimal 15.
+An octal number starts with "0o", "0O" or a zero and another digit. "0o17" is
+decimal 15.
A binary number starts with "0b" or "0B". For example "0b101" is decimal 5.
@@ -127,14 +128,14 @@ number, it will be interpreted as an octal number!
The ":echo" command always prints decimal numbers. Example: >
- :echo 0x7f 036
+ :echo 0x7f 0o36
< 127 30 ~
A number is made negative with a minus sign. This also works for hexadecimal,
octal and binary numbers. A minus sign is also used for subtraction. Compare
this with the previous example: >
- :echo 0x7f -036
+ :echo 0x7f -0o36
< 97 ~
White space in an expression is ignored. However, it's recommended to use it
@@ -142,7 +143,7 @@ for separating items, to make the expression easier to read. For example, to
avoid the confusion with a negative number above, put a space between the
minus sign and the following number: >
- :echo 0x7f - 036
+ :echo 0x7f - 0o36
==============================================================================
*41.2* Variables
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index a5fcef2800..64824b2e3f 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -460,6 +460,7 @@ Commands:
:Print
:promptfind
:promptrepl
+ :scriptversion (always version 1)
:shell
:sleep! (does not hide the cursor; same as :sleep)
:smile
@@ -471,6 +472,7 @@ Compile-time features:
X11 integration (see |x11-selection|)
Eval:
+ Vim9script
*js_encode()*
*js_decode()*
*v:none* (used by Vim to represent JavaScript "undefined"); use |v:null| instead.
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index 3a58cc08d9..e0c33fa2c9 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -271,7 +271,7 @@ Closing a window
----------------
:q[uit]
-:{count}q[uit]
+:{count}q[uit] *:count_quit*
CTRL-W q *CTRL-W_q*
CTRL-W CTRL-Q *CTRL-W_CTRL-Q*
Without {count}: Quit the current window. If {count} is
@@ -363,7 +363,8 @@ CTRL-W CTRL-C *CTRL-W_CTRL-C*
CTRL-W o *CTRL-W_o* *E445*
CTRL-W CTRL-O *CTRL-W_CTRL-O* *:on* *:only*
Make the current window the only one on the screen. All other
- windows are closed. For {count} see |:quit|.
+ windows are closed. For {count} see the `:quit` command
+ above |:count_quit|.
When the 'hidden' option is set, all buffers in closed windows
become hidden.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index c9eca870c2..0de04e9774 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2021 Jun 13
+" Last Change: 2021 Aug 23
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
@@ -1382,6 +1382,9 @@ au BufNewFile,BufRead *.pk setf poke
" Protocols
au BufNewFile,BufRead */etc/protocols setf protocols
+" Pyret
+au BufNewFile,BufRead *.arr setf pyret
+
" Pyrex
au BufNewFile,BufRead *.pyx,*.pxd setf pyrex
@@ -1393,7 +1396,7 @@ au BufNewFile,BufRead *.ptl,*.pyi,SConstruct setf python
" Radiance
au BufNewFile,BufRead *.rad,*.mat setf radiance
-" Raku (formelly Perl6)
+" Raku (formerly Perl6)
au BufNewFile,BufRead *.pm6,*.p6,*.t6,*.pod6,*.raku,*.rakumod,*.rakudoc,*.rakutest setf raku
" Ratpoison config/command files
@@ -1622,7 +1625,7 @@ au BufNewFile,BufRead .zshrc,.zshenv,.zlogin,.zlogout,.zcompdump setf zsh
au BufNewFile,BufRead *.zsh setf zsh
" Scheme
-au BufNewFile,BufRead *.scm,*.ss,*.rkt setf scheme
+au BufNewFile,BufRead *.scm,*.ss,*.rkt,*.rktd,*.rktl setf scheme
" Screen RC
au BufNewFile,BufRead .screenrc,screenrc setf screen
diff --git a/runtime/ftplugin/chicken.vim b/runtime/ftplugin/chicken.vim
index 4dc1e57d0a..84d45bae1e 100644
--- a/runtime/ftplugin/chicken.vim
+++ b/runtime/ftplugin/chicken.vim
@@ -2,6 +2,7 @@
" Last Change: 2018-03-05
" Author: Evan Hanson <evhan@foldling.org>
" Maintainer: Evan Hanson <evhan@foldling.org>
+" Repository: https://git.foldling.org/vim-scheme.git
" URL: https://foldling.org/vim/ftplugin/chicken.vim
" Notes: These are supplemental settings, to be loaded after the core
" Scheme ftplugin file (ftplugin/scheme.vim). Enable it by setting
diff --git a/runtime/ftplugin/dosini.vim b/runtime/ftplugin/dosini.vim
index 0d0f0f8983..6a53dfd096 100644
--- a/runtime/ftplugin/dosini.vim
+++ b/runtime/ftplugin/dosini.vim
@@ -1,5 +1,5 @@
" Vim filetype plugin file
-" Language: Configuration File (ini file) for MSDOS/MS Windows
+" Language: Configuration File (ini file) for MS-DOS/MS Windows
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2008-07-09
diff --git a/runtime/ftplugin/matlab.vim b/runtime/ftplugin/matlab.vim
index a1a282f19e..d3c74b4ecf 100644
--- a/runtime/ftplugin/matlab.vim
+++ b/runtime/ftplugin/matlab.vim
@@ -1,7 +1,8 @@
" Vim filetype plugin file
" Language: matlab
" Maintainer: Jake Wasserman <jwasserman at gmail dot com>
-" Last Change: 2019 Sep 27
+" Update By: Gabriel Dupras
+" Last Change: 2021 Aug 30
" Contributors:
" Charles Campbell
@@ -15,9 +16,9 @@ let s:save_cpo = &cpo
set cpo-=C
if exists("loaded_matchit")
- let s:conditionalEnd = '\%(([^()]*\)\@!\<end\>\%([^()]*)\)\@!'
+ let s:conditionalEnd = '\%(\%(^\|;\)\s*\)\@<=end\>'
let b:match_words=
- \ '\<\%(if\|switch\|for\|while\)\>:\<\%(elseif\|case\|break\|continue\|else\|otherwise\)\>:'.s:conditionalEnd.','.
+ \ '\<\%(if\|switch\|for\|while\|try\)\>:\<\%(elseif\|case\|break\|continue\|else\|otherwise\|catch\)\>:' . s:conditionalEnd . ',' .
\ '\<function\>:\<return\>:\<endfunction\>'
unlet s:conditionalEnd
endif
diff --git a/runtime/ftplugin/ocaml.vim b/runtime/ftplugin/ocaml.vim
index 8a628604fa..20172c9b32 100644
--- a/runtime/ftplugin/ocaml.vim
+++ b/runtime/ftplugin/ocaml.vim
@@ -371,7 +371,7 @@ endfunction
endif
else
let annot_file_name = ''
- "(Pierre Vittet: I have commented 4b because this was chrashing
+ "(Pierre Vittet: I have commented 4b because this was crashing
"my vim (it produced infinite loop))
"
" 4b. anarchy : the renamed _build directory may be higher in the hierarchy
@@ -462,8 +462,8 @@ endfunction
"b. 'search' and 'match' work to find the type information
- "In: - lin1,col1: postion of expression first char
- " - lin2,col2: postion of expression last char
+ "In: - lin1,col1: position of expression first char
+ " - lin2,col2: position of expression last char
"Out: - the pattern to be looked for to find the block
" Must be called in the source buffer (use of line2byte)
function! s:Block_pattern(lin1,lin2,col1,col2)
@@ -581,7 +581,7 @@ endfunction
let res = substitute (a:res, "\n", "", "g" )
"remove double space
let res =substitute(res , " ", " ", "g")
- "remove space at begining of string.
+ "remove space at beginning of string.
let res = substitute(res, "^ *", "", "g")
return res
endfunction
diff --git a/runtime/ftplugin/octave.vim b/runtime/ftplugin/octave.vim
new file mode 100644
index 0000000000..7cab7c212a
--- /dev/null
+++ b/runtime/ftplugin/octave.vim
@@ -0,0 +1,63 @@
+" Vim filetype plugin file
+" Language: GNU Octave
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Last Change: 2021 Sep 02
+
+if exists("b:did_ftplugin")
+ finish
+endif
+let b:did_ftplugin = 1
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" TODO: update Matlab ftplugin and source it as the base file?
+
+setlocal comments=s:%{,m:\ ,e:%},s:#{,m:\ ,e:#},:%,:#
+setlocal commentstring=#\ %s
+setlocal formatoptions-=t formatoptions+=croql
+
+setlocal keywordprg=info\ octave\ --vi-keys\ --index-search
+
+if exists("loaded_matchit") && !exists("b:match_words")
+ let b:match_words = '\<unwind_protect\>:\<unwind_protect_cleanup\>:\<end_unwind_protect\>'
+ if exists("octave_use_matlab_end")
+ let b:match_words ..= ',' ..
+ \ '\<\%(classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\|try\)\>' ..
+ \ ':' ..
+ \ '\<\%(elseif\|else\|case\|otherwise\|break\|continue\|catch\)\>' ..
+ \ ':' ..
+ \ '\<end\>'
+ else
+ let b:match_words ..= ',' ..
+ \ '\<classdef\>:\<endclassdef\>,' ..
+ \ '\<enumeration\>:\<endenumeration\>,' ..
+ \ '\<events\>:\<endevents\>,' ..
+ \ '\<do\>:\<\%(break\|continue\)\>:\<until\>' ..
+ \ '\<for\>:\<\%(break\|continue\)\>:\<endfor\>,' ..
+ \ '\<function\>:\<return\>:\<endfunction\>,' ..
+ \ '\<if\>:\<\%(elseif\|else\)\>:\<endif\>,' ..
+ \ '\<methods\>:\<endmethods\>,' ..
+ \ '\<parfor\>:\<endparfor\>,' ..
+ \ '\<properties\>:\<endproperties\>,' ..
+ \ '\<switch\>:\<\%(case\|otherwise\)\>:\<endswitch\>,' ..
+ \ '\<while\>:\<\%(break\|continue\)\>:\<endwhile\>,' ..
+ \ '\<try\>:\<catch\>:\<end_try_catch\>'
+ endif
+ " only match in statement position
+ let s:statement_start = escape('\%(\%(^\|;\)\s*\)\@<=', '\')
+ let b:match_words = substitute(b:match_words, '\\<', s:statement_start, 'g')
+endif
+
+if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
+ let b:browsefilter = "GNU Octave Source Files (*.m)\t*.m\n" ..
+ \ "All Files (*.*)\t*.*\n"
+endif
+
+let b:undo_ftplugin = "setl com< cms< fo< kp< " ..
+ \ "| unlet! b:browsefilter b:match_words"
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim: nowrap sw=2 sts=2 ts=8 noet:
diff --git a/runtime/ftplugin/scala.vim b/runtime/ftplugin/scala.vim
index 18e16f1d5b..b484df99f3 100644
--- a/runtime/ftplugin/scala.vim
+++ b/runtime/ftplugin/scala.vim
@@ -3,7 +3,7 @@
" Maintainer: Derek Wyatt
" URL: https://github.com/derekwyatt/vim-scala
" License: Same as Vim
-" Last Change: 02 August 2016
+" Last Change: 11 August 2021
" ----------------------------------------------------------------------------
if exists('b:did_ftplugin') || &cp
@@ -26,8 +26,8 @@ setlocal commentstring=//\ %s
setlocal shiftwidth=2 softtabstop=2 expandtab
-setlocal include='^\s*import'
-setlocal includeexpr='substitute(v:fname,"\\.","/","g")'
+setlocal include=^\\s*import
+setlocal includeexpr=substitute(v:fname,'\\.','/','g')
setlocal path+=src/main/scala,src/test/scala
setlocal suffixesadd=.scala
diff --git a/runtime/ftplugin/scdoc.vim b/runtime/ftplugin/scdoc.vim
new file mode 100644
index 0000000000..2e98e647f4
--- /dev/null
+++ b/runtime/ftplugin/scdoc.vim
@@ -0,0 +1,26 @@
+" scdoc filetype plugin
+" Maintainer: Gregory Anders <greg@gpanders.com>
+" Last Updated: 2021-08-04
+
+" Only do this when not done yet for this buffer
+if exists('b:did_ftplugin')
+ finish
+endif
+
+" Don't load another plugin for this buffer
+let b:did_ftplugin = 1
+
+setlocal comments=b:;
+setlocal commentstring=;%s
+setlocal formatoptions+=t
+setlocal noexpandtab
+setlocal shiftwidth=0
+setlocal softtabstop=0
+setlocal textwidth=80
+
+let b:undo_ftplugin = 'setl com< cms< fo< et< sw< sts< tw<'
+
+if has('conceal')
+ setlocal conceallevel=2
+ let b:undo_ftplugin .= ' cole<'
+endif
diff --git a/runtime/ftplugin/scheme.vim b/runtime/ftplugin/scheme.vim
index 5778594c41..04655bc136 100644
--- a/runtime/ftplugin/scheme.vim
+++ b/runtime/ftplugin/scheme.vim
@@ -1,9 +1,10 @@
" Vim filetype plugin file
" Language: Scheme (R7RS)
-" Last Change: 2019 Nov 18
+" Last Change: 2019-11-19
" Author: Evan Hanson <evhan@foldling.org>
" Maintainer: Evan Hanson <evhan@foldling.org>
" Previous Maintainer: Sergey Khorev <sergey.khorev@gmail.com>
+" Repository: https://git.foldling.org/vim-scheme.git
" URL: https://foldling.org/vim/ftplugin/scheme.vim
if exists('b:did_ftplugin')
@@ -48,7 +49,7 @@ let b:undo_ftplugin = b:undo_ftplugin . ' lispwords<'
let b:did_scheme_ftplugin = 1
if exists('b:is_chicken') || exists('g:is_chicken')
- exe 'ru! ftplugin/chicken.vim'
+ runtime! ftplugin/chicken.vim
endif
unlet b:did_scheme_ftplugin
diff --git a/runtime/ftplugin/systemverilog.vim b/runtime/ftplugin/systemverilog.vim
index e350427022..38ed1ad32a 100644
--- a/runtime/ftplugin/systemverilog.vim
+++ b/runtime/ftplugin/systemverilog.vim
@@ -32,7 +32,7 @@ if exists("loaded_matchit")
\ '\<checker\>:\<endchecker\>,' .
\ '\<class\>:\<endclass\>,' .
\ '\<clocking\>:\<endclocking\>,' .
- \ '\<gruop\>:\<endgruop\>,' .
+ \ '\<group\>:\<endgroup\>,' .
\ '\<interface\>:\<endinterface\>,' .
\ '\<package\>:\<endpackage\>,' .
\ '\<program\>:\<endprogram\>,' .
diff --git a/runtime/ftplugin/tex.vim b/runtime/ftplugin/tex.vim
index 11470012f9..0d68b51d46 100644
--- a/runtime/ftplugin/tex.vim
+++ b/runtime/ftplugin/tex.vim
@@ -28,7 +28,7 @@ let &l:define .= '\|\\\(re\)\=new\(boolean\|command\|counter\|environment\|font'
" Tell Vim how to recognize LaTeX \include{foo} and plain \input bar :
let &l:include .= '\|\\include{'
-" On some file systems, "{" and "}" are inluded in 'isfname'. In case the
+" On some file systems, "{" and "}" are included in 'isfname'. In case the
" TeX file has \include{fname} (LaTeX only), strip everything except "fname".
let &l:includeexpr = "substitute(v:fname, '^.\\{-}{\\|}.*', '', 'g')"
diff --git a/runtime/indent/ada.vim b/runtime/indent/ada.vim
index 1ca7fbacbe..6c8ab05267 100644
--- a/runtime/indent/ada.vim
+++ b/runtime/indent/ada.vim
@@ -219,7 +219,7 @@ function GetAdaIndent()
" Move indent in twice (next 'when' will move back)
let ind = ind + 2 * shiftwidth()
elseif line =~ '^\s*end\s*record\>'
- " Move indent back to tallying 'type' preceeding the 'record'.
+ " Move indent back to tallying 'type' preceding the 'record'.
" Allow indent to be equal to 'end record's.
let ind = s:MainBlockIndent( ind+shiftwidth(), lnum, 'type\>', '' )
elseif line =~ '\(^\s*new\>.*\)\@<!)\s*[;,]\s*$'
diff --git a/runtime/indent/bzl.vim b/runtime/indent/bzl.vim
index 6904bfdedb..cf4cfb5fad 100644
--- a/runtime/indent/bzl.vim
+++ b/runtime/indent/bzl.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: Bazel (http://bazel.io)
" Maintainer: David Barnett (https://github.com/google/vim-ft-bzl)
-" Last Change: 2017 Jun 13
+" Last Change: 2021 Jul 08
if exists('b:did_indent')
finish
@@ -41,30 +41,41 @@ function GetBzlIndent(lnum) abort
if exists('g:pyindent_open_paren')
let l:pyindent_open_paren = g:pyindent_open_paren
endif
- let g:pyindent_nested_paren = 'shiftwidth() * 2'
- let g:pyindent_open_paren = 'shiftwidth() * 2'
+ let g:pyindent_nested_paren = 'shiftwidth()'
+ let g:pyindent_open_paren = 'shiftwidth()'
endif
let l:indent = -1
- " Indent inside parens.
- " Align with the open paren unless it is at the end of the line.
- " E.g.
- " open_paren_not_at_EOL(100,
- " (200,
- " 300),
- " 400)
- " open_paren_at_EOL(
- " 100, 200, 300, 400)
call cursor(a:lnum, 1)
let [l:par_line, l:par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" .
\ " synIDattr(synID(line('.'), col('.'), 1), 'name')" .
\ " =~ '\\(Comment\\|String\\)$'")
if l:par_line > 0
- call cursor(l:par_line, 1)
- if l:par_col != col('$') - 1
- let l:indent = l:par_col
+ " Indent inside parens.
+ if searchpair('(\|{\|\[', '', ')\|}\|\]', 'W',
+ \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" .
+ \ " synIDattr(synID(line('.'), col('.'), 1), 'name')" .
+ \ " =~ '\\(Comment\\|String\\)$'") && line('.') == a:lnum
+ " If cursor is at close parens, match indent with open parens.
+ " E.g.
+ " foo(
+ " )
+ let l:indent = indent(l:par_line)
+ else
+ " Align with the open paren unless it is at the end of the line.
+ " E.g.
+ " open_paren_not_at_EOL(100,
+ " (200,
+ " 300),
+ " 400)
+ " open_paren_at_EOL(
+ " 100, 200, 300, 400)
+ call cursor(l:par_line, 1)
+ if l:par_col != col('$') - 1
+ let l:indent = l:par_col
+ endif
endif
endif
diff --git a/runtime/indent/cdl.vim b/runtime/indent/cdl.vim
index 4f9b7a8967..fb4fe27310 100644
--- a/runtime/indent/cdl.vim
+++ b/runtime/indent/cdl.vim
@@ -16,8 +16,8 @@ if exists("*CdlGetIndent")
"finish
endif
-" find out if an "...=..." expresion is an assignment (or a conditional)
-" it scans 'line' first, and then the previos lines
+" find out if an "...=..." expression is an assignment (or a conditional)
+" it scans 'line' first, and then the previous lines
fun! CdlAsignment(lnum, line)
let f = -1
let lnum = a:lnum
@@ -33,7 +33,7 @@ fun! CdlAsignment(lnum, line)
endif
" it's formula if there's a ';', 'elsE', 'theN', 'enDif' or 'expr'
" conditional if there's a '<', '>', 'elseif', 'if', 'and', 'or', 'not',
- " 'memberis', 'childrenof' and other \k\+of funcions
+ " 'memberis', 'childrenof' and other \k\+of functions
let f = line[inicio-1] =~? '[en;]' || strpart(line, inicio-4, 4) =~? 'ndif\|expr'
endw
let lnum = prevnonblank(lnum-1)
@@ -106,7 +106,7 @@ fun! CdlGetIndent(lnum)
elseif c == '(' || c ==? 'f' " '(' or 'if'
let ind = ind + shiftwidth()
else " c == '='
- " if it is an asignment increase indent
+ " if it is an assignment increase indent
if f == -1 " we don't know yet, find out
let f = CdlAsignment(lnum, strpart(line, 0, inicio))
end
@@ -117,11 +117,11 @@ fun! CdlGetIndent(lnum)
endw
" CURRENT LINE, if it starts with a closing element, decrease indent
- " or if it starts with '=' (asignment), increase indent
+ " or if it starts with '=' (assignment), increase indent
if match(thisline, '^\c\s*\(else\|then\|endif\|[);]\)') >= 0
let ind = ind - shiftwidth()
elseif match(thisline, '^\s*=') >= 0
- if f == -1 " we don't know yet if is an asignment, find out
+ if f == -1 " we don't know yet if is an assignment, find out
let f = CdlAsignment(lnum, "")
end
if f == 1 " formula increase it
diff --git a/runtime/indent/config.vim b/runtime/indent/config.vim
index 074f467bee..c987a78d64 100644
--- a/runtime/indent/config.vim
+++ b/runtime/indent/config.vim
@@ -62,8 +62,8 @@ function GetConfigIndent()
let ind = s:GetOffsetOf(line, '\[')
endif
- " if previous line had an unmatched closing parantheses,
- " indent to the matching opening parantheses
+ " if previous line had an unmatched closing parentheses,
+ " indent to the matching opening parentheses
if line =~ '[^(]\+\\\@<!)$'
call search(')', 'bW')
let lnum = searchpair('\\\@<!(', '', ')', 'bWn')
diff --git a/runtime/indent/dtd.vim b/runtime/indent/dtd.vim
index 963ac408ef..30c06aa8b2 100644
--- a/runtime/indent/dtd.vim
+++ b/runtime/indent/dtd.vim
@@ -119,16 +119,16 @@ function GetDTDIndent()
" Next comes the content model. If the token we’ve found isn’t a
" parenthesis it must be either ANY, EMPTY or some random junk. Either
" way, we’re done indenting this element, so set it to that of the first
- " line so that the terminating “>” winds up having the same indention.
+ " line so that the terminating “>” winds up having the same indentation.
if token != '('
return indent
endif
" Now go through the content model. We need to keep track of the nesting
" of parentheses. As soon as we hit 0 we’re done. If that happens we must
- " have a complete content model. Thus set indention to be the same as that
+ " have a complete content model. Thus set indentation to be the same as that
" of the first line so that the terminating “>” winds up having the same
- " indention. Otherwise, we’ll indent to the innermost parentheses not yet
+ " indentation. Otherwise, we’ll indent to the innermost parentheses not yet
" matched.
let [indent_of_innermost, end] = s:indent_to_innermost_parentheses(line, end)
if indent_of_innermost != -1
diff --git a/runtime/indent/erlang.vim b/runtime/indent/erlang.vim
index 625cfde0c1..4e7bf4ef4d 100644
--- a/runtime/indent/erlang.vim
+++ b/runtime/indent/erlang.vim
@@ -57,7 +57,7 @@ endfunction
" ======================
" Indtokens are "indentation tokens". See their exact format in the
-" documentaiton of the s:GetTokensFromLine function.
+" documentation of the s:GetTokensFromLine function.
" Purpose:
" Calculate the new virtual column after the given segment of a line.
@@ -75,7 +75,7 @@ endfunction
" s:CalcVCol("\t'\tx', b", 1, 4, 4) -> 10
function! s:CalcVCol(line, first_index, last_index, vcol, tabstop)
- " We copy the relevent segment of the line, otherwise if the line were
+ " We copy the relevant segment of the line, otherwise if the line were
" e.g. `"\t", term` then the else branch below would consume the `", term`
" part at once.
let line = a:line[a:first_index : a:last_index]
@@ -604,7 +604,7 @@ endfunction
function! s:BeginElementFoundIfEmpty(stack, token, curr_vcol, stored_vcol, sw)
if empty(a:stack)
if a:stored_vcol ==# -1
- call s:Log(' "' . a:token . '" directly preceeds LTI -> return')
+ call s:Log(' "' . a:token . '" directly precedes LTI -> return')
return [1, a:curr_vcol + a:sw]
else
call s:Log(' "' . a:token .
@@ -825,7 +825,7 @@ function! s:ErlangCalcIndent2(lnum, stack)
if ret | return res | endif
if stored_vcol ==# -1
- call s:Log(' End of clause directly preceeds LTI -> return')
+ call s:Log(' End of clause directly precedes LTI -> return')
return 0
else
call s:Log(' End of clause (but not end of line) -> return')
diff --git a/runtime/indent/json.vim b/runtime/indent/json.vim
index c649e37013..09c7d7a85a 100644
--- a/runtime/indent/json.vim
+++ b/runtime/indent/json.vim
@@ -1,6 +1,6 @@
" Vim indent file
" Language: JSON
-" Mantainer: Eli Parra <eli@elzr.com> https://github.com/elzr/vim-json
+" Maintainer: Eli Parra <eli@elzr.com> https://github.com/elzr/vim-json
" Last Change: 2020 Aug 30
" https://github.com/jakar/vim-json/commit/20b650e22aa750c4ab6a66aa646bdd95d7cd548a#diff-e81fc111b2052e306d126bd9989f7b7c
" Original Author: Rogerz Zhang <rogerz.zhang at gmail.com> http://github.com/rogerz/vim-json
diff --git a/runtime/indent/lifelines.vim b/runtime/indent/lifelines.vim
index 0d9b2b46e4..e6d61617dc 100644
--- a/runtime/indent/lifelines.vim
+++ b/runtime/indent/lifelines.vim
@@ -11,7 +11,7 @@ endif
let b:did_indent = 1
" LifeLines uses cindent without ; line terminator, C functions
-" declarations, C keywords, C++ formating
+" declarations, C keywords, C++ formatting
setlocal cindent
setlocal cinwords=""
setlocal cinoptions+=+0
diff --git a/runtime/indent/objc.vim b/runtime/indent/objc.vim
index beadca9fa4..a5451a5a11 100644
--- a/runtime/indent/objc.vim
+++ b/runtime/indent/objc.vim
@@ -15,7 +15,7 @@ setlocal cindent
" Set the function to do the work.
setlocal indentexpr=GetObjCIndent()
-" To make a colon (:) suggest an indentation other than a goto/swich label,
+" To make a colon (:) suggest an indentation other than a goto/switch label,
setlocal indentkeys-=:
setlocal indentkeys+=<:>
diff --git a/runtime/indent/pascal.vim b/runtime/indent/pascal.vim
index c7955d669b..1f39fd1cad 100644
--- a/runtime/indent/pascal.vim
+++ b/runtime/indent/pascal.vim
@@ -2,7 +2,7 @@
" Language: Pascal
" Maintainer: Neil Carter <n.carter@swansea.ac.uk>
" Created: 2004 Jul 13
-" Last Change: 2017 Jun 13
+" Last Change: 2021 Jul 01
"
" This is version 2.0, a complete rewrite.
"
@@ -20,6 +20,8 @@ setlocal indentkeys+==end;,==const,==type,==var,==begin,==repeat,==until,==for
setlocal indentkeys+==program,==function,==procedure,==object,==private
setlocal indentkeys+==record,==if,==else,==case
+let b:undo_indent = "setl indentkeys< indentexpr<"
+
if exists("*GetPascalIndent")
finish
endif
diff --git a/runtime/indent/pov.vim b/runtime/indent/pov.vim
index e806756c8e..f74c96b7f7 100644
--- a/runtime/indent/pov.vim
+++ b/runtime/indent/pov.vim
@@ -44,7 +44,7 @@ function GetPoVRayIndent()
return -1
endif
- " Search backwards for the frist non-empty, non-comment line.
+ " Search backwards for the first non-empty, non-comment line.
let plnum = prevnonblank(v:lnum - 1)
let plind = indent(plnum)
while plnum > 0 && synIDattr(synID(plnum, plind+1, 0), "name") =~? "comment"
diff --git a/runtime/indent/ruby.vim b/runtime/indent/ruby.vim
index 2a267fdab3..559d8652a6 100644
--- a/runtime/indent/ruby.vim
+++ b/runtime/indent/ruby.vim
@@ -265,7 +265,7 @@ function! GetRubyIndent(...) abort
\ ]
" Most Significant line based on the previous one -- in case it's a
- " contination of something above
+ " continuation of something above
let indent_info.plnum_msl = s:GetMSL(indent_info.plnum)
for callback_name in indent_callback_names
diff --git a/runtime/indent/scala.vim b/runtime/indent/scala.vim
index 6fd8ca9d81..b5eba29543 100644
--- a/runtime/indent/scala.vim
+++ b/runtime/indent/scala.vim
@@ -20,7 +20,10 @@ endif
let s:keepcpo= &cpo
set cpo&vim
-let s:defMatcher = '\%(\%(private\|protected\)\%(\[[^\]]*\]\)\?\s\+\|abstract\s\+\|override\s\+\)*\<def\>'
+let s:annotationMatcher = '@[A-Za-z._]\+\s\+'
+let s:modifierMatcher = s:annotationMatcher . '\|\%(private\|protected\)\%(\[[^\]]*\]\)\?\s\+\|abstract\s\+\|override\s\+\|final\s\+'
+let s:defMatcher = '\%(' . s:modifierMatcher . '\)*\<def\>'
+let s:valMatcher = '\%(' . s:modifierMatcher . '\|lazy\s\+\)*\<va[lr]\>'
let s:funcNameMatcher = '\w\+'
let s:typeSpecMatcher = '\%(\s*\[\_[^\]]*\]\)'
let s:defArgMatcher = '\%((\_.\{-})\)'
@@ -184,7 +187,7 @@ function! scala#NumberOfBraceGroups(line)
endfunction
function! scala#MatchesIncompleteDefValr(line)
- if a:line =~ '^\s*\%(' . s:defMatcher . '\|\<va[lr]\>\).*[=({]\s*$'
+ if a:line =~ '^\s*\%(' . s:defMatcher . '\|' . s:valMatcher . '\).*[=({]\s*$'
return 1
else
return 0
@@ -434,7 +437,7 @@ function! GetScalaIndent()
" If 'val', 'var', 'def' end with =, this is a one-line block
if (prevline =~ '^\s*\<\%(\%(}\?\s*else\s\+\)\?if\|for\|while\)\>.*[)=]\s*$' && scala#NumberOfBraceGroups(prevline) <= 1)
\ || prevline =~ '^\s*' . s:defMatcher . '.*=\s*$'
- \ || prevline =~ '^\s*\<va[lr]\>.*[=]\s*$'
+ \ || prevline =~ '^\s*' . s:valMatcher . '.*[=]\s*$'
\ || prevline =~ '^\s*\%(}\s*\)\?\<else\>\s*$'
\ || prevline =~ '=\s*$'
call scala#ConditionalConfirm("4")
diff --git a/runtime/indent/sqlanywhere.vim b/runtime/indent/sqlanywhere.vim
index 601c567adc..d39fa3240e 100644
--- a/runtime/indent/sqlanywhere.vim
+++ b/runtime/indent/sqlanywhere.vim
@@ -9,7 +9,7 @@
" Notes:
" Indenting keywords are based on Oracle and Sybase Adaptive Server
" Anywhere (ASA). Test indenting was done with ASA stored procedures and
-" fuctions and Oracle packages which contain stored procedures and
+" functions and Oracle packages which contain stored procedures and
" functions.
" This has not been tested against Microsoft SQL Server or
" Sybase Adaptive Server Enterprise (ASE) which use the Transact-SQL
diff --git a/runtime/indent/systemverilog.vim b/runtime/indent/systemverilog.vim
index 590fd4d998..16fb4515c5 100644
--- a/runtime/indent/systemverilog.vim
+++ b/runtime/indent/systemverilog.vim
@@ -64,7 +64,7 @@ function SystemVerilogIndent()
let vverb = 0
endif
- " Indent accoding to last line
+ " Indent according to last line
" End of multiple-line comment
if last_line =~ '\*/\s*$' && last_line !~ '/\*.\{-}\*/'
let ind = ind - offset_comment1
@@ -220,7 +220,7 @@ function SystemVerilogIndent()
endif
- " Return the indention
+ " Return the indentation
return ind
endfunction
diff --git a/runtime/indent/testdir/xml.in b/runtime/indent/testdir/xml.in
index b6333340e2..88ad51e484 100644
--- a/runtime/indent/testdir/xml.in
+++ b/runtime/indent/testdir/xml.in
@@ -15,7 +15,7 @@ text comment
</tag1>
<!--
text comment
-end coment -->
+end comment -->
</tag0>
<!-- END_INDENT -->
diff --git a/runtime/indent/testdir/xml.ok b/runtime/indent/testdir/xml.ok
index cfdf701c11..d5e2289cb3 100644
--- a/runtime/indent/testdir/xml.ok
+++ b/runtime/indent/testdir/xml.ok
@@ -15,7 +15,7 @@
</tag1>
<!--
text comment
- end coment -->
+ end comment -->
</tag0>
<!-- END_INDENT -->
diff --git a/runtime/indent/tex.vim b/runtime/indent/tex.vim
index 8a44ade1ac..d356ba905b 100644
--- a/runtime/indent/tex.vim
+++ b/runtime/indent/tex.vim
@@ -288,7 +288,7 @@ function! GetTeXIndent() " {{{
let ind = ind - shiftwidth()
let stay = 0
endif
- " lines following to '\item' are intented once again:
+ " lines following to '\item' are indented once again:
if line =~ g:tex_items
let ind = ind + shiftwidth()
let stay = 0
diff --git a/runtime/indent/treetop.vim b/runtime/indent/treetop.vim
index 2c6eecf5c4..42ec1c8ad9 100644
--- a/runtime/indent/treetop.vim
+++ b/runtime/indent/treetop.vim
@@ -34,5 +34,5 @@ function GetTreetopIndent()
let ind -= shiftwidth()
end
- retur ind
+ return ind
endfunction
diff --git a/runtime/indent/typescript.vim b/runtime/indent/typescript.vim
index b6b2cb5acf..e899f83d0f 100644
--- a/runtime/indent/typescript.vim
+++ b/runtime/indent/typescript.vim
@@ -460,7 +460,7 @@ function! Fixedgq(lnum, count)
return 1
endif
- " Put all the lines on one line and do normal spliting after that
+ " Put all the lines on one line and do normal splitting after that
if l:count > 1
while l:count > 1
let l:count -= 1
diff --git a/runtime/indent/verilog.vim b/runtime/indent/verilog.vim
index ab3d0ba3e0..e81197c3b4 100644
--- a/runtime/indent/verilog.vim
+++ b/runtime/indent/verilog.vim
@@ -76,7 +76,7 @@ function GetVerilogIndent()
let vverb = 0
endif
- " Indent accoding to last line
+ " Indent according to last line
" End of multiple-line comment
if last_line =~ '\*/\s*$' && last_line !~ '/\*.\{-}\*/'
let ind = ind - offset_comment1
@@ -219,7 +219,7 @@ function GetVerilogIndent()
endif
- " Return the indention
+ " Return the indentation
return ind
endfunction
diff --git a/runtime/indent/yaml.vim b/runtime/indent/yaml.vim
index 8dca5cd763..ed57e68d8b 100644
--- a/runtime/indent/yaml.vim
+++ b/runtime/indent/yaml.vim
@@ -2,7 +2,7 @@
" Language: YAML
" Maintainer: Nikolai Pavlov <zyx.vim@gmail.com>
" Last Update: Lukas Reineke
-" Last Change: 2021 Jan 19
+" Last Change: 2021 Aug 13
" Only load this indent file when no other was loaded.
if exists('b:did_indent')
diff --git a/runtime/keymap/kana.vim b/runtime/keymap/kana.vim
index 23b5f876ac..9aff4eba41 100644
--- a/runtime/keymap/kana.vim
+++ b/runtime/keymap/kana.vim
@@ -364,7 +364,7 @@ ppu っぷ
ppe っぺ
ppo っぽ
-" Proceded by a small `tu' and followed by a small 'ya', 'yu' or 'yo'
+" Preceded by a small `tu' and followed by a small 'ya', 'yu' or 'yo'
kkya っきゃ
kkyu っきゅ
kkyo っきょ
@@ -683,7 +683,7 @@ PPU ップ
PPE ッペ
PPO ッポ
-" Proceded by a small `tu' and followed by a small 'ya', 'yu' or 'yo'
+" Preceded by a small `tu' and followed by a small 'ya', 'yu' or 'yo'
KKYA ッキャ
KKYU ッキュ
KKYO ッキョ
diff --git a/runtime/keymap/korean.vim b/runtime/keymap/korean.vim
index 044e3b9918..64ae519320 100644
--- a/runtime/keymap/korean.vim
+++ b/runtime/keymap/korean.vim
@@ -10,7 +10,7 @@
" BUT, simply mapping each letter of Hangul with sequence of alphabet 1 by 1
" can fail to combine Hangul jamo (conconants and vowels) right.
" For example, sequentially pressing `ㅅㅓㅇㅜㄹㄷㅐㅎㅏㄱㅛ` can not only be
-" combined as `서울대학교`, but alse `성ㅜㄹ댛ㅏㄱ교`, which is totally
+" combined as `서울대학교`, but also `성ㅜㄹ댛ㅏㄱ교`, which is totally
" nonsense.
" Though combining Hangul is deterministic with law that each letter must be
" one of (consonant + vowel) or (consonant + vowel + consonant), there is no
diff --git a/runtime/keymap/russian-jcukenwintype.vim b/runtime/keymap/russian-jcukenwintype.vim
index 25d6286e24..2d5856ad0c 100644
--- a/runtime/keymap/russian-jcukenwintype.vim
+++ b/runtime/keymap/russian-jcukenwintype.vim
@@ -4,7 +4,7 @@
" Useful mainly with utf-8 but may work with other encodings
" Derived from russian-jcuken.vim by Artem Chuprina <ran@ran.pp.ru>
-" Typewriter variant of standart russian layout
+" Typewriter variant of standard russian layout
" Maintainer: Denis Proskurin <danwerspb@gmail.com>
" Last Changed: 2015 May 15
diff --git a/runtime/keymap/russian-typograph.vim b/runtime/keymap/russian-typograph.vim
index a85e861e32..e0fbf22884 100644
--- a/runtime/keymap/russian-typograph.vim
+++ b/runtime/keymap/russian-typograph.vim
@@ -106,7 +106,7 @@ loadkeymap
<char-0x005d> <char-0x044a> " CYRILLIC SMALL LETTER HARD SIGN
<char-0x007d> <char-0x042a> " CYRILLIC CAPITAL LETTER HARD SIGN
-" ALPHABETIC 2st ROW
+" ALPHABETIC 2nd ROW
<char-0x0061> <char-0x0444> " CYRILLIC SMALL LETTER EF
<char-0x0041> <char-0x0424> " CYRILLIC CAPITAL LETTER EF
@@ -131,7 +131,7 @@ loadkeymap
<char-0x0027> <char-0x044d> " CYRILLIC SMALL LETTER E
<char-0x0022> <char-0x042d> " CYRILLIC CAPITAL LETTER E
-" ALPHABETIC 3st ROW
+" ALPHABETIC 3rd ROW
<char-0x007a> <char-0x044f> " CYRILLIC SMALL LETTER YA
<char-0x005a> <char-0x042f> " CYRILLIC CAPITAL LETTER YA
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
new file mode 100644
index 0000000000..688f9b5811
--- /dev/null
+++ b/runtime/lua/vim/diagnostic.lua
@@ -0,0 +1,1150 @@
+local M = {}
+
+M.severity = {
+ ERROR = 1,
+ WARN = 2,
+ INFO = 3,
+ HINT = 4,
+}
+
+vim.tbl_add_reverse_lookup(M.severity)
+
+local global_diagnostic_options = {
+ signs = true,
+ underline = true,
+ virtual_text = true,
+ update_in_insert = false,
+ severity_sort = false,
+}
+
+-- Local functions {{{
+
+---@private
+local function to_severity(severity)
+ return type(severity) == 'string' and M.severity[string.upper(severity)] or severity
+end
+
+---@private
+local function filter_by_severity(severity, diagnostics)
+ if not severity then
+ return diagnostics
+ end
+
+ if type(severity) ~= "table" then
+ severity = to_severity(severity)
+ return vim.tbl_filter(function(t) return t.severity == severity end, diagnostics)
+ end
+
+ local min_severity = to_severity(severity.min) or M.severity.HINT
+ local max_severity = to_severity(severity.max) or M.severity.ERROR
+
+ return vim.tbl_filter(function(t) return t.severity <= min_severity and t.severity >= max_severity end, diagnostics)
+end
+
+---@private
+local function resolve_optional_value(option, namespace, bufnr)
+ local enabled_val = {}
+
+ if not option then
+ return false
+ elseif option == true then
+ return enabled_val
+ elseif type(option) == 'function' then
+ local val = option(namespace, bufnr)
+ if val == true then
+ return enabled_val
+ else
+ return val
+ end
+ elseif type(option) == 'table' then
+ return option
+ else
+ error("Unexpected option type: " .. vim.inspect(option))
+ end
+end
+
+local all_namespaces = {}
+
+---@private
+local function get_namespace(ns)
+ if not all_namespaces[ns] then
+ local name
+ for k, v in pairs(vim.api.nvim_get_namespaces()) do
+ if ns == v then
+ name = k
+ break
+ end
+ end
+
+ if not name then
+ return vim.notify("namespace does not exist or is anonymous", vim.log.levels.ERROR)
+ end
+
+ all_namespaces[ns] = {
+ name = name,
+ sign_group = string.format("vim.diagnostic.%s", name),
+ opts = {}
+ }
+ end
+ return all_namespaces[ns]
+end
+
+---@private
+local function get_resolved_options(opts, namespace, bufnr)
+ local ns = get_namespace(namespace)
+ local resolved = vim.tbl_extend('keep', opts or {}, ns.opts, global_diagnostic_options)
+ for k in pairs(global_diagnostic_options) do
+ if resolved[k] ~= nil then
+ resolved[k] = resolve_optional_value(resolved[k], namespace, bufnr)
+ end
+ end
+ return resolved
+end
+
+-- Default diagnostic highlights
+local diagnostic_severities = {
+ [M.severity.ERROR] = { ctermfg = 1, guifg = "Red" };
+ [M.severity.WARN] = { ctermfg = 3, guifg = "Orange" };
+ [M.severity.INFO] = { ctermfg = 4, guifg = "LightBlue" };
+ [M.severity.HINT] = { ctermfg = 7, guifg = "LightGrey" };
+}
+
+-- Make a map from DiagnosticSeverity -> Highlight Name
+---@private
+local function make_highlight_map(base_name)
+ local result = {}
+ for k in pairs(diagnostic_severities) do
+ local name = M.severity[k]
+ name = name:sub(1, 1) .. name:sub(2):lower()
+ result[k] = "Diagnostic" .. base_name .. name
+ end
+
+ return result
+end
+
+local virtual_text_highlight_map = make_highlight_map("VirtualText")
+local underline_highlight_map = make_highlight_map("Underline")
+local floating_highlight_map = make_highlight_map("Floating")
+local sign_highlight_map = make_highlight_map("Sign")
+
+---@private
+local define_default_signs = (function()
+ local signs_defined = false
+ return function()
+ if signs_defined then
+ return
+ end
+
+ for severity, sign_hl_name in pairs(sign_highlight_map) do
+ local severity_name = M.severity[severity]
+ vim.fn.sign_define(sign_hl_name, {
+ text = (severity_name or 'U'):sub(1, 1),
+ texthl = sign_hl_name,
+ linehl = '',
+ numhl = '',
+ })
+ end
+
+ signs_defined = true
+ end
+end)()
+
+---@private
+local function get_bufnr(bufnr)
+ if not bufnr or bufnr == 0 then
+ return vim.api.nvim_get_current_buf()
+ end
+ return bufnr
+end
+
+-- Metatable that automatically creates an empty table when assigning to a missing key
+local bufnr_and_namespace_cacher_mt = {
+ __index = function(t, bufnr)
+ if not bufnr or bufnr == 0 then
+ bufnr = vim.api.nvim_get_current_buf()
+ end
+
+ if rawget(t, bufnr) == nil then
+ rawset(t, bufnr, {})
+ end
+
+ return rawget(t, bufnr)
+ end,
+
+ __newindex = function(t, bufnr, v)
+ if not bufnr or bufnr == 0 then
+ bufnr = vim.api.nvim_get_current_buf()
+ end
+
+ rawset(t, bufnr, v)
+ end,
+}
+
+local diagnostic_cleanup = setmetatable({}, bufnr_and_namespace_cacher_mt)
+local diagnostic_cache = setmetatable({}, bufnr_and_namespace_cacher_mt)
+local diagnostic_cache_extmarks = setmetatable({}, bufnr_and_namespace_cacher_mt)
+local diagnostic_attached_buffers = {}
+local diagnostic_disabled = {}
+local bufs_waiting_to_update = setmetatable({}, bufnr_and_namespace_cacher_mt)
+
+---@private
+local function is_disabled(namespace, bufnr)
+ if type(diagnostic_disabled[bufnr]) == "table" then
+ return diagnostic_disabled[bufnr][namespace]
+ end
+ return diagnostic_disabled[bufnr]
+end
+
+---@private
+local function diagnostic_lines(diagnostics)
+ if not diagnostics then
+ return
+ end
+
+ local diagnostics_by_line = {}
+ for _, diagnostic in ipairs(diagnostics) do
+ local line_diagnostics = diagnostics_by_line[diagnostic.lnum]
+ if not line_diagnostics then
+ line_diagnostics = {}
+ diagnostics_by_line[diagnostic.lnum] = line_diagnostics
+ end
+ table.insert(line_diagnostics, diagnostic)
+ end
+ return diagnostics_by_line
+end
+
+---@private
+local function set_diagnostic_cache(namespace, diagnostics, bufnr)
+ local buf_line_count = vim.api.nvim_buf_line_count(bufnr)
+ for _, diagnostic in ipairs(diagnostics) do
+ if diagnostic.severity == nil then
+ diagnostic.severity = M.severity.ERROR
+ end
+
+ diagnostic.namespace = namespace
+ diagnostic.bufnr = bufnr
+
+ if buf_line_count > 0 then
+ diagnostic.lnum = math.max(math.min(
+ diagnostic.lnum, buf_line_count - 1
+ ), 0)
+ diagnostic.end_lnum = math.max(math.min(
+ diagnostic.end_lnum, buf_line_count - 1
+ ), 0)
+ end
+ end
+
+ diagnostic_cache[bufnr][namespace] = diagnostics
+end
+
+---@private
+local function clear_diagnostic_cache(namespace, bufnr)
+ diagnostic_cache[bufnr][namespace] = nil
+end
+
+---@private
+local function restore_extmarks(bufnr, last)
+ for ns, extmarks in pairs(diagnostic_cache_extmarks[bufnr]) do
+ local extmarks_current = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {details = true})
+ local found = {}
+ for _, extmark in ipairs(extmarks_current) do
+ -- nvim_buf_set_lines will move any extmark to the line after the last
+ -- nvim_buf_set_text will move any extmark to the last line
+ if extmark[2] ~= last + 1 then
+ found[extmark[1]] = true
+ end
+ end
+ for _, extmark in ipairs(extmarks) do
+ if not found[extmark[1]] then
+ local opts = extmark[4]
+ opts.id = extmark[1]
+ -- HACK: end_row should be end_line
+ if opts.end_row then
+ opts.end_line = opts.end_row
+ opts.end_row = nil
+ end
+ pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, extmark[2], extmark[3], opts)
+ end
+ end
+ end
+end
+
+---@private
+local function save_extmarks(namespace, bufnr)
+ bufnr = bufnr == 0 and vim.api.nvim_get_current_buf() or bufnr
+ if not diagnostic_attached_buffers[bufnr] then
+ vim.api.nvim_buf_attach(bufnr, false, {
+ on_lines = function(_, _, _, _, _, last)
+ restore_extmarks(bufnr, last - 1)
+ end,
+ on_detach = function()
+ diagnostic_cache_extmarks[bufnr] = nil
+ end})
+ diagnostic_attached_buffers[bufnr] = true
+ end
+ diagnostic_cache_extmarks[bufnr][namespace] = vim.api.nvim_buf_get_extmarks(bufnr, namespace, 0, -1, {details = true})
+end
+
+local registered_autocmds = {}
+
+---@private
+local function make_augroup_key(namespace, bufnr)
+ local ns = get_namespace(namespace)
+ return string.format("DiagnosticInsertLeave:%s:%s", bufnr, ns.name)
+end
+
+--- Table of autocmd events to fire the update for displaying new diagnostic information
+local insert_leave_auto_cmds = { "InsertLeave", "CursorHoldI" }
+
+---@private
+local function schedule_display(namespace, bufnr, args)
+ bufs_waiting_to_update[bufnr][namespace] = args
+
+ local key = make_augroup_key(namespace, bufnr)
+ if not registered_autocmds[key] then
+ vim.cmd(string.format("augroup %s", key))
+ vim.cmd(" au!")
+ vim.cmd(
+ string.format(
+ [[autocmd %s <buffer=%s> lua vim.diagnostic._execute_scheduled_display(%s, %s)]],
+ table.concat(insert_leave_auto_cmds, ","),
+ bufnr,
+ namespace,
+ bufnr
+ )
+ )
+ vim.cmd("augroup END")
+
+ registered_autocmds[key] = true
+ end
+end
+
+---@private
+local function clear_scheduled_display(namespace, bufnr)
+ local key = make_augroup_key(namespace, bufnr)
+
+ if registered_autocmds[key] then
+ vim.cmd(string.format("augroup %s", key))
+ vim.cmd(" au!")
+ vim.cmd("augroup END")
+
+ registered_autocmds[key] = nil
+ end
+end
+
+---@private
+--- Open a floating window with the provided diagnostics
+---@param opts table Configuration table
+--- - show_header (boolean, default true): Show "Diagnostics:" header
+--- - all opts for |vim.util.open_floating_preview()| can be used here
+---@param diagnostics table: The diagnostics to display
+---@return table {popup_bufnr, win_id}
+local function show_diagnostics(opts, diagnostics)
+ if vim.tbl_isempty(diagnostics) then return end
+ local lines = {}
+ local highlights = {}
+ local show_header = vim.F.if_nil(opts.show_header, true)
+ if show_header then
+ table.insert(lines, "Diagnostics:")
+ table.insert(highlights, {0, "Bold"})
+ end
+
+ for i, diagnostic in ipairs(diagnostics) do
+ local prefix = string.format("%d. ", i)
+ local hiname = floating_highlight_map[diagnostic.severity]
+ assert(hiname, 'unknown severity: ' .. tostring(diagnostic.severity))
+
+ local message_lines = vim.split(diagnostic.message, '\n', true)
+ table.insert(lines, prefix..message_lines[1])
+ table.insert(highlights, {#prefix, hiname})
+ for j = 2, #message_lines do
+ table.insert(lines, string.rep(' ', #prefix) .. message_lines[j])
+ table.insert(highlights, {0, hiname})
+ end
+ end
+
+ local popup_bufnr, winnr = require('vim.lsp.util').open_floating_preview(lines, 'plaintext', opts)
+ for i, hi in ipairs(highlights) do
+ local prefixlen, hiname = unpack(hi)
+ -- Start highlight after the prefix
+ vim.api.nvim_buf_add_highlight(popup_bufnr, -1, hiname, i-1, prefixlen, -1)
+ end
+
+ return popup_bufnr, winnr
+end
+
+local errlist_type_map = {
+ [M.severity.ERROR] = 'E',
+ [M.severity.WARN] = 'W',
+ [M.severity.INFO] = 'I',
+ [M.severity.HINT] = 'I',
+}
+
+---@private
+local function diagnostics_to_list_items(diagnostics)
+ local items = {}
+ for _, d in pairs(diagnostics) do
+ table.insert(items, {
+ bufnr = d.bufnr,
+ lnum = d.lnum + 1,
+ col = d.col + 1,
+ text = d.message,
+ type = errlist_type_map[d.severity or M.severity.ERROR] or 'E'
+ })
+ end
+ table.sort(items, function(a, b)
+ if a.bufnr == b.bufnr then
+ return a.lnum < b.lnum
+ else
+ return a.bufnr < b.bufnr
+ end
+ end)
+ return items
+end
+
+---@private
+local function set_list(loclist, opts)
+ opts = opts or {}
+ local open = vim.F.if_nil(opts.open, true)
+ local title = opts.title or "Diagnostics"
+ local winnr = opts.winnr or 0
+ local diagnostics = M.get(loclist and vim.api.nvim_win_get_buf(winnr), opts)
+ local items = diagnostics_to_list_items(diagnostics)
+ if loclist then
+ vim.fn.setloclist(winnr, {}, ' ', { title = title, items = items })
+ else
+ vim.fn.setqflist({}, ' ', { title = title, items = items })
+ end
+ if open then
+ vim.api.nvim_command(loclist and "lopen" or "copen")
+ end
+end
+
+-- }}}
+
+-- Public API {{{
+
+--- Configure diagnostic options globally or for a specific diagnostic
+--- namespace.
+---
+---@note Each of the configuration options below accepts one of the following:
+--- - `false`: Disable this feature
+--- - `true`: Enable this feature, use default settings.
+--- - `table`: Enable this feature with overrides.
+--- - `function`: Function with signature (namespace, bufnr) that returns any of the above.
+---
+---@param opts table Configuration table with the following keys:
+--- - underline: (default true) Use underline for diagnostics
+--- - virtual_text: (default true) Use virtual text for diagnostics
+--- - signs: (default true) Use signs for diagnostics
+--- - update_in_insert: (default false) Update diagnostics in Insert mode (if false,
+--- diagnostics are updated on InsertLeave)
+--- - severity_sort: (default false) Sort diagnostics by severity. This affects the order in
+--- which signs and virtual text are displayed
+---@param namespace number|nil Update the options for the given namespace. When omitted, update the
+--- global diagnostic options.
+function M.config(opts, namespace)
+ vim.validate {
+ opts = { opts, 't' },
+ namespace = { namespace, 'n', true },
+ }
+
+ local t
+ if namespace then
+ local ns = get_namespace(namespace)
+ t = ns.opts
+ else
+ t = global_diagnostic_options
+ end
+
+ for opt in pairs(global_diagnostic_options) do
+ if opts[opt] ~= nil then
+ t[opt] = opts[opt]
+ end
+ end
+
+ if namespace then
+ for bufnr, v in pairs(diagnostic_cache) do
+ if v[namespace] then
+ M.show(namespace, bufnr)
+ end
+ end
+ else
+ for bufnr, v in pairs(diagnostic_cache) do
+ for ns in pairs(v) do
+ M.show(ns, bufnr)
+ end
+ end
+ end
+end
+
+--- Set diagnostics for the given namespace and buffer.
+---
+---@param namespace number The diagnostic namespace
+---@param bufnr number Buffer number
+---@param diagnostics table A list of diagnostic items |diagnostic-structure|
+---@param opts table|nil Display options to pass to |vim.diagnostic.show()|
+function M.set(namespace, bufnr, diagnostics, opts)
+ vim.validate {
+ namespace = {namespace, 'n'},
+ bufnr = {bufnr, 'n'},
+ diagnostics = {diagnostics, 't'},
+ opts = {opts, 't', true},
+ }
+
+ if vim.tbl_isempty(diagnostics) then
+ return M.reset(namespace, bufnr)
+ end
+
+ if not diagnostic_cleanup[bufnr][namespace] then
+ diagnostic_cleanup[bufnr][namespace] = true
+
+ -- Clean up our data when the buffer unloads.
+ vim.api.nvim_buf_attach(bufnr, false, {
+ on_detach = function(_, b)
+ clear_diagnostic_cache(b, namespace)
+ diagnostic_cleanup[b][namespace] = nil
+ end
+ })
+ end
+
+ set_diagnostic_cache(namespace, diagnostics, bufnr)
+
+ if opts then
+ M.config(opts, namespace)
+ end
+
+ if vim.api.nvim_buf_is_loaded(bufnr) then
+ M.show(namespace, bufnr)
+ end
+
+ vim.api.nvim_command("doautocmd <nomodeline> User DiagnosticsChanged")
+end
+
+--- Get current diagnostics.
+---
+---@param bufnr number|nil Buffer number to get diagnostics from. Use 0 for
+--- current buffer or nil for all buffers.
+---@param opts table|nil A table with the following keys:
+--- - namespace: (number) Limit diagnostics to the given namespace.
+--- - lnum: (number) Limit diagnostics to the given line number.
+--- - severity: See |diagnostic-severity|.
+---@return table A list of diagnostic items |diagnostic-structure|.
+function M.get(bufnr, opts)
+ vim.validate {
+ bufnr = { bufnr, 'n', true },
+ opts = { opts, 't', true },
+ }
+
+ opts = opts or {}
+
+ local namespace = opts.namespace
+ local diagnostics = {}
+
+ ---@private
+ local function add(d)
+ if not opts.lnum or d.lnum == opts.lnum then
+ table.insert(diagnostics, d)
+ end
+ end
+
+ if namespace == nil and bufnr == nil then
+ for _, t in pairs(diagnostic_cache) do
+ for _, v in pairs(t) do
+ for _, diagnostic in pairs(v) do
+ add(diagnostic)
+ end
+ end
+ end
+ elseif namespace == nil then
+ for iter_namespace in pairs(diagnostic_cache[bufnr]) do
+ for _, diagnostic in pairs(diagnostic_cache[bufnr][iter_namespace]) do
+ add(diagnostic)
+ end
+ end
+ elseif bufnr == nil then
+ for _, t in pairs(diagnostic_cache) do
+ for _, diagnostic in pairs(t[namespace] or {}) do
+ add(diagnostic)
+ end
+ end
+ else
+ for _, diagnostic in pairs(diagnostic_cache[bufnr][namespace] or {}) do
+ add(diagnostic)
+ end
+ end
+
+ if opts.severity then
+ diagnostics = filter_by_severity(opts.severity, diagnostics)
+ end
+
+ return diagnostics
+end
+
+-- Diagnostic Movements {{{
+
+local next_diagnostic = function(position, search_forward, bufnr, opts, namespace)
+ position[1] = position[1] - 1
+ bufnr = bufnr or vim.api.nvim_get_current_buf()
+ local wrap = vim.F.if_nil(opts.wrap, true)
+ local line_count = vim.api.nvim_buf_line_count(bufnr)
+ opts.namespace = namespace
+ for i = 0, line_count do
+ local offset = i * (search_forward and 1 or -1)
+ local lnum = position[1] + offset
+ if lnum < 0 or lnum >= line_count then
+ if not wrap then
+ return
+ end
+ lnum = (lnum + line_count) % line_count
+ end
+ opts.lnum = lnum
+ local line_diagnostics = M.get(bufnr, opts)
+ if line_diagnostics and not vim.tbl_isempty(line_diagnostics) then
+ local sort_diagnostics, is_next
+ if search_forward then
+ sort_diagnostics = function(a, b) return a.col < b.col end
+ is_next = function(diagnostic) return diagnostic.col > position[2] end
+ else
+ sort_diagnostics = function(a, b) return a.col > b.col end
+ is_next = function(diagnostic) return diagnostic.col < position[2] end
+ end
+ table.sort(line_diagnostics, sort_diagnostics)
+ if i == 0 then
+ for _, v in pairs(line_diagnostics) do
+ if is_next(v) then
+ return v
+ end
+ end
+ else
+ return line_diagnostics[1]
+ end
+ end
+ end
+end
+
+---@private
+local function diagnostic_move_pos(opts, pos)
+ opts = opts or {}
+
+ local enable_popup = vim.F.if_nil(opts.enable_popup, true)
+ local win_id = opts.win_id or vim.api.nvim_get_current_win()
+
+ if not pos then
+ vim.api.nvim_echo({{"No more valid diagnostics to move to", "WarningMsg"}}, true, {})
+ return
+ end
+
+ vim.api.nvim_win_set_cursor(win_id, {pos[1] + 1, pos[2]})
+
+ if enable_popup then
+ -- This is a bit weird... I'm surprised that we need to wait til the next tick to do this.
+ vim.schedule(function()
+ M.show_position_diagnostics(opts.popup_opts, vim.api.nvim_win_get_buf(win_id))
+ end)
+ end
+end
+
+--- Get the previous diagnostic closest to the cursor position.
+---
+---@param opts table See |vim.diagnostic.goto_next()|
+---@return table Previous diagnostic
+function M.get_prev(opts)
+ opts = opts or {}
+
+ local win_id = opts.win_id or vim.api.nvim_get_current_win()
+ local bufnr = vim.api.nvim_win_get_buf(win_id)
+ local cursor_position = opts.cursor_position or vim.api.nvim_win_get_cursor(win_id)
+
+ return next_diagnostic(cursor_position, false, bufnr, opts, opts.namespace)
+end
+
+--- Return the position of the previous diagnostic in the current buffer.
+---
+---@param opts table See |vim.diagnostic.goto_next()|
+---@return table Previous diagnostic position as a (row, col) tuple.
+function M.get_prev_pos(opts)
+ local prev = M.get_prev(opts)
+ if not prev then
+ return false
+ end
+
+ return {prev.lnum, prev.col}
+end
+
+--- Move to the previous diagnostic in the current buffer.
+---@param opts table See |vim.diagnostic.goto_next()|
+function M.goto_prev(opts)
+ return diagnostic_move_pos(
+ opts,
+ M.get_prev_pos(opts)
+ )
+end
+
+--- Get the next diagnostic closest to the cursor position.
+---
+---@param opts table See |vim.diagnostic.goto_next()|
+---@return table Next diagnostic
+function M.get_next(opts)
+ opts = opts or {}
+
+ local win_id = opts.win_id or vim.api.nvim_get_current_win()
+ local bufnr = vim.api.nvim_win_get_buf(win_id)
+ local cursor_position = opts.cursor_position or vim.api.nvim_win_get_cursor(win_id)
+
+ return next_diagnostic(cursor_position, true, bufnr, opts, opts.namespace)
+end
+
+--- Return the position of the next diagnostic in the current buffer.
+---
+---@param opts table See |vim.diagnostic.goto_next()|
+---@return table Next diagnostic position as a (row, col) tuple.
+function M.get_next_pos(opts)
+ local next = M.get_next(opts)
+ if not next then
+ return false
+ end
+
+ return {next.lnum, next.col}
+end
+
+--- Move to the next diagnostic.
+---
+---@param opts table|nil Configuration table with the following keys:
+--- - namespace: (number) Only consider diagnostics from the given namespace.
+--- - cursor_position: (cursor position) Cursor position as a (row, col) tuple. See
+--- |nvim_win_get_cursor()|. Defaults to the current cursor position.
+--- - wrap: (boolean, default true) Whether to loop around file or not. Similar to 'wrapscan'.
+--- - severity: See |diagnostic-severity|.
+--- - enable_popup: (boolean, default true) Call |vim.diagnostic.show_line_diagnostics()|
+--- on jump.
+--- - popup_opts: (table) Table to pass as {opts} parameter to
+--- |vim.diagnostic.show_line_diagnostics()|
+--- - win_id: (number, default 0) Window ID
+function M.goto_next(opts)
+ return diagnostic_move_pos(
+ opts,
+ M.get_next_pos(opts)
+ )
+end
+
+-- Diagnostic Setters {{{
+
+--- Set signs for given diagnostics.
+---
+---@param namespace number The diagnostic namespace
+---@param bufnr number Buffer number
+---@param diagnostics table A list of diagnostic items |diagnostic-structure|. When omitted the
+--- current diagnostics in the given buffer are used.
+---@param opts table Configuration table with the following keys:
+--- - priority: Set the priority of the signs |sign-priority|.
+---@private
+function M._set_signs(namespace, bufnr, diagnostics, opts)
+ vim.validate {
+ namespace = {namespace, 'n'},
+ bufnr = {bufnr, 'n'},
+ diagnostics = {diagnostics, 't'},
+ opts = {opts, 't', true},
+ }
+
+ bufnr = get_bufnr(bufnr)
+ opts = get_resolved_options({ signs = opts }, namespace, bufnr).signs
+
+ if opts and opts.severity then
+ diagnostics = filter_by_severity(opts.severity, diagnostics)
+ end
+
+ local ns = get_namespace(namespace)
+
+ define_default_signs()
+
+ for _, diagnostic in ipairs(diagnostics) do
+ vim.fn.sign_place(
+ 0,
+ ns.sign_group,
+ sign_highlight_map[diagnostic.severity],
+ bufnr,
+ {
+ priority = opts and opts.priority,
+ lnum = diagnostic.lnum + 1
+ }
+ )
+ end
+end
+
+--- Set underline for given diagnostics.
+---
+---@param namespace number The diagnostic namespace
+---@param bufnr number Buffer number
+---@param diagnostics table A list of diagnostic items |diagnostic-structure|. When omitted the
+--- current diagnostics in the given buffer are used.
+---@param opts table Configuration table. Currently unused.
+---@private
+function M._set_underline(namespace, bufnr, diagnostics, opts)
+ vim.validate {
+ namespace = {namespace, 'n'},
+ bufnr = {bufnr, 'n'},
+ diagnostics = {diagnostics, 't'},
+ opts = {opts, 't', true},
+ }
+
+ bufnr = get_bufnr(bufnr)
+ opts = get_resolved_options({ underline = opts }, namespace, bufnr).underline
+
+ if opts and opts.severity then
+ diagnostics = filter_by_severity(opts.severity, diagnostics)
+ end
+
+ for _, diagnostic in ipairs(diagnostics) do
+ local higroup = underline_highlight_map[diagnostic.severity]
+
+ if higroup == nil then
+ -- Default to error if we don't have a highlight associated
+ higroup = underline_highlight_map.Error
+ end
+
+ vim.highlight.range(
+ bufnr,
+ namespace,
+ higroup,
+ { diagnostic.lnum, diagnostic.col },
+ { diagnostic.end_lnum, diagnostic.end_col }
+ )
+ end
+end
+
+--- Set virtual text for given diagnostics.
+---
+---@param namespace number The diagnostic namespace
+---@param bufnr number Buffer number
+---@param diagnostics table A list of diagnostic items |diagnostic-structure|. When omitted the
+--- current diagnostics in the given buffer are used.
+---@param opts table|nil Configuration table with the following keys:
+--- - prefix: (string) Prefix to display before virtual text on line.
+--- - spacing: (number) Number of spaces to insert before virtual text.
+---@private
+function M._set_virtual_text(namespace, bufnr, diagnostics, opts)
+ vim.validate {
+ namespace = {namespace, 'n'},
+ bufnr = {bufnr, 'n'},
+ diagnostics = {diagnostics, 't'},
+ opts = {opts, 't', true},
+ }
+
+ bufnr = get_bufnr(bufnr)
+ opts = get_resolved_options({ virtual_text = opts }, namespace, bufnr).virtual_text
+
+ local buffer_line_diagnostics = diagnostic_lines(diagnostics)
+ for line, line_diagnostics in pairs(buffer_line_diagnostics) do
+ if opts and opts.severity then
+ line_diagnostics = filter_by_severity(opts.severity, line_diagnostics)
+ end
+ local virt_texts = M.get_virt_text_chunks(line_diagnostics, opts)
+
+ if virt_texts then
+ vim.api.nvim_buf_set_extmark(bufnr, namespace, line, 0, {
+ hl_mode = "combine",
+ virt_text = virt_texts,
+ })
+ end
+ end
+end
+
+--- Get virtual text chunks to display using |nvim_buf_set_extmark()|.
+---
+---@param line_diags table The diagnostics associated with the line.
+---@param opts table|nil Configuration table with the following keys:
+--- - prefix: (string) Prefix to display before virtual text on line.
+--- - spacing: (number) Number of spaces to insert before virtual text.
+---@return an array of [text, hl_group] arrays. This can be passed directly to
+--- the {virt_text} option of |nvim_buf_set_extmark()|.
+function M.get_virt_text_chunks(line_diags, opts)
+ if #line_diags == 0 then
+ return nil
+ end
+
+ opts = opts or {}
+ local prefix = opts.prefix or "■"
+ local spacing = opts.spacing or 4
+
+ -- Create a little more space between virtual text and contents
+ local virt_texts = {{string.rep(" ", spacing)}}
+
+ for i = 1, #line_diags - 1 do
+ table.insert(virt_texts, {prefix, virtual_text_highlight_map[line_diags[i].severity]})
+ end
+ local last = line_diags[#line_diags]
+
+ -- TODO(tjdevries): Allow different servers to be shown first somehow?
+ -- TODO(tjdevries): Display server name associated with these?
+ if last.message then
+ table.insert(
+ virt_texts,
+ {
+ string.format("%s %s", prefix, last.message:gsub("\r", ""):gsub("\n", " ")),
+ virtual_text_highlight_map[last.severity]
+ }
+ )
+
+ return virt_texts
+ end
+end
+
+--- Callback scheduled when leaving Insert mode.
+---
+--- This function must be exported publicly so that it is available to be
+--- called from the Vimscript autocommand.
+---
+--- See @ref schedule_display()
+---
+---@private
+function M._execute_scheduled_display(namespace, bufnr)
+ local args = bufs_waiting_to_update[bufnr][namespace]
+ if not args then
+ return
+ end
+
+ -- Clear the args so we don't display unnecessarily.
+ bufs_waiting_to_update[bufnr][namespace] = nil
+
+ M.show(namespace, bufnr, nil, args)
+end
+
+--- Hide currently displayed diagnostics.
+---
+--- This only clears the decorations displayed in the buffer. Diagnostics can
+--- be redisplayed with |vim.diagnostic.show()|. To completely remove
+--- diagnostics, use |vim.diagnostic.reset()|.
+---
+--- To hide diagnostics and prevent them from re-displaying, use
+--- |vim.diagnostic.disable()|.
+---
+---@param namespace number The diagnostic namespace
+---@param bufnr number|nil Buffer number. Defaults to the current buffer.
+function M.hide(namespace, bufnr)
+ vim.validate {
+ namespace = { namespace, 'n' },
+ bufnr = { bufnr, 'n', true },
+ }
+
+ bufnr = get_bufnr(bufnr)
+ diagnostic_cache_extmarks[bufnr][namespace] = {}
+
+ local ns = get_namespace(namespace)
+
+ -- clear sign group
+ vim.fn.sign_unplace(ns.sign_group, {buffer=bufnr})
+
+ -- clear virtual text namespace
+ vim.api.nvim_buf_clear_namespace(bufnr, namespace, 0, -1)
+end
+
+
+--- Display diagnostics for the given namespace and buffer.
+---
+---@param namespace number Diagnostic namespace
+---@param bufnr number|nil Buffer number. Defaults to the current buffer.
+---@param diagnostics table|nil The diagnostics to display. When omitted, use the
+--- saved diagnostics for the given namespace and
+--- buffer. This can be used to display a list of diagnostics
+--- without saving them or to display only a subset of
+--- diagnostics.
+---@param opts table|nil Display options. See |vim.diagnostic.config()|.
+function M.show(namespace, bufnr, diagnostics, opts)
+ vim.validate {
+ namespace = { namespace, 'n' },
+ bufnr = { bufnr, 'n', true },
+ diagnostics = { diagnostics, 't', true },
+ opts = { opts, 't', true },
+ }
+
+ bufnr = get_bufnr(bufnr)
+ if is_disabled(namespace, bufnr) then
+ return
+ end
+
+ M.hide(namespace, bufnr)
+
+ diagnostics = diagnostics or M.get(bufnr, {namespace=namespace})
+
+ if not diagnostics or vim.tbl_isempty(diagnostics) then
+ return
+ end
+
+ opts = get_resolved_options(opts, namespace, bufnr)
+
+ if opts.update_in_insert then
+ clear_scheduled_display(namespace, bufnr)
+ else
+ local mode = vim.api.nvim_get_mode()
+ if string.sub(mode.mode, 1, 1) == 'i' then
+ schedule_display(namespace, bufnr, opts)
+ return
+ end
+ end
+
+ if opts.underline then
+ M._set_underline(namespace, bufnr, diagnostics, opts.underline)
+ end
+
+ if opts.virtual_text then
+ M._set_virtual_text(namespace, bufnr, diagnostics, opts.virtual_text)
+ end
+
+ if opts.signs then
+ M._set_signs(namespace, bufnr, diagnostics, opts.signs)
+ end
+
+ save_extmarks(namespace, bufnr)
+end
+
+--- Open a floating window with the diagnostics at the given position.
+---
+---@param opts table|nil Configuration table with the same keys as
+--- |vim.lsp.util.open_floating_preview()| in addition to the following:
+--- - namespace: (number) Limit diagnostics to the given namespace
+--- - severity: See |diagnostic-severity|.
+--- - show_header: (boolean, default true) Show "Diagnostics:" header
+---@param bufnr number|nil Buffer number. Defaults to the current buffer.
+---@param position table|nil The (0,0)-indexed position. Defaults to the current cursor position.
+---@return A ({popup_bufnr}, {win_id}) tuple
+function M.show_position_diagnostics(opts, bufnr, position)
+ vim.validate {
+ opts = { opts, 't', true },
+ bufnr = { bufnr, 'n', true },
+ position = { position, 't', true },
+ }
+
+ opts = opts or {}
+
+ opts.focus_id = "position_diagnostics"
+ bufnr = get_bufnr(bufnr)
+ if not position then
+ local curr_position = vim.api.nvim_win_get_cursor(0)
+ curr_position[1] = curr_position[1] - 1
+ position = curr_position
+ end
+ local match_position_predicate = function(diag)
+ return position[1] == diag.lnum and
+ position[2] >= diag.col and
+ (position[2] <= diag.end_col or position[1] < diag.end_lnum)
+ end
+ local position_diagnostics = vim.tbl_filter(match_position_predicate, M.get(bufnr, opts))
+ table.sort(position_diagnostics, function(a, b) return a.severity < b.severity end)
+ return show_diagnostics(opts, position_diagnostics)
+end
+
+--- Open a floating window with the diagnostics from the given line.
+---
+---@param opts table Configuration table. See |vim.diagnostic.show_position_diagnostics()|.
+---@param bufnr number|nil Buffer number. Defaults to the current buffer.
+---@param lnum number|nil Line number. Defaults to line number of cursor.
+---@return A ({popup_bufnr}, {win_id}) tuple
+function M.show_line_diagnostics(opts, bufnr, lnum)
+ vim.validate {
+ opts = { opts, 't', true },
+ bufnr = { bufnr, 'n', true },
+ lnum = { lnum, 'n', true },
+ }
+
+ opts = opts or {}
+ opts.focus_id = "line_diagnostics"
+ opts.lnum = lnum or (vim.api.nvim_win_get_cursor(0)[1] - 1)
+ local line_diagnostics = M.get(bufnr, opts)
+ return show_diagnostics(opts, line_diagnostics)
+end
+
+--- Remove all diagnostics from the given namespace.
+---
+--- Unlike |vim.diagnostic.hide()|, this function removes all saved
+--- diagnostics. They cannot be redisplayed using |vim.diagnostic.show()|. To
+--- simply remove diagnostic decorations in a way that they can be
+--- re-displayed, use |vim.diagnostic.hide()|.
+---
+---@param namespace number
+---@param bufnr number|nil Remove diagnostics for the given buffer. When omitted,
+--- diagnostics are removed for all buffers.
+function M.reset(namespace, bufnr)
+ if bufnr == nil then
+ for iter_bufnr, namespaces in pairs(diagnostic_cache) do
+ if namespaces[namespace] then
+ M.reset(namespace, iter_bufnr)
+ end
+ end
+ else
+ clear_diagnostic_cache(namespace, bufnr)
+ M.hide(namespace, bufnr)
+ end
+
+ vim.api.nvim_command("doautocmd <nomodeline> User DiagnosticsChanged")
+end
+
+--- Add all diagnostics to the quickfix list.
+---
+---@param opts table|nil Configuration table with the following keys:
+--- - namespace: (number) Only add diagnostics from the given namespace.
+--- - open: (boolean, default true) Open quickfix list after setting.
+--- - title: (string) Title of quickfix list. Defaults to "Diagnostics".
+--- - severity: See |diagnostic-severity|.
+function M.setqflist(opts)
+ set_list(false, opts)
+end
+
+--- Add buffer diagnostics to the location list.
+---
+---@param opts table|nil Configuration table with the following keys:
+--- - namespace: (number) Only add diagnostics from the given namespace.
+--- - winnr: (number, default 0) Window number to set location list for.
+--- - open: (boolean, default true) Open the location list after setting.
+--- - title: (string) Title of the location list. Defaults to "Diagnostics".
+--- - severity: See |diagnostic-severity|.
+function M.setloclist(opts)
+ set_list(true, opts)
+end
+
+--- Disable diagnostics in the given buffer.
+---
+---@param bufnr number|nil Buffer number. Defaults to the current buffer.
+---@param namespace number|nil Only disable diagnostics for the given namespace.
+function M.disable(bufnr, namespace)
+ vim.validate { bufnr = {bufnr, 'n', true}, namespace = {namespace, 'n', true} }
+ bufnr = get_bufnr(bufnr)
+ if namespace == nil then
+ diagnostic_disabled[bufnr] = true
+ for ns in pairs(diagnostic_cache[bufnr]) do
+ M.hide(ns, bufnr)
+ end
+ else
+ if type(diagnostic_disabled[bufnr]) ~= "table" then
+ diagnostic_disabled[bufnr] = {}
+ end
+ diagnostic_disabled[bufnr][namespace] = true
+ M.hide(namespace, bufnr)
+ end
+end
+
+--- Enable diagnostics in the given buffer.
+---
+---@param bufnr number|nil Buffer number. Defaults to the current buffer.
+---@param namespace number|nil Only enable diagnostics for the given namespace.
+function M.enable(bufnr, namespace)
+ vim.validate { bufnr = {bufnr, 'n', true}, namespace = {namespace, 'n', true} }
+ bufnr = get_bufnr(bufnr)
+ if namespace == nil then
+ diagnostic_disabled[bufnr] = nil
+ for ns in pairs(diagnostic_cache[bufnr]) do
+ M.show(ns, bufnr)
+ end
+ else
+ if type(diagnostic_disabled[bufnr]) ~= "table" then
+ return
+ end
+ diagnostic_disabled[bufnr][namespace] = nil
+ M.show(namespace, bufnr)
+ end
+end
+
+-- }}}
+
+
+return M
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 0fdd43e210..90c5872f11 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -674,7 +674,7 @@ function lsp.start_client(config)
---@param method (string) LSP method name
---@param params (table) The parameters for that method.
function dispatch.notification(method, params)
- local _ = log.debug() and log.debug('notification', method, params)
+ local _ = log.trace() and log.trace('notification', method, params)
local handler = resolve_handler(method)
if handler then
-- Method name is provided here for convenience.
@@ -688,13 +688,13 @@ function lsp.start_client(config)
---@param method (string) LSP method name
---@param params (table) The parameters for that method
function dispatch.server_request(method, params)
- local _ = log.debug() and log.debug('server_request', method, params)
+ local _ = log.trace() and log.trace('server_request', method, params)
local handler = resolve_handler(method)
if handler then
- local _ = log.debug() and log.debug("server_request: found handler for", method)
+ local _ = log.trace() and log.trace("server_request: found handler for", method)
return handler(nil, params, {method=method, client_id=client_id})
end
- local _ = log.debug() and log.debug("server_request: no handler found for", method)
+ local _ = log.warn() and log.warn("server_request: no handler found for", method)
return nil, lsp.rpc_response_error(protocol.ErrorCodes.MethodNotFound)
end
@@ -826,7 +826,7 @@ function lsp.start_client(config)
-- TODO(ashkan) handle errors here.
pcall(config.before_init, initialize_params, config)
end
- local _ = log.debug() and log.debug(log_prefix, "initialize_params", initialize_params)
+ local _ = log.trace() and log.trace(log_prefix, "initialize_params", initialize_params)
rpc.request('initialize', initialize_params, function(init_err, result)
assert(not init_err, tostring(init_err))
assert(result, "server sent empty result")
@@ -1534,8 +1534,5 @@ function lsp._with_extend(name, options, user_config)
return resulting_config
end
--- Define the LspDiagnostics signs if they're not defined already.
-require('vim.lsp.diagnostic')._define_default_signs_and_highlights()
-
return lsp
-- vim:sw=2 ts=2 et
diff --git a/runtime/lua/vim/lsp/_snippet.lua b/runtime/lua/vim/lsp/_snippet.lua
new file mode 100644
index 0000000000..0140b0aee3
--- /dev/null
+++ b/runtime/lua/vim/lsp/_snippet.lua
@@ -0,0 +1,399 @@
+local P = {}
+
+---Take characters until the target characters (The escape sequence is '\' + char)
+---@param targets string[] The character list for stop consuming text.
+---@param specials string[] If the character isn't contained in targets/specials, '\' will be left.
+P.take_until = function(targets, specials)
+ targets = targets or {}
+ specials = specials or {}
+
+ return function(input, pos)
+ local new_pos = pos
+ local raw = {}
+ local esc = {}
+ while new_pos <= #input do
+ local c = string.sub(input, new_pos, new_pos)
+ if c == '\\' then
+ table.insert(raw, '\\')
+ new_pos = new_pos + 1
+ c = string.sub(input, new_pos, new_pos)
+ if not vim.tbl_contains(targets, c) and not vim.tbl_contains(specials, c) then
+ table.insert(esc, '\\')
+ end
+ table.insert(raw, c)
+ table.insert(esc, c)
+ new_pos = new_pos + 1
+ else
+ if vim.tbl_contains(targets, c) then
+ break
+ end
+ table.insert(raw, c)
+ table.insert(esc, c)
+ new_pos = new_pos + 1
+ end
+ end
+
+ if new_pos == pos then
+ return P.unmatch(pos)
+ end
+
+ return {
+ parsed = true,
+ value = {
+ raw = table.concat(raw, ''),
+ esc = table.concat(esc, '')
+ },
+ pos = new_pos,
+ }
+ end
+end
+
+P.unmatch = function(pos)
+ return {
+ parsed = false,
+ value = nil,
+ pos = pos,
+ }
+end
+
+P.map = function(parser, map)
+ return function(input, pos)
+ local result = parser(input, pos)
+ if result.parsed then
+ return {
+ parsed = true,
+ value = map(result.value),
+ pos = result.pos,
+ }
+ end
+ return P.unmatch(pos)
+ end
+end
+
+P.lazy = function(factory)
+ return function(input, pos)
+ return factory()(input, pos)
+ end
+end
+
+P.token = function(token)
+ return function(input, pos)
+ local maybe_token = string.sub(input, pos, pos + #token - 1)
+ if token == maybe_token then
+ return {
+ parsed = true,
+ value = maybe_token,
+ pos = pos + #token,
+ }
+ end
+ return P.unmatch(pos)
+ end
+end
+
+P.pattern = function(p)
+ return function(input, pos)
+ local maybe_match = string.match(string.sub(input, pos), '^' .. p)
+ if maybe_match then
+ return {
+ parsed = true,
+ value = maybe_match,
+ pos = pos + #maybe_match,
+ }
+ end
+ return P.unmatch(pos)
+ end
+end
+
+P.many = function(parser)
+ return function(input, pos)
+ local values = {}
+ local new_pos = pos
+ while new_pos <= #input do
+ local result = parser(input, new_pos)
+ if not result.parsed then
+ break
+ end
+ table.insert(values, result.value)
+ new_pos = result.pos
+ end
+ if #values > 0 then
+ return {
+ parsed = true,
+ value = values,
+ pos = new_pos,
+ }
+ end
+ return P.unmatch(pos)
+ end
+end
+
+P.any = function(...)
+ local parsers = { ... }
+ return function(input, pos)
+ for _, parser in ipairs(parsers) do
+ local result = parser(input, pos)
+ if result.parsed then
+ return result
+ end
+ end
+ return P.unmatch(pos)
+ end
+end
+
+P.opt = function(parser)
+ return function(input, pos)
+ local result = parser(input, pos)
+ return {
+ parsed = true,
+ value = result.value,
+ pos = result.pos,
+ }
+ end
+end
+
+P.seq = function(...)
+ local parsers = { ... }
+ return function(input, pos)
+ local values = {}
+ local new_pos = pos
+ for _, parser in ipairs(parsers) do
+ local result = parser(input, new_pos)
+ if result.parsed then
+ table.insert(values, result.value)
+ new_pos = result.pos
+ else
+ return P.unmatch(pos)
+ end
+ end
+ return {
+ parsed = true,
+ value = values,
+ pos = new_pos,
+ }
+ end
+end
+
+local Node = {}
+
+Node.Type = {
+ SNIPPET = 0,
+ TABSTOP = 1,
+ PLACEHOLDER = 2,
+ VARIABLE = 3,
+ CHOICE = 4,
+ TRANSFORM = 5,
+ FORMAT = 6,
+ TEXT = 7,
+}
+
+function Node:__tostring()
+ local insert_text = {}
+ if self.type == Node.Type.SNIPPET then
+ for _, c in ipairs(self.children) do
+ table.insert(insert_text, tostring(c))
+ end
+ elseif self.type == Node.Type.CHOICE then
+ table.insert(insert_text, self.items[1])
+ elseif self.type == Node.Type.PLACEHOLDER then
+ for _, c in ipairs(self.children or {}) do
+ table.insert(insert_text, tostring(c))
+ end
+ elseif self.type == Node.Type.TEXT then
+ table.insert(insert_text, self.esc)
+ end
+ return table.concat(insert_text, '')
+end
+
+--@see https://code.visualstudio.com/docs/editor/userdefinedsnippets#_grammar
+
+local S = {}
+S.dollar = P.token('$')
+S.open = P.token('{')
+S.close = P.token('}')
+S.colon = P.token(':')
+S.slash = P.token('/')
+S.comma = P.token(',')
+S.pipe = P.token('|')
+S.plus = P.token('+')
+S.minus = P.token('-')
+S.question = P.token('?')
+S.int = P.map(P.pattern('[0-9]+'), function(value)
+ return tonumber(value, 10)
+end)
+S.var = P.pattern('[%a_][%w_]+')
+S.text = function(targets, specials)
+ return P.map(P.take_until(targets, specials), function(value)
+ return setmetatable({
+ type = Node.Type.TEXT,
+ raw = value.raw,
+ esc = value.esc,
+ }, Node)
+ end)
+end
+
+S.toplevel = P.lazy(function()
+ return P.any(S.placeholder, S.tabstop, S.variable, S.choice)
+end)
+
+S.format = P.any(
+ P.map(P.seq(S.dollar, S.int), function(values)
+ return setmetatable({
+ type = Node.Type.FORMAT,
+ capture_index = values[2],
+ }, Node)
+ end),
+ P.map(P.seq(S.dollar, S.open, S.int, S.close), function(values)
+ return setmetatable({
+ type = Node.Type.FORMAT,
+ capture_index = values[3],
+ }, Node)
+ end),
+ P.map(P.seq(S.dollar, S.open, S.int, S.colon, S.slash, P.any(
+ P.token('upcase'),
+ P.token('downcase'),
+ P.token('capitalize'),
+ P.token('camelcase'),
+ P.token('pascalcase')
+ ), S.close), function(values)
+ return setmetatable({
+ type = Node.Type.FORMAT,
+ capture_index = values[3],
+ modifier = values[6],
+ }, Node)
+ end),
+ P.map(P.seq(S.dollar, S.open, S.int, S.colon, P.any(
+ P.seq(S.question, P.take_until({ ':' }, { '\\' }), S.colon, P.take_until({ '}' }, { '\\' })),
+ P.seq(S.plus, P.take_until({ '}' }, { '\\' })),
+ P.seq(S.minus, P.take_until({ '}' }, { '\\' }))
+ ), S.close), function(values)
+ return setmetatable({
+ type = Node.Type.FORMAT,
+ capture_index = values[3],
+ if_text = values[5][2].esc,
+ else_text = (values[5][4] or {}).esc,
+ }, Node)
+ end)
+)
+
+S.transform = P.map(P.seq(
+ S.slash,
+ P.take_until({ '/' }, { '\\' }),
+ S.slash,
+ P.many(P.any(S.format, S.text({ '$', '/' }, { '\\' }))),
+ S.slash,
+ P.opt(P.pattern('[ig]+'))
+), function(values)
+ return setmetatable({
+ type = Node.Type.TRANSFORM,
+ pattern = values[2].raw,
+ format = values[4],
+ option = values[6],
+ }, Node)
+end)
+
+S.tabstop = P.any(
+ P.map(P.seq(S.dollar, S.int), function(values)
+ return setmetatable({
+ type = Node.Type.TABSTOP,
+ tabstop = values[2],
+ }, Node)
+ end),
+ P.map(P.seq(S.dollar, S.open, S.int, S.close), function(values)
+ return setmetatable({
+ type = Node.Type.TABSTOP,
+ tabstop = values[3],
+ }, Node)
+ end),
+ P.map(P.seq(S.dollar, S.open, S.int, S.transform, S.close), function(values)
+ return setmetatable({
+ type = Node.Type.TABSTOP,
+ tabstop = values[3],
+ transform = values[4],
+ }, Node)
+ end)
+)
+
+S.placeholder = P.any(
+ P.map(P.seq(S.dollar, S.open, S.int, S.colon, P.many(P.any(S.toplevel, S.text({ '$', '}' }, { '\\' }))), S.close), function(values)
+ return setmetatable({
+ type = Node.Type.PLACEHOLDER,
+ tabstop = values[3],
+ children = values[5],
+ }, Node)
+ end)
+)
+
+S.choice = P.map(P.seq(
+ S.dollar,
+ S.open,
+ S.int,
+ S.pipe,
+ P.many(
+ P.map(P.seq(S.text({ ',', '|' }), P.opt(S.comma)), function(values)
+ return values[1].esc
+ end)
+ ),
+ S.pipe,
+ S.close
+), function(values)
+ return setmetatable({
+ type = Node.Type.CHOICE,
+ tabstop = values[3],
+ items = values[5],
+ }, Node)
+end)
+
+S.variable = P.any(
+ P.map(P.seq(S.dollar, S.var), function(values)
+ return setmetatable({
+ type = Node.Type.VARIABLE,
+ name = values[2],
+ }, Node)
+ end),
+ P.map(P.seq(S.dollar, S.open, S.var, S.close), function(values)
+ return setmetatable({
+ type = Node.Type.VARIABLE,
+ name = values[3],
+ }, Node)
+ end),
+ P.map(P.seq(S.dollar, S.open, S.var, S.transform, S.close), function(values)
+ return setmetatable({
+ type = Node.Type.VARIABLE,
+ name = values[3],
+ transform = values[4],
+ }, Node)
+ end),
+ P.map(P.seq(S.dollar, S.open, S.var, S.colon, P.many(P.any(S.toplevel, S.text({ '$', '}' }, { '\\' }))), S.close), function(values)
+ return setmetatable({
+ type = Node.Type.VARIABLE,
+ name = values[3],
+ children = values[5],
+ }, Node)
+ end)
+)
+
+S.snippet = P.map(P.many(P.any(S.toplevel, S.text({ '$' }, { '}', '\\' }))), function(values)
+ return setmetatable({
+ type = Node.Type.SNIPPET,
+ children = values,
+ }, Node)
+end)
+
+local M = {}
+
+---The snippet node type enum
+---@types table<string, number>
+M.NodeType = Node.Type
+
+---Parse snippet string and returns the AST
+---@param input string
+---@return table
+function M.parse(input)
+ local result = S.snippet(input, 1)
+ if not result.parsed then
+ error('snippet parsing failed.')
+ end
+ return result.value
+end
+
+return M
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 41a62da522..eef840bee5 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -1,48 +1,4 @@
-local api = vim.api
-local validate = vim.validate
-
-local highlight = vim.highlight
local log = require('vim.lsp.log')
-local protocol = require('vim.lsp.protocol')
-local util = require('vim.lsp.util')
-
-local if_nil = vim.F.if_nil
-
----@class DiagnosticSeverity
-local DiagnosticSeverity = protocol.DiagnosticSeverity
-
-local to_severity = function(severity)
- if not severity then return nil end
- return type(severity) == 'string' and DiagnosticSeverity[severity] or severity
-end
-
-local filter_to_severity_limit = function(severity, diagnostics)
- local filter_level = to_severity(severity)
- if not filter_level then
- return diagnostics
- end
-
- return vim.tbl_filter(function(t) return t.severity == filter_level end, diagnostics)
-end
-
-local filter_by_severity_limit = function(severity_limit, diagnostics)
- local filter_level = to_severity(severity_limit)
- if not filter_level then
- return diagnostics
- end
-
- return vim.tbl_filter(function(t) return t.severity <= filter_level end, diagnostics)
-end
-
-local to_position = function(position, bufnr)
- vim.validate { position = {position, 't'} }
-
- return {
- position.line,
- util._get_line_byte_from_position(bufnr, position)
- }
-end
-
---@brief lsp-diagnostic
---
@@ -57,70 +13,9 @@ end
local M = {}
--- Diagnostic Highlights {{{
-
--- TODO(tjdevries): Determine how to generate documentation for these
--- and how to configure them to be easy for users.
---
--- For now, just use the following script. It should work pretty good.
---[[
-local levels = {"Error", "Warning", "Information", "Hint" }
-
-local all_info = {
- { "Default", "Used as the base highlight group, other highlight groups link to", },
- { "VirtualText", 'Used for "%s" diagnostic virtual text.\n See |vim.lsp.diagnostic.set_virtual_text()|', },
- { "Underline", 'Used to underline "%s" diagnostics.\n See |vim.lsp.diagnostic.set_underline()|', },
- { "Floating", 'Used to color "%s" diagnostic messages in diagnostics float.\n See |vim.lsp.diagnostic.show_line_diagnostics()|', },
- { "Sign", 'Used for "%s" signs in sing column.\n See |vim.lsp.diagnostic.set_signs()|', },
-}
-
-local results = {}
-for _, info in ipairs(all_info) do
- for _, level in ipairs(levels) do
- local name = info[1]
- local description = info[2]
- local fullname = string.format("Lsp%s%s", name, level)
- table.insert(results, string.format(
- "%78s", string.format("*hl-%s*", fullname))
- )
-
- table.insert(results, fullname)
- table.insert(results, string.format(" %s", description))
- table.insert(results, "")
- end
-end
-
--- print(table.concat(results, '\n'))
-vim.fn.setreg("*", table.concat(results, '\n'))
---]]
-
-local diagnostic_severities = {
- [DiagnosticSeverity.Error] = { guifg = "Red" };
- [DiagnosticSeverity.Warning] = { guifg = "Orange" };
- [DiagnosticSeverity.Information] = { guifg = "LightBlue" };
- [DiagnosticSeverity.Hint] = { guifg = "LightGrey" };
-}
-
--- Make a map from DiagnosticSeverity -> Highlight Name
-local make_highlight_map = function(base_name)
- local result = {}
- for k, _ in pairs(diagnostic_severities) do
- result[k] = "LspDiagnostics" .. base_name .. DiagnosticSeverity[k]
- end
-
- return result
-end
-
-local default_highlight_map = make_highlight_map("Default")
-local virtual_text_highlight_map = make_highlight_map("VirtualText")
-local underline_highlight_map = make_highlight_map("Underline")
-local floating_highlight_map = make_highlight_map("Floating")
-local sign_highlight_map = make_highlight_map("Sign")
-
--- }}}
--- Diagnostic Namespaces {{{
local DEFAULT_CLIENT_ID = -1
-local get_client_id = function(client_id)
+---@private
+local function get_client_id(client_id)
if client_id == nil then
client_id = DEFAULT_CLIENT_ID
end
@@ -128,179 +23,112 @@ local get_client_id = function(client_id)
return client_id
end
-local get_bufnr = function(bufnr)
+---@private
+local function get_bufnr(bufnr)
if not bufnr then
- return api.nvim_get_current_buf()
+ return vim.api.nvim_get_current_buf()
elseif bufnr == 0 then
- return api.nvim_get_current_buf()
+ return vim.api.nvim_get_current_buf()
end
return bufnr
end
-
---- Create a namespace table, used to track a client's buffer local items
-local _make_namespace_table = function(namespace, api_namespace)
- vim.validate { namespace = { namespace, 's' } }
-
- return setmetatable({
- [DEFAULT_CLIENT_ID] = api.nvim_create_namespace(namespace)
- }, {
- __index = function(t, client_id)
- client_id = get_client_id(client_id)
-
- if rawget(t, client_id) == nil then
- local value = string.format("%s:%s", namespace, client_id)
-
- if api_namespace then
- value = api.nvim_create_namespace(value)
- end
-
- rawset(t, client_id, value)
- end
-
- return rawget(t, client_id)
- end
- })
-end
-
-local _diagnostic_namespaces = _make_namespace_table("vim_lsp_diagnostics", true)
-local _sign_namespaces = _make_namespace_table("vim_lsp_signs", false)
-
---@private
-function M._get_diagnostic_namespace(client_id)
- return _diagnostic_namespaces[client_id]
+local function severity_lsp_to_vim(severity)
+ if type(severity) == 'string' then
+ severity = vim.lsp.protocol.DiagnosticSeverity[severity]
+ end
+ return severity
end
---@private
-function M._get_sign_namespace(client_id)
- return _sign_namespaces[client_id]
-end
--- }}}
--- Diagnostic Buffer & Client metatables {{{
-local bufnr_and_client_cacher_mt = {
- __index = function(t, bufnr)
- if bufnr == 0 or bufnr == nil then
- bufnr = vim.api.nvim_get_current_buf()
- end
-
- if rawget(t, bufnr) == nil then
- rawset(t, bufnr, {})
- end
-
- return rawget(t, bufnr)
- end,
-
- __newindex = function(t, bufnr, v)
- if bufnr == 0 or bufnr == nil then
- bufnr = vim.api.nvim_get_current_buf()
- end
-
- rawset(t, bufnr, v)
- end,
-}
--- }}}
--- Diagnostic Saving & Caching {{{
-local _diagnostic_cleanup = setmetatable({}, bufnr_and_client_cacher_mt)
-local diagnostic_cache = setmetatable({}, bufnr_and_client_cacher_mt)
-local diagnostic_cache_extmarks = setmetatable({}, bufnr_and_client_cacher_mt)
-local diagnostic_cache_lines = setmetatable({}, bufnr_and_client_cacher_mt)
-local diagnostic_cache_counts = setmetatable({}, bufnr_and_client_cacher_mt)
-local diagnostic_attached_buffers = {}
-
--- Disabled buffers and clients
-local diagnostic_disabled = setmetatable({}, bufnr_and_client_cacher_mt)
-
-local _bufs_waiting_to_update = setmetatable({}, bufnr_and_client_cacher_mt)
-
---- Store Diagnostic[] by line
----
----@param diagnostics Diagnostic[]
----@return table<number, Diagnostic[]>
-local _diagnostic_lines = function(diagnostics)
- if not diagnostics then return end
-
- local diagnostics_by_line = {}
- for _, diagnostic in ipairs(diagnostics) do
- local start = diagnostic.range.start
- local line_diagnostics = diagnostics_by_line[start.line]
- if not line_diagnostics then
- line_diagnostics = {}
- diagnostics_by_line[start.line] = line_diagnostics
- end
- table.insert(line_diagnostics, diagnostic)
+local function severity_vim_to_lsp(severity)
+ if type(severity) == 'string' then
+ severity = vim.diagnostic.severity[severity]
end
- return diagnostics_by_line
+ return severity
end
---- Get the count of M by Severity
----
----@param diagnostics Diagnostic[]
----@return table<DiagnosticSeverity, number>
-local _diagnostic_counts = function(diagnostics)
- if not diagnostics then return end
-
- local counts = {}
- for _, diagnostic in pairs(diagnostics) do
- if diagnostic.severity then
- local val = counts[diagnostic.severity]
- if val == nil then
- val = 0
- end
+---@private
+local function line_byte_from_position(lines, lnum, col, offset_encoding)
+ if offset_encoding == "utf-8" then
+ return col
+ end
- counts[diagnostic.severity] = val + 1
- end
+ local line = lines[lnum + 1]
+ local ok, result = pcall(vim.str_byteindex, line, col, offset_encoding == "utf-16")
+ if ok then
+ return result
end
- return counts
+ return col
end
---@private
---- Set the different diagnostic cache after `textDocument/publishDiagnostics`
----@param diagnostics Diagnostic[]
----@param bufnr number
----@param client_id number
----@return nil
-local function set_diagnostic_cache(diagnostics, bufnr, client_id)
- client_id = get_client_id(client_id)
-
- -- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#diagnostic
- --
- -- The diagnostic's severity. Can be omitted. If omitted it is up to the
- -- client to interpret diagnostics as error, warning, info or hint.
- -- TODO: Replace this with server-specific heuristics to infer severity.
- local buf_line_count = vim.api.nvim_buf_line_count(bufnr)
- for _, diagnostic in ipairs(diagnostics) do
- if diagnostic.severity == nil then
- diagnostic.severity = DiagnosticSeverity.Error
- end
- -- Account for servers that place diagnostics on terminating newline
- if buf_line_count > 0 then
- diagnostic.range.start.line = math.max(math.min(
- diagnostic.range.start.line, buf_line_count - 1
- ), 0)
- diagnostic.range["end"].line = math.max(math.min(
- diagnostic.range["end"].line, buf_line_count - 1
- ), 0)
- end
+local function get_buf_lines(bufnr)
+ if vim.api.nvim_buf_is_loaded(bufnr) then
+ return vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
end
- diagnostic_cache[bufnr][client_id] = diagnostics
- diagnostic_cache_lines[bufnr][client_id] = _diagnostic_lines(diagnostics)
- diagnostic_cache_counts[bufnr][client_id] = _diagnostic_counts(diagnostics)
+ local filename = vim.api.nvim_buf_get_name(bufnr)
+ local f = io.open(filename)
+ local lines = vim.split(f:read("*a"), "\n")
+ f:close()
+ return lines
end
+---@private
+local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)
+ local buf_lines = get_buf_lines(bufnr)
+ local client = vim.lsp.get_client_by_id(client_id)
+ local offset_encoding = client and client.offset_encoding or "utf-16"
+ return vim.tbl_map(function(diagnostic)
+ local start = diagnostic.range.start
+ local _end = diagnostic.range["end"]
+ return {
+ lnum = start.line,
+ col = line_byte_from_position(buf_lines, start.line, start.character, offset_encoding),
+ end_lnum = _end.line,
+ end_col = line_byte_from_position(buf_lines, _end.line, _end.character, offset_encoding),
+ severity = severity_lsp_to_vim(diagnostic.severity),
+ message = diagnostic.message
+ }
+ end, diagnostics)
+end
---@private
---- Clear the cached diagnostics
----@param bufnr number
----@param client_id number
-local function clear_diagnostic_cache(bufnr, client_id)
- client_id = get_client_id(client_id)
+local function diagnostic_vim_to_lsp(diagnostics)
+ return vim.tbl_map(function(diagnostic)
+ return {
+ range = {
+ start = {
+ line = diagnostic.lnum,
+ character = diagnostic.col,
+ },
+ ["end"] = {
+ line = diagnostic.end_lnum,
+ character = diagnostic.end_col,
+ },
+ },
+ severity = severity_vim_to_lsp(diagnostic.severity),
+ message = diagnostic.message,
+ }
+ end, diagnostics)
+end
+
+local _client_namespaces = {}
- diagnostic_cache[bufnr][client_id] = nil
- diagnostic_cache_lines[bufnr][client_id] = nil
- diagnostic_cache_counts[bufnr][client_id] = nil
+--- Get the diagnostic namespace associated with an LSP client |vim.diagnostic|.
+---
+---@param client_id number The id of the LSP client
+function M.get_namespace(client_id)
+ vim.validate { client_id = { client_id, 'n' } }
+ if not _client_namespaces[client_id] then
+ local name = string.format("vim.lsp.client-%d", client_id)
+ _client_namespaces[client_id] = vim.api.nvim_create_namespace(name)
+ end
+ return _client_namespaces[client_id]
end
--- Save diagnostics to the current buffer.
@@ -309,86 +137,146 @@ end
---@param diagnostics Diagnostic[]
---@param bufnr number
---@param client_id number
+---@private
function M.save(diagnostics, bufnr, client_id)
- validate {
- diagnostics = {diagnostics, 't'},
- bufnr = {bufnr, 'n'},
- client_id = {client_id, 'n', true},
- }
+ local namespace = M.get_namespace(client_id)
+ vim.diagnostic.set(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id))
+end
+-- }}}
+
+--- |lsp-handler| for the method "textDocument/publishDiagnostics"
+---
+--- See |vim.diagnostic.config()| for configuration options. Handler-specific
+--- configuration can be set using |vim.lsp.with()|:
+--- <pre>
+--- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
+--- vim.lsp.diagnostic.on_publish_diagnostics, {
+--- -- Enable underline, use default values
+--- underline = true,
+--- -- Enable virtual text, override spacing to 4
+--- virtual_text = {
+--- spacing = 4,
+--- },
+--- -- Use a function to dynamically turn signs off
+--- -- and on, using buffer local variables
+--- signs = function(bufnr, client_id)
+--- return vim.bo[bufnr].show_signs == false
+--- end,
+--- -- Disable a feature
+--- update_in_insert = false,
+--- }
+--- )
+--- </pre>
+---
+---@param config table Configuration table (see |vim.diagnostic.config()|).
+function M.on_publish_diagnostics(_, result, ctx, config)
+ local client_id = ctx.client_id
+ local uri = result.uri
+ local bufnr = vim.uri_to_bufnr(uri)
- if not diagnostics then return end
+ if not bufnr then
+ return
+ end
- bufnr = get_bufnr(bufnr)
client_id = get_client_id(client_id)
+ local namespace = M.get_namespace(client_id)
+ local diagnostics = result.diagnostics
- if not _diagnostic_cleanup[bufnr][client_id] then
- _diagnostic_cleanup[bufnr][client_id] = true
+ if config then
+ if vim.F.if_nil(config.severity_sort, false) then
+ table.sort(diagnostics, function(a, b) return a.severity > b.severity end)
+ end
- -- Clean up our data when the buffer unloads.
- api.nvim_buf_attach(bufnr, false, {
- on_detach = function(_, b)
- clear_diagnostic_cache(b, client_id)
- _diagnostic_cleanup[b][client_id] = nil
+ for _, opt in pairs(config) do
+ if type(opt) == 'table' then
+ if not opt.severity and opt.severity_limit then
+ opt.severity = {min=severity_lsp_to_vim(opt.severity_limit)}
+ end
end
- })
+ end
+
+ vim.diagnostic.config(config, namespace)
end
- set_diagnostic_cache(diagnostics, bufnr, client_id)
+ vim.diagnostic.set(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id))
+
+ -- Keep old autocmd for back compat. This should eventually be removed.
+ vim.api.nvim_command("doautocmd <nomodeline> User LspDiagnosticsChanged")
+end
+
+--- Clear diagnotics and diagnostic cache.
+---
+--- Diagnostic producers should prefer |vim.diagnostic.reset()|. However,
+--- this method signature is still used internally in some parts of the LSP
+--- implementation so it's simply marked @private rather than @deprecated.
+---
+---@param client_id number
+---@param buffer_client_map table map of buffers to active clients
+---@private
+function M.reset(client_id, buffer_client_map)
+ buffer_client_map = vim.deepcopy(buffer_client_map)
+ vim.schedule(function()
+ for bufnr, client_ids in pairs(buffer_client_map) do
+ if client_ids[client_id] then
+ local namespace = M.get_namespace(client_id)
+ vim.diagnostic.reset(namespace, bufnr)
+ end
+ end
+ end)
end
--- }}}
--- Diagnostic Retrieval {{{
+-- Deprecated Functions {{{
--- Get all diagnostics for clients
---
+---@deprecated Prefer |vim.diagnostic.get()|
+---
---@param client_id number Restrict included diagnostics to the client
--- If nil, diagnostics of all clients are included.
---@return table with diagnostics grouped by bufnr (bufnr: Diagnostic[])
function M.get_all(client_id)
- local diagnostics_by_bufnr = {}
- for bufnr, buf_diagnostics in pairs(diagnostic_cache) do
- diagnostics_by_bufnr[bufnr] = {}
- for cid, client_diagnostics in pairs(buf_diagnostics) do
- if client_id == nil or cid == client_id then
- vim.list_extend(diagnostics_by_bufnr[bufnr], client_diagnostics)
- end
- end
+ local result = {}
+ local namespace
+ if client_id then
+ namespace = M.get_namespace(client_id)
+ end
+ for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
+ local diagnostics = diagnostic_vim_to_lsp(vim.diagnostic.get(bufnr, {namespace = namespace}))
+ result[bufnr] = diagnostics
end
- return diagnostics_by_bufnr
+ return result
end
--- Return associated diagnostics for bufnr
---
+---@deprecated Prefer |vim.diagnostic.get()|
+---
---@param bufnr number
---@param client_id number|nil If nil, then return all of the diagnostics.
--- Else, return just the diagnostics associated with the client_id.
---@param predicate function|nil Optional function for filtering diagnostics
function M.get(bufnr, client_id, predicate)
+ predicate = predicate or function() return true end
if client_id == nil then
local all_diagnostics = {}
- for iter_client_id, _ in pairs(diagnostic_cache[bufnr]) do
- local iter_diagnostics = M.get(bufnr, iter_client_id, predicate)
-
+ vim.lsp.for_each_buffer_client(bufnr, function(_, iter_client_id, _)
+ local iter_diagnostics = vim.tbl_filter(predicate, M.get(bufnr, iter_client_id))
for _, diagnostic in ipairs(iter_diagnostics) do
table.insert(all_diagnostics, diagnostic)
end
- end
-
+ end)
return all_diagnostics
end
- predicate = predicate or function(_) return true end
- local client_diagnostics = {}
- for _, diagnostic in ipairs(diagnostic_cache[bufnr][client_id] or {}) do
- if predicate(diagnostic) then
- table.insert(client_diagnostics, diagnostic)
- end
- end
- return client_diagnostics
+ local namespace = M.get_namespace(client_id)
+ return diagnostic_vim_to_lsp(vim.tbl_filter(predicate, vim.diagnostic.get(bufnr, {namespace=namespace})))
end
--- Get the diagnostics by line
---
+--- Marked private as this is used internally by the LSP subsystem, but
+--- most users should instead prefer |vim.diagnostic.get()|.
+---
---@param bufnr number|nil The buffer number
---@param line_nr number|nil The line number
---@param opts table|nil Configuration keys
@@ -398,216 +286,134 @@ end
--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
---@param client_id|nil number the client id
---@return table Table with map of line number to list of diagnostics.
--- Structured: { [1] = {...}, [5] = {.... } }
+--- Structured: { [1] = {...}, [5] = {.... } }
+---@private
function M.get_line_diagnostics(bufnr, line_nr, opts, client_id)
opts = opts or {}
-
- bufnr = bufnr or vim.api.nvim_get_current_buf()
- line_nr = line_nr or vim.api.nvim_win_get_cursor(0)[1] - 1
-
- local client_get_diags = function(iter_client_id)
- return (diagnostic_cache_lines[bufnr][iter_client_id] or {})[line_nr] or {}
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
end
- local line_diagnostics
- if client_id == nil then
- line_diagnostics = {}
- for iter_client_id, _ in pairs(diagnostic_cache_lines[bufnr]) do
- for _, diagnostic in ipairs(client_get_diags(iter_client_id)) do
- table.insert(line_diagnostics, diagnostic)
- end
- end
- else
- line_diagnostics = vim.deepcopy(client_get_diags(client_id))
+ if client_id then
+ opts.namespace = M.get_namespace(client_id)
end
- if opts.severity then
- line_diagnostics = filter_to_severity_limit(opts.severity, line_diagnostics)
- elseif opts.severity_limit then
- line_diagnostics = filter_by_severity_limit(opts.severity_limit, line_diagnostics)
+ if not line_nr then
+ line_nr = vim.api.nvim_win_get_cursor(0)[1] - 1
end
- table.sort(line_diagnostics, function(a, b) return a.severity < b.severity end)
+ opts.lnum = line_nr
- return line_diagnostics
+ return diagnostic_vim_to_lsp(vim.diagnostic.get(bufnr, opts))
end
--- Get the counts for a particular severity
---
---- Useful for showing diagnostic counts in statusline. eg:
----
---- <pre>
---- function! LspStatus() abort
---- let sl = ''
---- if luaeval('not vim.tbl_isempty(vim.lsp.buf_get_clients(0))')
---- let sl.='%#MyStatuslineLSP#E:'
---- let sl.='%#MyStatuslineLSPErrors#%{luaeval("vim.lsp.diagnostic.get_count(0, [[Error]])")}'
---- let sl.='%#MyStatuslineLSP# W:'
---- let sl.='%#MyStatuslineLSPWarnings#%{luaeval("vim.lsp.diagnostic.get_count(0, [[Warning]])")}'
---- else
---- let sl.='%#MyStatuslineLSPErrors#off'
---- endif
---- return sl
---- endfunction
---- let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus()
---- </pre>
+---@deprecated Prefer |vim.diagnostic.get_count()|
---
---@param bufnr number The buffer number
---@param severity DiagnosticSeverity
---@param client_id number the client id
function M.get_count(bufnr, severity, client_id)
- if client_id == nil then
- local total = 0
- for iter_client_id, _ in pairs(diagnostic_cache_counts[bufnr]) do
- total = total + M.get_count(bufnr, severity, iter_client_id)
- end
-
- return total
- end
-
- return (diagnostic_cache_counts[bufnr][client_id] or {})[DiagnosticSeverity[severity]] or 0
-end
-
-
--- }}}
--- Diagnostic Movements {{{
-
---- Helper function to find the next diagnostic relative to a position
----@return table the next diagnostic if found
-local _next_diagnostic = function(position, search_forward, bufnr, opts, client_id)
- position[1] = position[1] - 1
- bufnr = bufnr or vim.api.nvim_get_current_buf()
- local wrap = if_nil(opts.wrap, true)
- local line_count = vim.api.nvim_buf_line_count(bufnr)
- for i = 0, line_count do
- local offset = i * (search_forward and 1 or -1)
- local line_nr = position[1] + offset
- if line_nr < 0 or line_nr >= line_count then
- if not wrap then
- return
- end
- line_nr = (line_nr + line_count) % line_count
- end
- local line_diagnostics = M.get_line_diagnostics(bufnr, line_nr, opts, client_id)
- if line_diagnostics and not vim.tbl_isempty(line_diagnostics) then
- local sort_diagnostics, is_next
- if search_forward then
- sort_diagnostics = function(a, b) return a.range.start.character < b.range.start.character end
- is_next = function(diagnostic) return diagnostic.range.start.character > position[2] end
- else
- sort_diagnostics = function(a, b) return a.range.start.character > b.range.start.character end
- is_next = function(diagnostic) return diagnostic.range.start.character < position[2] end
- end
- table.sort(line_diagnostics, sort_diagnostics)
- if i == 0 then
- for _, v in pairs(line_diagnostics) do
- if is_next(v) then
- return v
- end
- end
- else
- return line_diagnostics[1]
- end
- end
+ severity = severity_lsp_to_vim(severity)
+ local opts = { severity = severity }
+ if client_id ~= nil then
+ opts.namespace = M.get_namespace(client_id)
end
-end
-
----@private
---- Helper function to return a position from a diagnostic
----
----@return table {row, col}
-local function _diagnostic_pos(opts, diagnostic)
- opts = opts or {}
- local win_id = opts.win_id or vim.api.nvim_get_current_win()
- local bufnr = vim.api.nvim_win_get_buf(win_id)
-
- if not diagnostic then return false end
-
- return to_position(diagnostic.range.start, bufnr)
-end
-
----@private
--- Move to the diagnostic position
-local function _diagnostic_move_pos(name, opts, pos)
- opts = opts or {}
-
- local enable_popup = if_nil(opts.enable_popup, true)
- local win_id = opts.win_id or vim.api.nvim_get_current_win()
-
- if not pos then
- print(string.format("%s: No more valid diagnostics to move to.", name))
- return
- end
-
- vim.api.nvim_win_set_cursor(win_id, {pos[1] + 1, pos[2]})
-
- if enable_popup then
- -- This is a bit weird... I'm surprised that we need to wait til the next tick to do this.
- vim.schedule(function()
- M.show_position_diagnostics(opts.popup_opts, vim.api.nvim_win_get_buf(win_id))
- end)
- end
+ return #vim.diagnostic.get(bufnr, opts)
end
--- Get the previous diagnostic closest to the cursor_position
---
+---@deprecated Prefer |vim.diagnostic.get_prev()|
+---
---@param opts table See |vim.lsp.diagnostic.goto_next()|
---@return table Previous diagnostic
function M.get_prev(opts)
- opts = opts or {}
-
- local win_id = opts.win_id or vim.api.nvim_get_current_win()
- local bufnr = vim.api.nvim_win_get_buf(win_id)
- local cursor_position = opts.cursor_position or vim.api.nvim_win_get_cursor(win_id)
-
- return _next_diagnostic(cursor_position, false, bufnr, opts, opts.client_id)
+ if opts then
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
+ end
+ end
+ return diagnostic_vim_to_lsp({vim.diagnostic.get_prev(opts)})[1]
end
--- Return the pos, {row, col}, for the prev diagnostic in the current buffer.
+---
+---@deprecated Prefer |vim.diagnostic.get_prev_pos()|
+---
---@param opts table See |vim.lsp.diagnostic.goto_next()|
---@return table Previous diagnostic position
function M.get_prev_pos(opts)
- return _diagnostic_pos(
- opts,
- M.get_prev(opts)
- )
+ if opts then
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
+ end
+ end
+ return vim.diagnostic.get_prev_pos(opts)
end
--- Move to the previous diagnostic
+---
+---@deprecated Prefer |vim.diagnostic.goto_prev()|
+---
---@param opts table See |vim.lsp.diagnostic.goto_next()|
function M.goto_prev(opts)
- return _diagnostic_move_pos(
- "DiagnosticPrevious",
- opts,
- M.get_prev_pos(opts)
- )
+ if opts then
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
+ end
+ end
+ return vim.diagnostic.goto_prev(opts)
end
--- Get the next diagnostic closest to the cursor_position
+---
+---@deprecated Prefer |vim.diagnostic.get_next()|
+---
---@param opts table See |vim.lsp.diagnostic.goto_next()|
---@return table Next diagnostic
function M.get_next(opts)
- opts = opts or {}
-
- local win_id = opts.win_id or vim.api.nvim_get_current_win()
- local bufnr = vim.api.nvim_win_get_buf(win_id)
- local cursor_position = opts.cursor_position or vim.api.nvim_win_get_cursor(win_id)
-
- return _next_diagnostic(cursor_position, true, bufnr, opts, opts.client_id)
+ if opts then
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
+ end
+ end
+ return diagnostic_vim_to_lsp({vim.diagnostic.get_next(opts)})[1]
end
--- Return the pos, {row, col}, for the next diagnostic in the current buffer.
+---
+---@deprecated Prefer |vim.diagnostic.get_next_pos()|
+---
---@param opts table See |vim.lsp.diagnostic.goto_next()|
---@return table Next diagnostic position
function M.get_next_pos(opts)
- return _diagnostic_pos(
- opts,
- M.get_next(opts)
- )
+ if opts then
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
+ end
+ end
+ return vim.diagnostic.get_next_pos(opts)
end
--- Move to the next diagnostic
+---
+---@deprecated Prefer |vim.diagnostic.goto_next()|
+---
---@param opts table|nil Configuration table. Keys:
--- - {client_id}: (number)
--- - If nil, will consider all clients attached to buffer.
@@ -626,25 +432,20 @@ end
--- - {win_id}: (number, default 0)
--- - Window ID
function M.goto_next(opts)
- return _diagnostic_move_pos(
- "DiagnosticNext",
- opts,
- M.get_next_pos(opts)
- )
+ if opts then
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
+ end
+ end
+ return vim.diagnostic.goto_next(opts)
end
--- }}}
--- Diagnostic Setters {{{
--- Set signs for given diagnostics
---
---- Sign characters can be customized with the following commands:
+---@deprecated Prefer |vim.diagnostic._set_signs()|
---
---- <pre>
---- sign define LspDiagnosticsSignError text=E texthl=LspDiagnosticsSignError linehl= numhl=
---- sign define LspDiagnosticsSignWarning text=W texthl=LspDiagnosticsSignWarning linehl= numhl=
---- sign define LspDiagnosticsSignInformation text=I texthl=LspDiagnosticsSignInformation linehl= numhl=
---- sign define LspDiagnosticsSignHint text=H texthl=LspDiagnosticsSignHint linehl= numhl=
---- </pre>
---@param diagnostics Diagnostic[]
---@param bufnr number The buffer number
---@param client_id number the client id
@@ -653,36 +454,13 @@ end
--- - priority: Set the priority of the signs.
--- - severity_limit (DiagnosticSeverity):
--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
-function M.set_signs(diagnostics, bufnr, client_id, sign_ns, opts)
- opts = opts or {}
- sign_ns = sign_ns or M._get_sign_namespace(client_id)
-
- if not diagnostics then
- diagnostics = diagnostic_cache[bufnr][client_id]
- end
-
- if not diagnostics then
- return
- end
-
- bufnr = get_bufnr(bufnr)
- diagnostics = filter_by_severity_limit(opts.severity_limit, diagnostics)
-
- local ok = true
- for _, diagnostic in ipairs(diagnostics) do
-
- ok = ok and pcall(vim.fn.sign_place,
- 0,
- sign_ns,
- sign_highlight_map[diagnostic.severity],
- bufnr,
- {
- priority = opts.priority,
- lnum = diagnostic.range.start.line + 1
- }
- )
+function M.set_signs(diagnostics, bufnr, client_id, _, opts)
+ local namespace = M.get_namespace(client_id)
+ if opts and not opts.severity and opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
end
+ local ok = vim.diagnostic._set_signs(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id), opts)
if not ok then
log.debug("Failed to place signs:", diagnostics)
end
@@ -690,14 +468,7 @@ end
--- Set underline for given diagnostics
---
---- Underline highlights can be customized by changing the following |:highlight| groups.
----
---- <pre>
---- LspDiagnosticsUnderlineError
---- LspDiagnosticsUnderlineWarning
---- LspDiagnosticsUnderlineInformation
---- LspDiagnosticsUnderlineHint
---- </pre>
+---@deprecated Prefer |vim.diagnostic._set_underline()|
---
---@param diagnostics Diagnostic[]
---@param bufnr number: The buffer number
@@ -706,43 +477,17 @@ end
---@param opts table: Configuration table:
--- - severity_limit (DiagnosticSeverity):
--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
-function M.set_underline(diagnostics, bufnr, client_id, diagnostic_ns, opts)
- opts = opts or {}
-
- diagnostic_ns = diagnostic_ns or M._get_diagnostic_namespace(client_id)
- diagnostics = filter_by_severity_limit(opts.severity_limit, diagnostics)
-
- for _, diagnostic in ipairs(diagnostics) do
- local start = diagnostic.range["start"]
- local finish = diagnostic.range["end"]
- local higroup = underline_highlight_map[diagnostic.severity]
-
- if higroup == nil then
- -- Default to error if we don't have a highlight associated
- higroup = underline_highlight_map[DiagnosticSeverity.Error]
- end
-
- highlight.range(
- bufnr,
- diagnostic_ns,
- higroup,
- to_position(start, bufnr),
- to_position(finish, bufnr)
- )
+function M.set_underline(diagnostics, bufnr, client_id, _, opts)
+ local namespace = M.get_namespace(client_id)
+ if opts and not opts.severity and opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
end
+ return vim.diagnostic._set_underline(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id), opts)
end
--- Virtual Text {{{
--- Set virtual text given diagnostics
---
---- Virtual text highlights can be customized by changing the following |:highlight| groups.
----
---- <pre>
---- LspDiagnosticsVirtualTextError
---- LspDiagnosticsVirtualTextWarning
---- LspDiagnosticsVirtualTextInformation
---- LspDiagnosticsVirtualTextHint
---- </pre>
+---@deprecated Prefer |vim.diagnostic._set_virtual_text()|
---
---@param diagnostics Diagnostic[]
---@param bufnr number
@@ -753,436 +498,75 @@ end
--- - spacing (number): Number of spaces to insert before virtual text
--- - severity_limit (DiagnosticSeverity):
--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
-function M.set_virtual_text(diagnostics, bufnr, client_id, diagnostic_ns, opts)
- opts = opts or {}
-
- client_id = get_client_id(client_id)
- diagnostic_ns = diagnostic_ns or M._get_diagnostic_namespace(client_id)
-
- local buffer_line_diagnostics
- if diagnostics then
- buffer_line_diagnostics = _diagnostic_lines(diagnostics)
- else
- buffer_line_diagnostics = diagnostic_cache_lines[bufnr][client_id]
- end
-
- if not buffer_line_diagnostics then
- return nil
- end
-
- for line, line_diagnostics in pairs(buffer_line_diagnostics) do
- line_diagnostics = filter_by_severity_limit(opts.severity_limit, line_diagnostics)
- local virt_texts = M.get_virtual_text_chunks_for_line(bufnr, line, line_diagnostics, opts)
-
- if virt_texts then
- api.nvim_buf_set_extmark(bufnr, diagnostic_ns, line, 0, {
- virt_text = virt_texts,
- })
- end
+function M.set_virtual_text(diagnostics, bufnr, client_id, _, opts)
+ local namespace = M.get_namespace(client_id)
+ if opts and not opts.severity and opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
end
+ return vim.diagnostic._set_virtual_text(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id), opts)
end
--- Default function to get text chunks to display using |nvim_buf_set_extmark()|.
+---
+---@deprecated Prefer |vim.diagnostic.get_virt_text_chunks()|
+---
---@param bufnr number The buffer to display the virtual text in
---@param line number The line number to display the virtual text on
---@param line_diags Diagnostic[] The diagnostics associated with the line
---@param opts table See {opts} from |vim.lsp.diagnostic.set_virtual_text()|
---@return an array of [text, hl_group] arrays. This can be passed directly to
--- the {virt_text} option of |nvim_buf_set_extmark()|.
-function M.get_virtual_text_chunks_for_line(bufnr, line, line_diags, opts)
- assert(bufnr or line)
-
- if #line_diags == 0 then
- return nil
- end
-
- opts = opts or {}
- local prefix = opts.prefix or "■"
- local spacing = opts.spacing or 4
-
- -- Create a little more space between virtual text and contents
- local virt_texts = {{string.rep(" ", spacing)}}
-
- for i = 1, #line_diags - 1 do
- table.insert(virt_texts, {prefix, virtual_text_highlight_map[line_diags[i].severity]})
- end
- local last = line_diags[#line_diags]
-
- -- TODO(tjdevries): Allow different servers to be shown first somehow?
- -- TODO(tjdevries): Display server name associated with these?
- if last.message then
- table.insert(
- virt_texts,
- {
- string.format("%s %s", prefix, last.message:gsub("\r", ""):gsub("\n", " ")),
- virtual_text_highlight_map[last.severity]
- }
- )
-
- return virt_texts
- end
+function M.get_virtual_text_chunks_for_line(bufnr, _, line_diags, opts)
+ return vim.diagnostic.get_virt_text_chunks(diagnostic_lsp_to_vim(line_diags, bufnr), opts)
end
--- }}}
--- }}}
--- Diagnostic Clear {{{
---- Clears the currently displayed diagnostics
----@param bufnr number The buffer number
----@param client_id number the client id
----@param diagnostic_ns number|nil Associated diagnostic namespace
----@param sign_ns number|nil Associated sign namespace
-function M.clear(bufnr, client_id, diagnostic_ns, sign_ns)
- bufnr = get_bufnr(bufnr)
- if client_id == nil then
- return vim.lsp.for_each_buffer_client(bufnr, function(_, iter_client_id, _)
- return M.clear(bufnr, iter_client_id)
- end)
- end
-
- diagnostic_ns = diagnostic_ns or M._get_diagnostic_namespace(client_id)
- sign_ns = sign_ns or M._get_sign_namespace(client_id)
- diagnostic_cache_extmarks[bufnr][client_id] = {}
- assert(bufnr, "bufnr is required")
- assert(diagnostic_ns, "Need diagnostic_ns, got nil")
- assert(sign_ns, string.format("Need sign_ns, got nil %s", sign_ns))
-
- -- clear sign group
- vim.fn.sign_unplace(sign_ns, {buffer=bufnr})
-
- -- clear virtual text namespace
- api.nvim_buf_clear_namespace(bufnr, diagnostic_ns, 0, -1)
-end
--- }}}
--- Diagnostic Insert Leave Handler {{{
-
---- Callback scheduled for after leaving insert mode
----
---- Used to handle
----@private
-function M._execute_scheduled_display(bufnr, client_id)
- local args = _bufs_waiting_to_update[bufnr][client_id]
- if not args then
- return
- end
-
- -- Clear the args so we don't display unnecessarily.
- _bufs_waiting_to_update[bufnr][client_id] = nil
-
- M.display(nil, bufnr, client_id, args)
-end
-
-local registered = {}
-
-local make_augroup_key = function(bufnr, client_id)
- return string.format("LspDiagnosticInsertLeave:%s:%s", bufnr, client_id)
-end
-
---- Table of autocmd events to fire the update for displaying new diagnostic information
-M.insert_leave_auto_cmds = { "InsertLeave", "CursorHoldI" }
-
---- Used to schedule diagnostic updates upon leaving insert mode.
+--- Open a floating window with the diagnostics from {position}
---
---- For parameter description, see |M.display()|
-function M._schedule_display(bufnr, client_id, args)
- _bufs_waiting_to_update[bufnr][client_id] = args
-
- local key = make_augroup_key(bufnr, client_id)
- if not registered[key] then
- vim.cmd(string.format("augroup %s", key))
- vim.cmd(" au!")
- vim.cmd(
- string.format(
- [[autocmd %s <buffer=%s> :lua vim.lsp.diagnostic._execute_scheduled_display(%s, %s)]],
- table.concat(M.insert_leave_auto_cmds, ","),
- bufnr,
- bufnr,
- client_id
- )
- )
- vim.cmd("augroup END")
-
- registered[key] = true
- end
-end
-
-
---- Used in tandem with
+---@deprecated Prefer |vim.diagnostic.show_position_diagnostics()|
---
---- For parameter description, see |M.display()|
-function M._clear_scheduled_display(bufnr, client_id)
- local key = make_augroup_key(bufnr, client_id)
-
- if registered[key] then
- vim.cmd(string.format("augroup %s", key))
- vim.cmd(" au!")
- vim.cmd("augroup END")
-
- registered[key] = nil
- end
-end
--- }}}
-
--- Diagnostic Private Highlight Utilies {{{
---- Get the severity highlight name
----@private
-function M._get_severity_highlight_name(severity)
- return virtual_text_highlight_map[severity]
-end
-
---- Get floating severity highlight name
----@private
-function M._get_floating_severity_highlight_name(severity)
- return floating_highlight_map[severity]
-end
-
---- This should be called to update the highlights for the LSP client.
-function M._define_default_signs_and_highlights()
- ---@private
- local function define_default_sign(name, properties)
- if vim.tbl_isempty(vim.fn.sign_getdefined(name)) then
- vim.fn.sign_define(name, properties)
+---@param opts table|nil Configuration keys
+--- - severity: (DiagnosticSeverity, default nil)
+--- - Only return diagnostics with this severity. Overrides severity_limit
+--- - severity_limit: (DiagnosticSeverity, default nil)
+--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
+--- - all opts for |show_diagnostics()| can be used here
+---@param buf_nr number|nil The buffer number
+---@param position table|nil The (0,0)-indexed position
+---@return table {popup_bufnr, win_id}
+function M.show_position_diagnostics(opts, buf_nr, position)
+ if opts then
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
end
end
-
- -- Initialize default diagnostic highlights
- for severity, hi_info in pairs(diagnostic_severities) do
- local default_highlight_name = default_highlight_map[severity]
- highlight.create(default_highlight_name, hi_info, true)
-
- -- Default link all corresponding highlights to the default highlight
- highlight.link(virtual_text_highlight_map[severity], default_highlight_name, false)
- highlight.link(floating_highlight_map[severity], default_highlight_name, false)
- highlight.link(sign_highlight_map[severity], default_highlight_name, false)
- end
-
- -- Create all signs
- for severity, sign_hl_name in pairs(sign_highlight_map) do
- local severity_name = DiagnosticSeverity[severity]
-
- define_default_sign(sign_hl_name, {
- text = (severity_name or 'U'):sub(1, 1),
- texthl = sign_hl_name,
- linehl = '',
- numhl = '',
- })
- end
-
- -- Initialize Underline highlights
- for severity, underline_highlight_name in pairs(underline_highlight_map) do
- highlight.create(underline_highlight_name, {
- cterm = 'underline',
- gui = 'underline',
- guisp = diagnostic_severities[severity].guifg
- }, true)
- end
+ return vim.diagnostic.show_position_diagnostics(opts, buf_nr, position)
end
--- }}}
--- Diagnostic Display {{{
---- |lsp-handler| for the method "textDocument/publishDiagnostics"
+--- Open a floating window with the diagnostics from {line_nr}
---
----@note Each of the configuration options accepts:
---- - `false`: Disable this feature
---- - `true`: Enable this feature, use default settings.
---- - `table`: Enable this feature, use overrides.
---- - `function`: Function with signature (bufnr, client_id) that returns any of the above.
---- <pre>
---- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
---- vim.lsp.diagnostic.on_publish_diagnostics, {
---- -- Enable underline, use default values
---- underline = true,
---- -- Enable virtual text, override spacing to 4
---- virtual_text = {
---- spacing = 4,
---- },
---- -- Use a function to dynamically turn signs off
---- -- and on, using buffer local variables
---- signs = function(bufnr, client_id)
---- return vim.bo[bufnr].show_signs == false
---- end,
---- -- Disable a feature
---- update_in_insert = false,
---- }
---- )
---- </pre>
+---@deprecated Prefer |vim.diagnostic.show_line_diagnostics()|
---
----@param config table Configuration table.
---- - underline: (default=true)
---- - Apply underlines to diagnostics.
---- - See |vim.lsp.diagnostic.set_underline()|
---- - virtual_text: (default=true)
---- - Apply virtual text to line endings.
---- - See |vim.lsp.diagnostic.set_virtual_text()|
---- - signs: (default=true)
---- - Apply signs for diagnostics.
---- - See |vim.lsp.diagnostic.set_signs()|
---- - update_in_insert: (default=false)
---- - Update diagnostics in InsertMode or wait until InsertLeave
---- - severity_sort: (default=false)
---- - Sort diagnostics (and thus signs and virtual text)
-function M.on_publish_diagnostics(_, result, ctx, config)
- local client_id = ctx.client_id
- local uri = result.uri
- local bufnr = vim.uri_to_bufnr(uri)
-
- if not bufnr then
- return
- end
-
- local diagnostics = result.diagnostics
-
- if config and if_nil(config.severity_sort, false) then
- table.sort(diagnostics, function(a, b) return a.severity > b.severity end)
- end
-
- -- Always save the diagnostics, even if the buf is not loaded.
- -- Language servers may report compile or build errors via diagnostics
- -- Users should be able to find these, even if they're in files which
- -- are not loaded.
- M.save(diagnostics, bufnr, client_id)
-
- -- Unloaded buffers should not handle diagnostics.
- -- When the buffer is loaded, we'll call on_attach, which sends textDocument/didOpen.
- -- This should trigger another publish of the diagnostics.
- --
- -- In particular, this stops a ton of spam when first starting a server for current
- -- unloaded buffers.
- if not api.nvim_buf_is_loaded(bufnr) then
- return
- end
-
- M.display(diagnostics, bufnr, client_id, config)
-end
-
--- restores the extmarks set by M.display
----@param last number last line that was changed
----@private
-local function restore_extmarks(bufnr, last)
- for client_id, extmarks in pairs(diagnostic_cache_extmarks[bufnr]) do
- local ns = M._get_diagnostic_namespace(client_id)
- local extmarks_current = api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {details = true})
- local found = {}
- for _, extmark in ipairs(extmarks_current) do
- -- nvim_buf_set_lines will move any extmark to the line after the last
- -- nvim_buf_set_text will move any extmark to the last line
- if extmark[2] ~= last + 1 then
- found[extmark[1]] = true
- end
- end
- for _, extmark in ipairs(extmarks) do
- if not found[extmark[1]] then
- local opts = extmark[4]
- opts.id = extmark[1]
- -- HACK: end_row should be end_line
- if opts.end_row then
- opts.end_line = opts.end_row
- opts.end_row = nil
- end
- pcall(api.nvim_buf_set_extmark, bufnr, ns, extmark[2], extmark[3], opts)
- end
- end
- end
-end
-
--- caches the extmarks set by M.display
----@private
-local function save_extmarks(bufnr, client_id)
- bufnr = bufnr == 0 and api.nvim_get_current_buf() or bufnr
- if not diagnostic_attached_buffers[bufnr] then
- api.nvim_buf_attach(bufnr, false, {
- on_lines = function(_, _, _, _, _, last)
- restore_extmarks(bufnr, last - 1)
- end,
- on_detach = function()
- diagnostic_cache_extmarks[bufnr] = nil
- end})
- diagnostic_attached_buffers[bufnr] = true
- end
- local ns = M._get_diagnostic_namespace(client_id)
- diagnostic_cache_extmarks[bufnr][client_id] = api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {details = true})
-end
-
----@private
---- Display diagnostics for the buffer, given a configuration.
-function M.display(diagnostics, bufnr, client_id, config)
- if diagnostic_disabled[bufnr][client_id] then
- return
- end
-
- config = vim.lsp._with_extend('vim.lsp.diagnostic.on_publish_diagnostics', {
- signs = true,
- underline = true,
- virtual_text = true,
- update_in_insert = false,
- severity_sort = false,
- }, config)
-
- -- TODO(tjdevries): Consider how we can make this a "standardized" kind of thing for |lsp-handlers|.
- -- It seems like we would probably want to do this more often as we expose more of them.
- -- It provides a very nice functional interface for people to override configuration.
- local resolve_optional_value = function(option)
- local enabled_val = {}
-
- if not option then
- return false
- elseif option == true then
- return enabled_val
- elseif type(option) == 'function' then
- local val = option(bufnr, client_id)
- if val == true then
- return enabled_val
- else
- return val
- end
- elseif type(option) == 'table' then
- return option
- else
- error("Unexpected option type: " .. vim.inspect(option))
- end
- end
-
- if resolve_optional_value(config.update_in_insert) then
- M._clear_scheduled_display(bufnr, client_id)
- else
- local mode = vim.api.nvim_get_mode()
-
- if string.sub(mode.mode, 1, 1) == 'i' then
- M._schedule_display(bufnr, client_id, config)
- return
- end
- end
-
- M.clear(bufnr, client_id)
-
- diagnostics = diagnostics or M.get(bufnr, client_id)
-
- vim.api.nvim_command("doautocmd <nomodeline> User LspDiagnosticsChanged")
-
- if not diagnostics or vim.tbl_isempty(diagnostics) then
- return
- end
-
- local underline_opts = resolve_optional_value(config.underline)
- if underline_opts then
- M.set_underline(diagnostics, bufnr, client_id, nil, underline_opts)
- end
-
- local virtual_text_opts = resolve_optional_value(config.virtual_text)
- if virtual_text_opts then
- M.set_virtual_text(diagnostics, bufnr, client_id, nil, virtual_text_opts)
- end
-
- local signs_opts = resolve_optional_value(config.signs)
- if signs_opts then
- M.set_signs(diagnostics, bufnr, client_id, nil, signs_opts)
+---@param opts table Configuration table
+--- - all opts for |vim.lsp.diagnostic.get_line_diagnostics()| and
+--- |show_diagnostics()| can be used here
+---@param buf_nr number|nil The buffer number
+---@param line_nr number|nil The line number
+---@param client_id number|nil the client id
+---@return table {popup_bufnr, win_id}
+function M.show_line_diagnostics(opts, buf_nr, line_nr, client_id)
+ if client_id then
+ opts = opts or {}
+ opts.namespace = M.get_namespace(client_id)
end
-
- -- cache extmarks
- save_extmarks(bufnr, client_id)
+ return vim.diagnostic.show_line_diagnostics(opts, buf_nr, line_nr)
end
--- Redraw diagnostics for the given buffer and client
---
+---@deprecated Prefer |vim.diagnostic.redraw()|
+---
--- This calls the "textDocument/publishDiagnostics" handler manually using
--- the cached diagnostics already received from the server. This can be useful
--- for redrawing diagnostics after making changes in diagnostics
@@ -1200,183 +584,14 @@ function M.redraw(bufnr, client_id)
end)
end
- -- We need to invoke the publishDiagnostics handler directly instead of just
- -- calling M.display so that we can preserve any custom configuration options
- -- the user may have set with vim.lsp.with.
- vim.lsp.handlers["textDocument/publishDiagnostics"](
- nil,
- {
- uri = vim.uri_from_bufnr(bufnr),
- diagnostics = M.get(bufnr, client_id),
- },
- {
- method = "textDocument/publishDiagnostics",
- client_id = client_id,
- bufnr = bufnr,
- }
- )
- end
-
-
----@private
---- Open a floating window with the provided diagnostics
----
---- The floating window can be customized with the following highlight groups:
---- <pre>
---- LspDiagnosticsFloatingError
---- LspDiagnosticsFloatingWarning
---- LspDiagnosticsFloatingInformation
---- LspDiagnosticsFloatingHint
---- </pre>
----@param opts table Configuration table
---- - show_header (boolean, default true): Show "Diagnostics:" header
---- - all opts for |vim.lsp.util.open_floating_preview()| can be used here
----@param diagnostics table: The diagnostics to display
----@return table {popup_bufnr, win_id}
-local function show_diagnostics(opts, diagnostics)
- if vim.tbl_isempty(diagnostics) then return end
- local lines = {}
- local highlights = {}
- local show_header = if_nil(opts.show_header, true)
- if show_header then
- table.insert(lines, "Diagnostics:")
- table.insert(highlights, {0, "Bold"})
- end
-
- for i, diagnostic in ipairs(diagnostics) do
- local prefix = string.format("%d. ", i)
- local hiname = M._get_floating_severity_highlight_name(diagnostic.severity)
- assert(hiname, 'unknown severity: ' .. tostring(diagnostic.severity))
-
- local message_lines = vim.split(diagnostic.message, '\n', true)
- table.insert(lines, prefix..message_lines[1])
- table.insert(highlights, {#prefix, hiname})
- for j = 2, #message_lines do
- table.insert(lines, string.rep(' ', #prefix) .. message_lines[j])
- table.insert(highlights, {0, hiname})
- end
- end
-
- local popup_bufnr, winnr = util.open_floating_preview(lines, 'plaintext', opts)
- for i, hi in ipairs(highlights) do
- local prefixlen, hiname = unpack(hi)
- -- Start highlight after the prefix
- api.nvim_buf_add_highlight(popup_bufnr, -1, hiname, i-1, prefixlen, -1)
- end
-
- return popup_bufnr, winnr
-end
-
-
--- }}}
--- Diagnostic User Functions {{{
-
---- Open a floating window with the diagnostics from {position}
----@param opts table|nil Configuration keys
---- - severity: (DiagnosticSeverity, default nil)
---- - Only return diagnostics with this severity. Overrides severity_limit
---- - severity_limit: (DiagnosticSeverity, default nil)
---- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
---- - all opts for |show_diagnostics()| can be used here
----@param buf_nr number|nil The buffer number
----@param position table|nil The (0,0)-indexed position
----@return table {popup_bufnr, win_id}
-function M.show_position_diagnostics(opts, buf_nr, position)
- opts = opts or {}
- opts.focus_id = "position_diagnostics"
- buf_nr = buf_nr or vim.api.nvim_get_current_buf()
- if not position then
- local curr_position = vim.api.nvim_win_get_cursor(0)
- curr_position[1] = curr_position[1] - 1
- position = curr_position
- end
- local match_position_predicate = function(diag)
- return position[1] == diag.range['start'].line and
- position[2] >= diag.range['start'].character and
- (position[2] <= diag.range['end'].character or position[1] < diag.range['end'].line)
- end
- local position_diagnostics = M.get(buf_nr, nil, match_position_predicate)
- if opts.severity then
- position_diagnostics = filter_to_severity_limit(opts.severity, position_diagnostics)
- elseif opts.severity_limit then
- position_diagnostics = filter_by_severity_limit(opts.severity_limit, position_diagnostics)
- end
- table.sort(position_diagnostics, function(a, b) return a.severity < b.severity end)
- return show_diagnostics(opts, position_diagnostics)
-end
-
---- Open a floating window with the diagnostics from {line_nr}
-
----@param opts table Configuration table
---- - all opts for |vim.lsp.diagnostic.get_line_diagnostics()| and
---- |show_diagnostics()| can be used here
----@param buf_nr number|nil The buffer number
----@param line_nr number|nil The line number
----@param client_id number|nil the client id
----@return table {popup_bufnr, win_id}
-function M.show_line_diagnostics(opts, buf_nr, line_nr, client_id)
- opts = opts or {}
- opts.focus_id = "line_diagnostics"
- line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1)
- local line_diagnostics = M.get_line_diagnostics(buf_nr, line_nr, opts, client_id)
- return show_diagnostics(opts, line_diagnostics)
-end
-
---- Clear diagnotics and diagnostic cache
----
---- Handles saving diagnostics from multiple clients in the same buffer.
----@param client_id number
----@param buffer_client_map table map of buffers to active clients
-function M.reset(client_id, buffer_client_map)
- buffer_client_map = vim.deepcopy(buffer_client_map)
- vim.schedule(function()
- for bufnr, client_ids in pairs(buffer_client_map) do
- if client_ids[client_id] then
- clear_diagnostic_cache(bufnr, client_id)
- M.clear(bufnr, client_id)
- end
- end
- end)
-end
-
----@private
---- Gets diagnostics, converts them to quickfix/location list items, and applies the item_handler callback to the items.
----@param item_handler function Callback to apply to the diagnostic items
----@param command string|nil Command to execute after applying the item_handler
----@param opts table|nil Configuration table. Keys:
---- - {client_id}: (number)
---- - If nil, will consider all clients attached to buffer.
---- - {severity}: (DiagnosticSeverity)
---- - Exclusive severity to consider. Overrides {severity_limit}
---- - {severity_limit}: (DiagnosticSeverity)
---- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
---- - {workspace}: (boolean, default false)
---- - Set the list with workspace diagnostics
-local function apply_to_diagnostic_items(item_handler, command, opts)
- opts = opts or {}
- local current_bufnr = api.nvim_get_current_buf()
- local diags = opts.workspace and M.get_all(opts.client_id) or {
- [current_bufnr] = M.get(current_bufnr, opts.client_id)
- }
- local predicate = function(d)
- local severity = to_severity(opts.severity)
- if severity then
- return d.severity == severity
- end
- local severity_limit = to_severity(opts.severity_limit)
- if severity_limit then
- return d.severity <= severity_limit
- end
- return true
- end
- local items = util.diagnostics_to_items(diags, predicate)
- item_handler(items)
- if command then
- vim.cmd(command)
- end
+ local namespace = M.get_namespace(client_id)
+ return vim.diagnostic.show(namespace, bufnr)
end
--- Sets the quickfix list
+---
+---@deprecated Prefer |vim.diagnostic.setqflist()|
+---
---@param opts table|nil Configuration table. Keys:
--- - {open}: (boolean, default true)
--- - Open quickfix list after set
@@ -1390,13 +605,24 @@ end
--- - Set the list with workspace diagnostics
function M.set_qflist(opts)
opts = opts or {}
- opts.workspace = if_nil(opts.workspace, true)
- local open_qflist = if_nil(opts.open, true)
- local command = open_qflist and [[copen]] or nil
- apply_to_diagnostic_items(util.set_qflist, command, opts)
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
+ end
+ if opts.client_id then
+ opts.client_id = nil
+ opts.namespace = M.get_namespace(opts.client_id)
+ end
+ local workspace = vim.F.if_nil(opts.workspace, true)
+ opts.bufnr = not workspace and 0
+ return vim.diagnostic.setqflist(opts)
end
--- Sets the location list
+---
+---@deprecated Prefer |vim.diagnostic.setloclist()|
+---
---@param opts table|nil Configuration table. Keys:
--- - {open}: (boolean, default true)
--- - Open loclist after set
@@ -1410,12 +636,24 @@ end
--- - Set the list with workspace diagnostics
function M.set_loclist(opts)
opts = opts or {}
- local open_loclist = if_nil(opts.open, true)
- local command = open_loclist and [[lopen]] or nil
- apply_to_diagnostic_items(util.set_loclist, command, opts)
+ if opts.severity then
+ opts.severity = severity_lsp_to_vim(opts.severity)
+ elseif opts.severity_limit then
+ opts.severity = {min=severity_lsp_to_vim(opts.severity_limit)}
+ end
+ if opts.client_id then
+ opts.client_id = nil
+ opts.namespace = M.get_namespace(opts.client_id)
+ end
+ local workspace = vim.F.if_nil(opts.workspace, false)
+ opts.bufnr = not workspace and 0
+ return vim.diagnostic.setloclist(opts)
end
--- Disable diagnostics for the given buffer and client
+---
+---@deprecated Prefer |vim.diagnostic.disable()|
+---
---@param bufnr (optional, number): Buffer handle, defaults to current
---@param client_id (optional, number): Disable diagnostics for the given
--- client. The default is to disable diagnostics for all attached
@@ -1430,11 +668,15 @@ function M.disable(bufnr, client_id)
end)
end
- diagnostic_disabled[bufnr][client_id] = true
- M.clear(bufnr, client_id)
+ bufnr = get_bufnr(bufnr)
+ local namespace = M.get_namespace(client_id)
+ return vim.diagnostic.disable(bufnr, namespace)
end
--- Enable diagnostics for the given buffer and client
+---
+---@deprecated Prefer |vim.diagnostic.enable()|
+---
---@param bufnr (optional, number): Buffer handle, defaults to current
---@param client_id (optional, number): Enable diagnostics for the given
--- client. The default is to enable diagnostics for all attached
@@ -1446,14 +688,13 @@ function M.enable(bufnr, client_id)
end)
end
- if not diagnostic_disabled[bufnr][client_id] then
- return
- end
-
- diagnostic_disabled[bufnr][client_id] = nil
-
- M.redraw(bufnr, client_id)
+ bufnr = get_bufnr(bufnr)
+ local namespace = M.get_namespace(client_id)
+ return vim.diagnostic.enable(bufnr, namespace)
end
+
-- }}}
return M
+
+-- vim: fdm=marker
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 8fa6f6d024..918666ab27 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -210,10 +210,16 @@ local function response_to_list(map_result, entity)
else
config = config or {}
if config.loclist then
- util.set_loclist(map_result(result, ctx.bufnr))
+ vim.fn.setloclist(0, {}, ' ', {
+ title = 'Language Server';
+ items = map_result(result, ctx.bufnr);
+ })
api.nvim_command("lopen")
else
- util.set_qflist(map_result(result, ctx.bufnr))
+ vim.fn.setqflist({}, ' ', {
+ title = 'Language Server';
+ items = map_result(result, ctx.bufnr);
+ })
api.nvim_command("copen")
end
end
@@ -428,7 +434,7 @@ M['window/logMessage'] = function(_, result, ctx, _)
log.error(message)
elseif message_type == protocol.MessageType.Warning then
log.warn(message)
- elseif message_type == protocol.MessageType.Info then
+ elseif message_type == protocol.MessageType.Info or message_type == protocol.MessageType.Log then
log.info(message)
else
log.debug(message)
@@ -458,7 +464,7 @@ end
-- Add boilerplate error validation and logging for all of these.
for k, fn in pairs(M) do
M[k] = function(err, result, ctx, config)
- local _ = log.debug() and log.debug('default_handler', ctx.method, {
+ local _ = log.trace() and log.trace('default_handler', ctx.method, {
err = err, result = result, ctx=vim.inspect(ctx), config = config
})
diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua
index 5d2e396cc5..4597f1919a 100644
--- a/runtime/lua/vim/lsp/log.lua
+++ b/runtime/lua/vim/lsp/log.lua
@@ -14,7 +14,8 @@ log.levels = vim.deepcopy(vim.log.levels)
-- Default log level is warn.
local current_log_level = log.levels.WARN
-local log_date_format = "%FT%H:%M:%S%z"
+local log_date_format = "%F %H:%M:%S"
+local format_func = function(arg) return vim.inspect(arg, {newline=''}) end
do
local path_sep = vim.loop.os_uname().version:match("Windows") and "\\" or "/"
@@ -44,7 +45,7 @@ do
end
-- Start message for logging
- logfile:write(string.format("[ START ] %s ] LSP logging initiated\n", os.date(log_date_format)))
+ logfile:write(string.format("[START][%s] LSP logging initiated\n", os.date(log_date_format)))
for level, levelnr in pairs(log.levels) do
-- Also export the log level on the root object.
log[level] = levelnr
@@ -67,14 +68,14 @@ do
if levelnr < current_log_level then return false end
if argc == 0 then return true end
local info = debug.getinfo(2, "Sl")
- local fileinfo = string.format("%s:%s", info.short_src, info.currentline)
- local parts = { table.concat({"[", level, "]", os.date(log_date_format), "]", fileinfo, "]"}, " ") }
+ local header = string.format("[%s][%s] ...%s:%s", level, os.date(log_date_format), string.sub(info.short_src, #info.short_src - 15), info.currentline)
+ local parts = { header }
for i = 1, argc do
local arg = select(i, ...)
if arg == nil then
table.insert(parts, "nil")
else
- table.insert(parts, vim.inspect(arg, {newline=''}))
+ table.insert(parts, format_func(arg))
end
end
logfile:write(table.concat(parts, '\t'), "\n")
@@ -104,6 +105,13 @@ function log.get_level()
return current_log_level
end
+--- Sets formatting function used to format logs
+---@param handle function function to apply to logging arguments, pass vim.inspect for multi-line formatting
+function log.set_format_func(handle)
+ assert(handle == vim.inspect or type(handle) == 'function', "handle must be a function")
+ format_func = handle
+end
+
--- Checks whether the level is sufficient for logging.
---@param level number log level
---@returns (bool) true if would log, false if not
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index eedb708118..7f31bbdf75 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -392,7 +392,7 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params)
---@param payload (table) Converted into a JSON string, see |json_encode()|
---@returns true if the payload could be scheduled, false if the main event-loop is in the process of closing.
local function encode_and_send(payload)
- local _ = log.debug() and log.debug("rpc.send.payload", payload)
+ local _ = log.debug() and log.debug("rpc.send", payload)
if handle == nil or handle:is_closing() then return false end
-- TODO(ashkan) remove this once we have a Lua json_encode
schedule(function()
@@ -493,7 +493,7 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params)
-- on_error(client_errors.INVALID_SERVER_JSON, err)
return
end
- local _ = log.debug() and log.debug("decoded", decoded)
+ local _ = log.debug() and log.debug("rpc.receive", decoded)
if type(decoded.method) == 'string' and decoded.id then
-- Server Request
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index a4c8b69f6c..9a3ce185a0 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1,4 +1,5 @@
local protocol = require 'vim.lsp.protocol'
+local snippet = require 'vim.lsp._snippet'
local vim = vim
local validate = vim.validate
local api = vim.api
@@ -30,16 +31,6 @@ local default_border = {
{" ", "NormalFloat"},
}
-
-local DiagnosticSeverity = protocol.DiagnosticSeverity
-local loclist_type_map = {
- [DiagnosticSeverity.Error] = 'E',
- [DiagnosticSeverity.Warning] = 'W',
- [DiagnosticSeverity.Information] = 'I',
- [DiagnosticSeverity.Hint] = 'I',
-}
-
-
---@private
--- Check the border given by opts or the default border for the additional
--- size it adds to a float.
@@ -523,74 +514,18 @@ function M.apply_text_document_edit(text_document_edit, index)
M.apply_text_edits(text_document_edit.edits, bufnr)
end
----@private
---- Recursively parses snippets in a completion entry.
----
----@param input (string) Snippet text to parse for snippets
----@param inner (bool) Whether this function is being called recursively
----@returns 2-tuple of strings: The first is the parsed result, the second is the
----unparsed rest of the input
-local function parse_snippet_rec(input, inner)
- local res = ""
-
- local close, closeend = nil, nil
- if inner then
- close, closeend = input:find("}", 1, true)
- while close ~= nil and input:sub(close-1,close-1) == "\\" do
- close, closeend = input:find("}", closeend+1, true)
- end
- end
-
- local didx = input:find('$', 1, true)
- if didx == nil and close == nil then
- return input, ""
- elseif close ~=nil and (didx == nil or close < didx) then
- -- No inner placeholders
- return input:sub(0, close-1), input:sub(closeend+1)
- end
-
- res = res .. input:sub(0, didx-1)
- input = input:sub(didx+1)
-
- local tabstop, tabstopend = input:find('^%d+')
- local placeholder, placeholderend = input:find('^{%d+:')
- local choice, choiceend = input:find('^{%d+|')
-
- if tabstop then
- input = input:sub(tabstopend+1)
- elseif choice then
- input = input:sub(choiceend+1)
- close, closeend = input:find("|}", 1, true)
-
- res = res .. input:sub(0, close-1)
- input = input:sub(closeend+1)
- elseif placeholder then
- -- TODO: add support for variables
- input = input:sub(placeholderend+1)
-
- -- placeholders and variables are recursive
- while input ~= "" do
- local r, tail = parse_snippet_rec(input, true)
- r = r:gsub("\\}", "}")
-
- res = res .. r
- input = tail
- end
- else
- res = res .. "$"
- end
-
- return res, input
-end
-
--- Parses snippets in a completion entry.
---
----@param input (string) unparsed snippet
----@returns (string) parsed snippet
+---@param input string unparsed snippet
+---@returns string parsed snippet
function M.parse_snippet(input)
- local res, _ = parse_snippet_rec(input, false)
-
- return res
+ local ok, parsed = pcall(function()
+ return tostring(snippet.parse(input))
+ end)
+ if not ok then
+ return input
+ end
+ return parsed
end
---@private
@@ -1598,6 +1533,9 @@ end
--- Returns the items with the byte position calculated correctly and in sorted
--- order, for display in quickfix and location lists.
---
+--- The result can be passed to the {list} argument of |setqflist()| or
+--- |setloclist()|.
+---
---@param locations (table) list of `Location`s or `LocationLink`s
---@returns (table) list of items
function M.locations_to_items(locations)
@@ -1656,6 +1594,8 @@ end
--- Can be obtained with e.g. |vim.lsp.util.locations_to_items()|.
--- Defaults to current window.
---
+---@deprecated Use |setloclist()|
+---
---@param items (table) list of items
function M.set_loclist(items, win_id)
vim.fn.setloclist(win_id or 0, {}, ' ', {
@@ -1667,6 +1607,8 @@ end
--- Fills quickfix list with given list of items.
--- Can be obtained with e.g. |vim.lsp.util.locations_to_items()|.
---
+---@deprecated Use |setqflist()|
+---
---@param items (table) list of items
function M.set_qflist(items)
vim.fn.setqflist({}, ' ', {
@@ -1924,40 +1866,6 @@ function M.lookup_section(settings, section)
return settings
end
-
---- Convert diagnostics grouped by bufnr to a list of items for use in the
---- quickfix or location list.
----
----@param diagnostics_by_bufnr table bufnr -> Diagnostic[]
----@param predicate an optional function to filter the diagnostics.
---- If present, only diagnostic items matching will be included.
----@return table (A list of items)
-function M.diagnostics_to_items(diagnostics_by_bufnr, predicate)
- local items = {}
- for bufnr, diagnostics in pairs(diagnostics_by_bufnr or {}) do
- for _, d in pairs(diagnostics) do
- if not predicate or predicate(d) then
- table.insert(items, {
- bufnr = bufnr,
- lnum = d.range.start.line + 1,
- col = d.range.start.character + 1,
- text = d.message,
- type = loclist_type_map[d.severity or DiagnosticSeverity.Error] or 'E'
- })
- end
- end
- end
- table.sort(items, function(a, b)
- if a.bufnr == b.bufnr then
- return a.lnum < b.lnum
- else
- return a.bufnr < b.bufnr
- end
- end)
- return items
-end
-
-
M._get_line_byte_from_position = get_line_byte_from_position
M._warn_once = warn_once
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 032b2b2cb5..18c1e21049 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -267,18 +267,23 @@ function vim.tbl_deep_extend(behavior, ...)
end
--- Deep compare values for equality
+---
+--- Tables are compared recursively unless they both provide the `eq` methamethod.
+--- All other types are compared using the equality `==` operator.
+---@param a first value
+---@param b second value
+---@returns `true` if values are equals, else `false`.
function vim.deep_equal(a, b)
if a == b then return true end
if type(a) ~= type(b) then return false end
if type(a) == 'table' then
- -- TODO improve this algorithm's performance.
for k, v in pairs(a) do
if not vim.deep_equal(v, b[k]) then
return false
end
end
- for k, v in pairs(b) do
- if not vim.deep_equal(v, a[k]) then
+ for k, _ in pairs(b) do
+ if a[k] == nil then
return false
end
end
diff --git a/runtime/pack/dist/opt/matchit/doc/matchit.txt b/runtime/pack/dist/opt/matchit/doc/matchit.txt
index 3cd2c8e2a7..58a47780ef 100644
--- a/runtime/pack/dist/opt/matchit/doc/matchit.txt
+++ b/runtime/pack/dist/opt/matchit/doc/matchit.txt
@@ -4,7 +4,7 @@ For instructions on installing this file, type
`:help matchit-install`
inside Vim.
-For Vim version 8.1. Last change: 2020 Mar 01
+For Vim version 8.1. Last change: 2021 May 17
VIM REFERENCE MANUAL by Benji Fisher et al
@@ -322,7 +322,7 @@ should work (and have the same effect as "foobar:barfoo:endfoobar"), although
this has not been thoroughly tested.
You can use |zero-width| patterns such as |\@<=| and |\zs|. (The latter has
-not been thouroughly tested in matchit.vim.) For example, if the keyword "if"
+not been thoroughly tested in matchit.vim.) For example, if the keyword "if"
must occur at the start of the line, with optional white space, you might use
the pattern "\(^\s*\)\@<=if" so that the cursor will end on the "i" instead of
at the start of the line. For another example, if HTML had only one tag then
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index 2914e2bc4d..94b97c9f0c 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -2,7 +2,7 @@
"
" Author: Bram Moolenaar
" Copyright: Vim license applies, see ":help license"
-" Last Change: 2021 May 18
+" Last Change: 2021 Aug 23
"
" WORK IN PROGRESS - Only the basics work
" Note: On MS-Windows you need a recent version of gdb. The one included with
@@ -127,6 +127,10 @@ func s:StartDebug_internal(dict)
let s:pid = 0
let s:asmwin = 0
+ if exists('#User#TermdebugStartPre')
+ doauto <nomodeline> User TermdebugStartPre
+ endif
+
" Uncomment this line to write logging in "debuglog".
" call ch_logfile('debuglog', 'w')
@@ -173,6 +177,10 @@ func s:StartDebug_internal(dict)
call win_gotoid(curwinid)
endif
endif
+
+ if exists('#User#TermdebugStartPost')
+ doauto <nomodeline> User TermdebugStartPost
+ endif
endfunc
" Use when debugger didn't start or ended.
@@ -335,6 +343,9 @@ func s:StartDebug_term(dict)
" "Type <return> to continue" prompt.
call s:SendCommand('set pagination off')
+ " Set the filetype, this can be used to add mappings.
+ set filetype=termdebug
+
call s:StartDebugCommon(a:dict)
endfunc
@@ -623,6 +634,10 @@ func s:GetAsmAddr(msg)
endfunc
function s:EndTermDebug(job_id, exit_code, event)
+ if exists('#User#TermdebugStopPre')
+ doauto <nomodeline> User TermdebugStopPre
+ endif
+
unlet s:gdbwin
call s:EndDebugCommon()
@@ -657,10 +672,18 @@ func s:EndDebugCommon()
let &columns = s:save_columns
endif
+ if exists('#User#TermdebugStopPost')
+ doauto <nomodeline> User TermdebugStopPost
+ endif
+
au! TermDebug
endfunc
func s:EndPromptDebug(job_id, exit_code, event)
+ if exists('#User#TermdebugStopPre')
+ doauto <nomodeline> User TermdebugStopPre
+ endif
+
let curwinid = win_getid(winnr())
call win_gotoid(s:gdbwin)
close
diff --git a/runtime/plugin/diagnostic.vim b/runtime/plugin/diagnostic.vim
new file mode 100644
index 0000000000..2183623ac8
--- /dev/null
+++ b/runtime/plugin/diagnostic.vim
@@ -0,0 +1,26 @@
+" :help vim.diagnostic
+
+hi default DiagnosticError ctermfg=1 guifg=Red
+hi default DiagnosticWarn ctermfg=3 guifg=Orange
+hi default DiagnosticInfo ctermfg=4 guifg=LightBlue
+hi default DiagnosticHint ctermfg=7 guifg=LightGrey
+
+hi default DiagnosticUnderlineError cterm=underline gui=underline guisp=Red
+hi default DiagnosticUnderlineWarn cterm=underline gui=underline guisp=Orange
+hi default DiagnosticUnderlineInfo cterm=underline gui=underline guisp=LightBlue
+hi default DiagnosticUnderlineHint cterm=underline gui=underline guisp=LightGrey
+
+hi default link DiagnosticVirtualTextError DiagnosticError
+hi default link DiagnosticVirtualTextWarn DiagnosticWarn
+hi default link DiagnosticVirtualTextInfo DiagnosticInfo
+hi default link DiagnosticVirtualTextHint DiagnosticHint
+
+hi default link DiagnosticFloatingError DiagnosticError
+hi default link DiagnosticFloatingWarn DiagnosticWarn
+hi default link DiagnosticFloatingInfo DiagnosticInfo
+hi default link DiagnosticFloatingHint DiagnosticHint
+
+hi default link DiagnosticSignError DiagnosticError
+hi default link DiagnosticSignWarn DiagnosticWarn
+hi default link DiagnosticSignInfo DiagnosticInfo
+hi default link DiagnosticSignHint DiagnosticHint
diff --git a/runtime/plugin/netrwPlugin.vim b/runtime/plugin/netrwPlugin.vim
index 217a7795c9..d309f81484 100644
--- a/runtime/plugin/netrwPlugin.vim
+++ b/runtime/plugin/netrwPlugin.vim
@@ -1,9 +1,9 @@
" netrwPlugin.vim: Handles file transfer and remote directory listing across a network
" PLUGIN SECTION
-" Date: Feb 08, 2016 - Jan 07, 2020
+" Date: Feb 09, 2021
" Maintainer: Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
-" Copyright: Copyright (C) 1999-2013 Charles E. Campbell {{{1
+" Copyright: Copyright (C) 1999-2021 Charles E. Campbell {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
@@ -20,7 +20,7 @@
if &cp || exists("g:loaded_netrwPlugin")
finish
endif
-let g:loaded_netrwPlugin = "v170"
+let g:loaded_netrwPlugin = "v171"
let s:keepcpo = &cpo
set cpo&vim
"DechoRemOn
@@ -83,11 +83,11 @@ if !exists("g:netrw_nogx")
endif
nno <silent> <Plug>NetrwBrowseX :call netrw#BrowseX(netrw#GX(),netrw#CheckIfRemote(netrw#GX()))<cr>
endif
- if maparg('gx','v') == ""
+ if maparg('gx','x') == ""
if !hasmapto('<Plug>NetrwBrowseXVis')
- vmap <unique> gx <Plug>NetrwBrowseXVis
+ xmap <unique> gx <Plug>NetrwBrowseXVis
endif
- vno <silent> <Plug>NetrwBrowseXVis :<c-u>call netrw#BrowseXVis()<cr>
+ xno <silent> <Plug>NetrwBrowseXVis :<c-u>call netrw#BrowseXVis()<cr>
endif
endif
if exists("g:netrw_usetab") && g:netrw_usetab
@@ -129,7 +129,9 @@ fun! s:LocalBrowse(dirname)
elseif isdirectory(a:dirname)
" call Decho("(LocalBrowse) dirname<".a:dirname."> ft=".&ft." (isdirectory, not amiga)")
" call Dredir("LocalBrowse ft last set: ","verbose set ft")
- sil! call netrw#LocalBrowseCheck(a:dirname)
+ " Jul 13, 2021: for whatever reason, preceding the following call with
+ " a sil! causes an unbalanced if-endif vim error
+ call netrw#LocalBrowseCheck(a:dirname)
if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt
exe w:netrw_bannercnt
endif
@@ -151,10 +153,22 @@ endfun
" has already been called.
fun! s:VimEnter(dirname)
" call Dfunc("s:VimEnter(dirname<".a:dirname.">) expand(%)<".expand("%").">")
+ if has('nvim') || v:version < 802
+ " Johann Höchtl: reported that the call range... line causes an E488: Trailing characters
+ " error with neovim. I suspect its because neovim hasn't updated with recent
+ " vim patches. As is, this code will have problems with popup terminals
+ " instantiated before the VimEnter event runs.
+ " Ingo Karkat : E488 also in Vim 8.1.1602
let curwin = winnr()
let s:vimentered = 1
windo call s:LocalBrowse(expand("%:p"))
exe curwin."wincmd w"
+ else
+ " the following complicated expression comes courtesy of lacygoill; largely does the same thing as the windo and
+ " wincmd which are commented out, but avoids some side effects. Allows popup terminal before VimEnter.
+ let s:vimentered = 1
+ call range(1, winnr('$'))->map({_, v -> win_execute(win_getid(v), 'call expand("%:p")->s:LocalBrowse()')})
+ endif
" call Dret("s:VimEnter")
endfun
diff --git a/runtime/plugin/tohtml.vim b/runtime/plugin/tohtml.vim
index 2c85b57529..08df19b4f9 100644
--- a/runtime/plugin/tohtml.vim
+++ b/runtime/plugin/tohtml.vim
@@ -62,7 +62,7 @@ let g:loaded_2html_plugin = 'vim8.1_v2'
" 7.3_v14 (Vim 7.3.1246): Allow suppressing line number anchors using
" g:html_line_ids=0. Allow customizing
" important IDs (like line IDs and fold IDs) using
-" g:html_id_expr evalutated when the buffer conversion
+" g:html_id_expr evaluated when the buffer conversion
" is started.
" 7.3_v13 (Vim 7.3.1088): Keep foldmethod at manual in the generated file and
" insert modeline to set it to manual.
diff --git a/runtime/syntax/2html.vim b/runtime/syntax/2html.vim
index 4afdff2899..8adbd76950 100644
--- a/runtime/syntax/2html.vim
+++ b/runtime/syntax/2html.vim
@@ -499,7 +499,7 @@ if s:settings.prevent_copy =~# 'n'
endif
elseif s:settings.line_ids
" if lines are not being numbered the only reason this function gets called
- " is to put the line IDs on each line; "text" will be emtpy but lnr will
+ " is to put the line IDs on each line; "text" will be empty but lnr will
" always be non-zero, however we don't want to use the <input> because that
" won't work as nice for empty text
function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr)
@@ -1034,7 +1034,7 @@ if !s:settings.no_progress
" ProgressBar Indicator
let s:progressbar={}
- " Progessbar specific functions
+ " Progressbar specific functions
func! s:SetProgbarColor()
if hlID("TOhtmlProgress") != 0
diff --git a/runtime/syntax/abel.vim b/runtime/syntax/abel.vim
index 67d7e4f786..dbed541ba8 100644
--- a/runtime/syntax/abel.vim
+++ b/runtime/syntax/abel.vim
@@ -59,7 +59,7 @@ syn region abelSpecifier start='istype' end=';' contains=abelTypeIdChar,abelType
syn match abelTypeIdChar "[,']" contained
syn match abelTypeIdEnd ";" contained
-" string contstants and special characters within them
+" string constants and special characters within them
syn match abelSpecial contained "\\['\\]"
syn region abelString start=+'+ skip=+\\"+ end=+'+ contains=abelSpecial
diff --git a/runtime/syntax/ada.vim b/runtime/syntax/ada.vim
index c9d2b06e18..415c9522fb 100644
--- a/runtime/syntax/ada.vim
+++ b/runtime/syntax/ada.vim
@@ -159,7 +159,7 @@ endif
" Section: end {{{1
" Unless special ("end loop", "end if", etc.), "end" marks the end of a
-" begin, package, task etc. Assiging it to adaEnd.
+" begin, package, task etc. Assigning it to adaEnd.
syntax match adaEnd /\<end\>/
syntax keyword adaPreproc pragma
diff --git a/runtime/syntax/ahdl.vim b/runtime/syntax/ahdl.vim
index 664bd3837d..3a40dcfaea 100644
--- a/runtime/syntax/ahdl.vim
+++ b/runtime/syntax/ahdl.vim
@@ -38,7 +38,7 @@ syn keyword ahdlMegafunction lpm_rom lpm_dff lpm_tff clklock pll ntsc
syn keyword ahdlTodo contained TODO
-" String contstants
+" String constants
syn region ahdlString start=+"+ skip=+\\"+ end=+"+
" valid integer number formats (decimal, binary, octal, hex)
diff --git a/runtime/syntax/aptconf.vim b/runtime/syntax/aptconf.vim
index 8cb14321e2..d51e7bdfa9 100644
--- a/runtime/syntax/aptconf.vim
+++ b/runtime/syntax/aptconf.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: APT config file
" Maintainer: Yann Amar <quidame@poivron.org>
-" Last Change: 2015 Dec 22
+" Last Change: 2021 Jul 12
" quit when a syntax file was already loaded
if !exists("main_syntax")
@@ -396,10 +396,13 @@ syn cluster aptconfSynaptic_ contains=aptconfSynaptic,
" }}}
" Unattended Upgrade: {{{
syn keyword aptconfUnattendedUpgrade contained
- \ AutoFixInterruptedDpkg Automatic-Reboot Automatic-Reboot-Time
- \ Automatic-Reboot-WithUsers InstallOnShutdown Mail MailOnlyOnError
- \ MinimalSteps Origins-Pattern Package-Blacklist
- \ Remove-Unused-Dependencies
+ \ Allow-APT-Mark-Fallback Allow-downgrade AutoFixInterruptedDpkg
+ \ Automatic-Reboot Automatic-Reboot-Time Automatic-Reboot-WithUsers
+ \ Debug InstallOnShutdown Mail MailOnlyOnError MailReport MinimalSteps
+ \ OnlyOnACPower Origins-Pattern Package-Blacklist
+ \ Remove-New-Unused-Dependencies Remove-Unused-Dependencies
+ \ Remove-Unused-Kernel-Packages Skip-Updates-On-Metered-Connections
+ \ SyslogEnable SyslogFacility Verbose
syn cluster aptconfUnattendedUpgrade_ contains=aptconfUnattendedUpgrade
" }}}
diff --git a/runtime/syntax/aspvbs.vim b/runtime/syntax/aspvbs.vim
index f0861d8b5a..08db416ef9 100644
--- a/runtime/syntax/aspvbs.vim
+++ b/runtime/syntax/aspvbs.vim
@@ -108,7 +108,7 @@ syn match AspVBSMethods contained "Response\.\w*"
" Colorize boolean constants:
syn keyword AspVBSMethods contained true false
-" AspVBScript Number Contstants
+" AspVBScript Number Constants
" Integer number, or floating point number without a dot.
syn match AspVBSNumber contained "\<\d\+\>"
" Floating point number, with dot
@@ -116,7 +116,7 @@ syn match AspVBSNumber contained "\<\d\+\.\d*\>"
" Floating point number, starting with a dot
syn match AspVBSNumber contained "\.\d\+\>"
-" String and Character Contstants
+" String and Character Constants
" removed (skip=+\\\\\|\\"+) because VB doesn't have backslash escaping in
" strings (or does it?)
syn region AspVBSString contained start=+"+ end=+"+ keepend
@@ -143,7 +143,7 @@ syn cluster AspVBScriptTop contains=AspVBSStatement,AspVBSFunction,AspVBSMethods
syn region AspVBSFold start="^\s*\(class\)\s\+.*$" end="^\s*end\s\+\(class\)\>.*$" fold contained transparent keepend
syn region AspVBSFold start="^\s*\(private\|public\)\=\(\s\+default\)\=\s\+\(sub\|function\)\s\+.*$" end="^\s*end\s\+\(function\|sub\)\>.*$" fold contained transparent keepend
-" Define AspVBScript delimeters
+" Define AspVBScript delimiters
" <%= func("string_with_%>_in_it") %> This is illegal in ASP syntax.
syn region AspVBScriptInsideHtmlTags keepend matchgroup=Delimiter start=+<%=\=+ end=+%>+ contains=@AspVBScriptTop, AspVBSFold
syn region AspVBScriptInsideHtmlTags keepend matchgroup=Delimiter start=+<script\s\+language="\=vbscript"\=[^>]*\s\+runatserver[^>]*>+ end=+</script>+ contains=@AspVBScriptTop
diff --git a/runtime/syntax/cfg.vim b/runtime/syntax/cfg.vim
index a50297d418..f347b1379f 100644
--- a/runtime/syntax/cfg.vim
+++ b/runtime/syntax/cfg.vim
@@ -32,7 +32,7 @@ syn match CfgComment "#.*"
syn match CfgComment ";.*"
syn match CfgComment "\/\/.*"
-" Define the default hightlighting.
+" Define the default highlighting.
" Only when an item doesn't have highlighting yet
hi def link CfgOnOff Label
hi def link CfgComment Comment
diff --git a/runtime/syntax/chicken.vim b/runtime/syntax/chicken.vim
index c3f949f823..806d08fbb7 100644
--- a/runtime/syntax/chicken.vim
+++ b/runtime/syntax/chicken.vim
@@ -1,8 +1,9 @@
" Vim syntax file
" Language: Scheme (CHICKEN)
-" Last Change: 2018-02-05
+" Last Change: 2021 Jul 30
" Author: Evan Hanson <evhan@foldling.org>
" Maintainer: Evan Hanson <evhan@foldling.org>
+" Repository: https://git.foldling.org/vim-scheme.git
" URL: https://foldling.org/vim/syntax/chicken.vim
" Notes: This is supplemental syntax, to be loaded after the core Scheme
" syntax file (syntax/scheme.vim). Enable it by setting b:is_chicken=1
@@ -36,9 +37,23 @@ if len(s:c)
syn region c matchgroup=schemeComment start=/#>/ end=/<#/ contains=@c
endif
+# SRFI 26
+syn match schemeSyntax /\(([ \t\n]*\)\@<=\(cut\|cute\)\>/
+
+syn keyword schemeSyntax and-let*
syn keyword schemeSyntax define-record
+syn keyword schemeSyntax set!-values
+syn keyword schemeSyntax fluid-let
+syn keyword schemeSyntax let-optionals
+syn keyword schemeSyntax let-optionals*
+syn keyword schemeSyntax letrec-values
+syn keyword schemeSyntax nth-value
+syn keyword schemeSyntax receive
syn keyword schemeLibrarySyntax declare
+syn keyword schemeLibrarySyntax define-interface
+syn keyword schemeLibrarySyntax functor
+syn keyword schemeLibrarySyntax include-relative
syn keyword schemeLibrarySyntax module
syn keyword schemeLibrarySyntax reexport
syn keyword schemeLibrarySyntax require-library
@@ -52,10 +67,12 @@ syn keyword schemeTypeSyntax define-specialization
syn keyword schemeTypeSyntax define-type
syn keyword schemeTypeSyntax the
-syn keyword schemeExtraSyntax and-let*
syn keyword schemeExtraSyntax match
syn keyword schemeExtraSyntax match-lambda
syn keyword schemeExtraSyntax match-lambda*
+syn keyword schemeExtraSyntax match-let
+syn keyword schemeExtraSyntax match-let*
+syn keyword schemeExtraSyntax match-letrec
syn keyword schemeSpecialSyntax define-compiler-syntax
syn keyword schemeSpecialSyntax define-constant
diff --git a/runtime/syntax/cpp.vim b/runtime/syntax/cpp.vim
index 3ad79d5545..5437580a0a 100644
--- a/runtime/syntax/cpp.vim
+++ b/runtime/syntax/cpp.vim
@@ -2,7 +2,7 @@
" Language: C++
" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
" Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
-" Last Change: 2021 May 04
+" Last Change: 2021 Aug 23
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@@ -60,7 +60,7 @@ if !exists("cpp_no_cpp14")
syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
- syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell
+ syn region cppString start=+\(L\|u\|u8\|U\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell
endif
" C++ 17 extensions
@@ -69,6 +69,20 @@ if !exists("cpp_no_cpp17")
syn match cppCast "\<reinterpret_pointer_cast\s*$"
syn match cppFloat display contained "\<0x\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
syn match cppFloat display contained "\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+
+ " TODO: push this up to c.vim if/when supported in C23
+ syn match cppCharacter "u8'[^\\]'"
+ syn match cppCharacter "u8'[^']*'" contains=cSpecial
+ if exists("c_gnu")
+ syn match cppSpecialError "u8'\\[^'\"?\\abefnrtv]'"
+ syn match cppSpecialCharacter "u8'\\['\"?\\abefnrtv]'"
+ else
+ syn match cppSpecialError "u8'\\[^'\"?\\abfnrtv]'"
+ syn match cppSpecialCharacter "u8'\\['\"?\\abfnrtv]'"
+ endif
+ syn match cppSpecialCharacter display "u8'\\\o\{1,3}'"
+ syn match cppSpecialCharacter display "u8'\\x\x\+'"
+
endif
" C++ 20 extensions
@@ -99,6 +113,9 @@ hi def link cppType Type
hi def link cppStorageClass StorageClass
hi def link cppStructure Structure
hi def link cppBoolean Boolean
+hi def link cppCharacter cCharacter
+hi def link cppSpecialCharacter cSpecialCharacter
+hi def link cppSpecialError cSpecialError
hi def link cppConstant Constant
hi def link cppRawStringDelimiter Delimiter
hi def link cppRawString String
diff --git a/runtime/syntax/csc.vim b/runtime/syntax/csc.vim
index 6e5d8b9f37..b1bc4d6a7b 100644
--- a/runtime/syntax/csc.vim
+++ b/runtime/syntax/csc.vim
@@ -141,7 +141,7 @@ sy keyword cscBPMacro contained EndLoop AllMembers SelectedMembers If Else EndIf
sy match cscBPMacro contained "!"
sy match cscBPW "!\s*\a*" contains=cscBPmacro
-" when wanted, highlighting lhs members or erros in asignments (may lag the editing)
+" when wanted, highlighting lhs members or errors in assignments (may lag the editing)
if exists("csc_asignment")
sy match cscEqError '\("[^"]*"\s*\|[^][\t !%()*+,--/:;<=>{}~]\+\s*\|->\s*\)*=\([^=]\@=\|$\)'
sy region cscFormula transparent matchgroup=cscVarName start='\("[^"]*"\|[^][\t !%()*+,--/:;<=>{}~]\+\)\s*=\([^=]\@=\|\n\)' skip='"[^"]*"' end=';' contains=ALLBUT,cscFormula,cscFormulaIn,cscBPMacro,cscCondition
diff --git a/runtime/syntax/cupl.vim b/runtime/syntax/cupl.vim
index 5b93b0db93..54495f8ba5 100644
--- a/runtime/syntax/cupl.vim
+++ b/runtime/syntax/cupl.vim
@@ -23,7 +23,7 @@ syn keyword cuplTodo contained TODO XXX FIXME
" cuplHeaderContents uses default highlighting except for numbers
syn match cuplHeaderContents ".\+;"me=e-1 contains=cuplNumber contained
-" String contstants
+" String constants
syn region cuplString start=+'+ end=+'+
syn region cuplString start=+"+ end=+"+
diff --git a/runtime/syntax/debchangelog.vim b/runtime/syntax/debchangelog.vim
index 220f184bc0..93b03ae06d 100644
--- a/runtime/syntax/debchangelog.vim
+++ b/runtime/syntax/debchangelog.vim
@@ -3,7 +3,7 @@
" Maintainer: Debian Vim Maintainers
" Former Maintainers: Gerfried Fuchs <alfie@ist.org>
" Wichert Akkerman <wakkerma@debian.org>
-" Last Change: 2020 Nov 28
+" Last Change: 2021 Aug 03
" URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/syntax/debchangelog.vim
" Standard syntax initialization
@@ -24,7 +24,7 @@ let s:supported = [
\ 'jessie', 'stretch', 'buster', 'bullseye', 'bookworm',
\ 'trixie', 'sid', 'rc-buggy',
\
- \ 'trusty', 'xenial', 'bionic', 'focal', 'groovy', 'hirsute', 'devel'
+ \ 'trusty', 'xenial', 'bionic', 'focal', 'hirsute', 'impish', 'devel'
\ ]
let s:unsupported = [
\ 'frozen', 'buzz', 'rex', 'bo', 'hamm', 'slink', 'potato',
@@ -34,7 +34,7 @@ let s:unsupported = [
\ 'gutsy', 'hardy', 'intrepid', 'jaunty', 'karmic', 'lucid',
\ 'maverick', 'natty', 'oneiric', 'precise', 'quantal', 'raring', 'saucy',
\ 'utopic', 'vivid', 'wily', 'yakkety', 'zesty', 'artful', 'cosmic',
- \ 'disco', 'eoan'
+ \ 'disco', 'eoan', 'groovy'
\ ]
let &cpo=s:cpo
diff --git a/runtime/syntax/debsources.vim b/runtime/syntax/debsources.vim
index 2352466a3b..8aa96fcb58 100644
--- a/runtime/syntax/debsources.vim
+++ b/runtime/syntax/debsources.vim
@@ -2,7 +2,7 @@
" Language: Debian sources.list
" Maintainer: Debian Vim Maintainers
" Former Maintainer: Matthijs Mohlmann <matthijs@cacholong.nl>
-" Last Change: 2020 Nov 28
+" Last Change: 2021 Aug 03
" URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/syntax/debsources.vim
" Standard syntax initialization
@@ -26,7 +26,7 @@ let s:supported = [
\ 'jessie', 'stretch', 'buster', 'bullseye', 'bookworm',
\ 'trixie', 'sid', 'rc-buggy',
\
- \ 'trusty', 'xenial', 'bionic', 'focal', 'groovy', 'hirsute', 'devel'
+ \ 'trusty', 'xenial', 'bionic', 'focal', 'hirsute', 'impish', 'devel'
\ ]
let s:unsupported = [
\ 'buzz', 'rex', 'bo', 'hamm', 'slink', 'potato',
@@ -36,7 +36,7 @@ let s:unsupported = [
\ 'gutsy', 'hardy', 'intrepid', 'jaunty', 'karmic', 'lucid',
\ 'maverick', 'natty', 'oneiric', 'precise', 'quantal', 'raring', 'saucy',
\ 'utopic', 'vivid', 'wily', 'yakkety', 'zesty', 'artful', 'cosmic',
- \ 'disco', 'eoan'
+ \ 'disco', 'eoan', 'groovy'
\ ]
let &cpo=s:cpo
diff --git a/runtime/syntax/dosbatch.vim b/runtime/syntax/dosbatch.vim
index 249e6f7c46..f003a65909 100644
--- a/runtime/syntax/dosbatch.vim
+++ b/runtime/syntax/dosbatch.vim
@@ -1,5 +1,5 @@
" Vim syntax file
-" Language: MSDOS batch file (with NT command extensions)
+" Language: MS-DOS batch file (with NT command extensions)
" Maintainer: Mike Williams <mrw@eandem.co.uk>
" Filenames: *.bat
" Last Change: 6th September 2009
diff --git a/runtime/syntax/doxygen.vim b/runtime/syntax/doxygen.vim
index cfd5452ee4..167b17cd0f 100644
--- a/runtime/syntax/doxygen.vim
+++ b/runtime/syntax/doxygen.vim
@@ -1,4 +1,4 @@
-" DoxyGen syntax hilighting extension for c/c++/idl/java
+" DoxyGen syntax highlighting extension for c/c++/idl/java
" Language: doxygen on top of c, cpp, idl, java, php
" Maintainer: Michael Geddes <vimmer@frog.wheelycreek.net>
" Author: Michael Geddes
@@ -54,7 +54,7 @@ let s:cpo_save = &cpo
try
set cpo&vim
- " Start of Doxygen syntax hilighting:
+ " Start of Doxygen syntax highlighting:
"
" C/C++ Style line comments
@@ -256,7 +256,7 @@ endif
syn match doxygenLinkRest +[^*@\\]\|\*/\@!\|[@\\]\(endlink\>\)\@!+ contained skipnl nextgroup=doxygenLinkRest,doxygenContinueLinkComment
syn match doxygenContinueLinkComment contained +^\s*\*\=[^/]+me=e-1 nextgroup=doxygenLinkRest
syn match doxygenLinkError "\*/" contained
- " #Link hilighting.
+ " #Link highlighting.
syn match doxygenHashLink /\(\h\w*\)\?#\(\.\w\@=\|\w\+\|::\|()\)\+/ contained contains=doxygenHashSpecial
syn match doxygenHashSpecial /#/ contained
syn match doxygenHyperLink /\(\s\|^\s*\*\?\)\@<=\(http\|https\|ftp\):\/\/[-0-9a-zA-Z_?&=+#%/.!':;@~]\+/ contained
@@ -306,7 +306,7 @@ endif
syn region doxygenFormula contained matchgroup=doxygenFormulaEnds start=+f\[+ end=+[@\\]f]+ contains=doxygenFormulaSpecial,doxygenFormulaOperator,doxygenAtom
syn region doxygenAtom contained transparent matchgroup=doxygenFormulaOperator start=+{+ end=+}+ contains=doxygenAtom,doxygenFormulaSpecial,doxygenFormulaOperator
- " Add TODO hilighting.
+ " Add TODO highlighting.
syn keyword doxygenTODO contained TODO README XXX FIXME
" Supported HTML subset. Not perfect, but okay.
diff --git a/runtime/syntax/focexec.vim b/runtime/syntax/focexec.vim
index a75aed47cb..187fd50dbf 100644
--- a/runtime/syntax/focexec.vim
+++ b/runtime/syntax/focexec.vim
@@ -8,7 +8,7 @@
" this is a very simple syntax file - I will be improving it
" one thing is how to do computes
" I don't like that &vars and FUSE() functions highlight to the same color
-" I think some of these things should get different hilights -
+" I think some of these things should get different highlights -
" should MODIFY commands look different than TABLE?
" quit when a syntax file was already loaded
diff --git a/runtime/syntax/forth.vim b/runtime/syntax/forth.vim
index 9b39a7fd7d..721bceb367 100644
--- a/runtime/syntax/forth.vim
+++ b/runtime/syntax/forth.vim
@@ -181,7 +181,7 @@ syn keyword forthMath DECIMAL HEX BASE
syn match forthInteger '\<-\=[0-9]\+.\=\>'
syn match forthInteger '\<&-\=[0-9]\+.\=\>'
" recognize hex and binary numbers, the '$' and '%' notation is for gforth
-syn match forthInteger '\<\$\x*\x\+\>' " *1* --- dont't mess
+syn match forthInteger '\<\$\x*\x\+\>' " *1* --- don't mess
syn match forthInteger '\<\x*\d\x*\>' " *2* --- this order!
syn match forthInteger '\<%[0-1]*[0-1]\+\>'
syn match forthFloat '\<-\=\d*[.]\=\d\+[DdEe]\d\+\>'
diff --git a/runtime/syntax/gemtext.vim b/runtime/syntax/gemtext.vim
new file mode 100644
index 0000000000..8c2bd29928
--- /dev/null
+++ b/runtime/syntax/gemtext.vim
@@ -0,0 +1,24 @@
+" Vim syntax file
+" Language: Gemtext markup language
+" Maintainer: Suneel Freimuth <suneelfreimuth1@gmail.com>
+" Latest Revision: 2020-11-21
+" Filenames: *.gmi
+
+if exists('b:current_syntax')
+ finish
+endif
+
+syntax match Heading /^#\{1,3}.\+$/
+syntax match List /^\* /
+syntax match LinkURL /^=>\s*\S\+/
+syntax match Quote /^>.\+/
+syntax region Preformatted start=/^```/ end=/```/
+
+highlight default link Heading Special
+highlight default link List Statement
+highlight default link LinkURL Underlined
+highlight default link Quote Constant
+highlight default link Preformatted Identifier
+
+let b:current_syntax = 'gemtext'
+
diff --git a/runtime/syntax/go.vim b/runtime/syntax/go.vim
index e78f8cf27c..1439487f69 100644
--- a/runtime/syntax/go.vim
+++ b/runtime/syntax/go.vim
@@ -1,58 +1,109 @@
-" Vim syntax file
-" Language: Go
-" Maintainer: David Barnett (https://github.com/google/vim-ft-go)
-" Last Change: 2014 Aug 16
-
-" Options:
-" There are some options for customizing the highlighting; the recommended
-" settings are the default values, but you can write:
-" let OPTION_NAME = 0
-" in your ~/.vimrc file to disable particular options. You can also write:
-" let OPTION_NAME = 1
-" to enable particular options. At present, all options default to on.
+" Copyright 2009 The Go Authors. All rights reserved.
+" Use of this source code is governed by a BSD-style
+" license that can be found in the LICENSE file.
"
-" - g:go_highlight_array_whitespace_error
-" Highlights white space after "[]".
-" - g:go_highlight_chan_whitespace_error
-" Highlights white space around the communications operator that don't
-" follow the standard style.
-" - g:go_highlight_extra_types
-" Highlights commonly used library types (io.Reader, etc.).
-" - g:go_highlight_space_tab_error
-" Highlights instances of tabs following spaces.
-" - g:go_highlight_trailing_whitespace_error
-" Highlights trailing white space.
+" go.vim: Vim syntax file for Go.
+" Language: Go
+" Maintainer: Billie Cleek <bhcleek@gmail.com>
+" Latest Revision: 2021-06-26
+" License: BSD-style. See LICENSE file in source repository.
+" Repository: https://github.com/fatih/vim-go
" Quit when a (custom) syntax file was already loaded
-if exists('b:current_syntax')
+if exists("b:current_syntax")
finish
endif
-if !exists('g:go_highlight_array_whitespace_error')
- let g:go_highlight_array_whitespace_error = 1
-endif
-if !exists('g:go_highlight_chan_whitespace_error')
- let g:go_highlight_chan_whitespace_error = 1
-endif
-if !exists('g:go_highlight_extra_types')
- let g:go_highlight_extra_types = 1
-endif
-if !exists('g:go_highlight_space_tab_error')
- let g:go_highlight_space_tab_error = 1
-endif
-if !exists('g:go_highlight_trailing_whitespace_error')
- let g:go_highlight_trailing_whitespace_error = 1
-endif
+let s:keepcpo = &cpo
+set cpo&vim
+
+function! s:FoldEnable(...) abort
+ if a:0 > 0
+ return index(s:FoldEnable(), a:1) > -1
+ endif
+ return get(g:, 'go_fold_enable', ['block', 'import', 'varconst', 'package_comment'])
+endfunction
+
+function! s:HighlightArrayWhitespaceError() abort
+ return get(g:, 'go_highlight_array_whitespace_error', 0)
+endfunction
+
+function! s:HighlightChanWhitespaceError() abort
+ return get(g:, 'go_highlight_chan_whitespace_error', 0)
+endfunction
+
+function! s:HighlightExtraTypes() abort
+ return get(g:, 'go_highlight_extra_types', 0)
+endfunction
+
+function! s:HighlightSpaceTabError() abort
+ return get(g:, 'go_highlight_space_tab_error', 0)
+endfunction
+
+function! s:HighlightTrailingWhitespaceError() abort
+ return get(g:, 'go_highlight_trailing_whitespace_error', 0)
+endfunction
+
+function! s:HighlightOperators() abort
+ return get(g:, 'go_highlight_operators', 0)
+endfunction
+
+function! s:HighlightFunctions() abort
+ return get(g:, 'go_highlight_functions', 0)
+endfunction
+
+function! s:HighlightFunctionParameters() abort
+ return get(g:, 'go_highlight_function_parameters', 0)
+endfunction
+
+function! s:HighlightFunctionCalls() abort
+ return get(g:, 'go_highlight_function_calls', 0)
+endfunction
+
+function! s:HighlightFields() abort
+ return get(g:, 'go_highlight_fields', 0)
+endfunction
+
+function! s:HighlightTypes() abort
+ return get(g:, 'go_highlight_types', 0)
+endfunction
+
+function! s:HighlightBuildConstraints() abort
+ return get(g:, 'go_highlight_build_constraints', 0)
+endfunction
+
+function! s:HighlightStringSpellcheck() abort
+ return get(g:, 'go_highlight_string_spellcheck', 1)
+endfunction
+
+function! s:HighlightFormatStrings() abort
+ return get(g:, 'go_highlight_format_strings', 1)
+endfunction
+
+function! s:HighlightGenerateTags() abort
+ return get(g:, 'go_highlight_generate_tags', 0)
+endfunction
+
+function! s:HighlightVariableAssignments() abort
+ return get(g:, 'go_highlight_variable_assignments', 0)
+endfunction
+
+function! s:HighlightVariableDeclarations() abort
+ return get(g:, 'go_highlight_variable_declarations', 0)
+endfunction
syn case match
-syn keyword goDirective package import
-syn keyword goDeclaration var const type
-syn keyword goDeclType struct interface
+syn keyword goPackage package
+syn keyword goImport import contained
+syn keyword goVar var contained
+syn keyword goConst const contained
-hi def link goDirective Statement
+hi def link goPackage Statement
+hi def link goImport Statement
+hi def link goVar Keyword
+hi def link goConst Keyword
hi def link goDeclaration Keyword
-hi def link goDeclType Keyword
" Keywords within functions
syn keyword goStatement defer go goto return break continue fallthrough
@@ -78,28 +129,38 @@ hi def link goUnsignedInts Type
hi def link goFloats Type
hi def link goComplexes Type
-" Treat func specially: it's a declaration at the start of a line, but a type
-" elsewhere. Order matters here.
-syn match goType /\<func\>/
-syn match goDeclaration /^func\>/
-
" Predefined functions and values
-syn keyword goBuiltins append cap close complex copy delete imag len
-syn keyword goBuiltins make new panic print println real recover
-syn keyword goConstants iota true false nil
+syn keyword goBuiltins append cap close complex copy delete imag len
+syn keyword goBuiltins make new panic print println real recover
+syn keyword goBoolean true false
+syn keyword goPredefinedIdentifiers nil iota
-hi def link goBuiltins Keyword
-hi def link goConstants Keyword
+hi def link goBuiltins Identifier
+hi def link goBoolean Boolean
+hi def link goPredefinedIdentifiers goBoolean
" Comments; their contents
syn keyword goTodo contained TODO FIXME XXX BUG
syn cluster goCommentGroup contains=goTodo
-syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
-syn region goComment start="//" end="$" contains=@goCommentGroup,@Spell
+
+syn region goComment start="//" end="$" contains=goGenerate,@goCommentGroup,@Spell
+if s:FoldEnable('comment')
+ syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell fold
+ syn match goComment "\v(^\s*//.*\n)+" contains=goGenerate,@goCommentGroup,@Spell fold
+else
+ syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
+endif
hi def link goComment Comment
hi def link goTodo Todo
+if s:HighlightGenerateTags()
+ syn match goGenerateVariables contained /\%(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/
+ syn region goGenerate start="^\s*//go:generate" end="$" contains=goGenerateVariables
+ hi def link goGenerate PreProc
+ hi def link goGenerateVariables Special
+endif
+
" Go escapes
syn match goEscapeOctal display contained "\\[0-7]\{3}"
syn match goEscapeC display contained +\\[abfnrtv\\'"]+
@@ -118,8 +179,30 @@ hi def link goEscapeError Error
" Strings and their contents
syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError
-syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
-syn region goRawString start=+`+ end=+`+
+if s:HighlightStringSpellcheck()
+ syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup,@Spell
+ syn region goRawString start=+`+ end=+`+ contains=@Spell
+else
+ syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
+ syn region goRawString start=+`+ end=+`+
+endif
+
+if s:HighlightFormatStrings()
+ " [n] notation is valid for specifying explicit argument indexes
+ " 1. Match a literal % not preceded by a %.
+ " 2. Match any number of -, #, 0, space, or +
+ " 3. Match * or [n]* or any number or nothing before a .
+ " 4. Match * or [n]* or any number or nothing after a .
+ " 5. Match [n] or nothing before a verb
+ " 6. Match a formatting verb
+ syn match goFormatSpecifier /\
+ \%([^%]\%(%%\)*\)\
+ \@<=%[-#0 +]*\
+ \%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\
+ \%(\.\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\)\=\
+ \%(\[\d\+\]\)\=[vTtbcdoqxXUeEfFgGspw]/ contained containedin=goString,goRawString
+ hi def link goFormatSpecifier goSpecialString
+endif
hi def link goString String
hi def link goRawString String
@@ -131,71 +214,263 @@ syn region goCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=
hi def link goCharacter Character
" Regions
-syn region goBlock start="{" end="}" transparent fold
syn region goParen start='(' end=')' transparent
+if s:FoldEnable('block')
+ syn region goBlock start="{" end="}" transparent fold
+else
+ syn region goBlock start="{" end="}" transparent
+endif
+
+" import
+if s:FoldEnable('import')
+ syn region goImport start='import (' end=')' transparent fold contains=goImport,goString,goComment
+else
+ syn region goImport start='import (' end=')' transparent contains=goImport,goString,goComment
+endif
+
+" var, const
+if s:FoldEnable('varconst')
+ syn region goVar start='var (' end='^\s*)$' transparent fold
+ \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
+ syn region goConst start='const (' end='^\s*)$' transparent fold
+ \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
+else
+ syn region goVar start='var (' end='^\s*)$' transparent
+ \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
+ syn region goConst start='const (' end='^\s*)$' transparent
+ \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
+endif
+
+" Single-line var, const, and import.
+syn match goSingleDecl /\%(import\|var\|const\) [^(]\@=/ contains=goImport,goVar,goConst
" Integers
-syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>"
-syn match goHexadecimalInt "\<0x\x\+\>"
-syn match goOctalInt "\<0\o\+\>"
-syn match goOctalError "\<0\o*[89]\d*\>"
+syn match goDecimalInt "\<-\=\(0\|[1-9]_\?\(\d\|\d\+_\?\d\+\)*\)\%([Ee][-+]\=\d\+\)\=\>"
+syn match goDecimalError "\<-\=\(_\(\d\+_*\)\+\|\([1-9]\d*_*\)\+__\(\d\+_*\)\+\|\([1-9]\d*_*\)\+_\+\)\%([Ee][-+]\=\d\+\)\=\>"
+syn match goHexadecimalInt "\<-\=0[xX]_\?\(\x\+_\?\)\+\>"
+syn match goHexadecimalError "\<-\=0[xX]_\?\(\x\+_\?\)*\(\([^ \t0-9A-Fa-f_)]\|__\)\S*\|_\)\>"
+syn match goOctalInt "\<-\=0[oO]\?_\?\(\o\+_\?\)\+\>"
+syn match goOctalError "\<-\=0[0-7oO_]*\(\([^ \t0-7oOxX_/)\]\}\:]\|[oO]\{2,\}\|__\)\S*\|_\|[oOxX]\)\>"
+syn match goBinaryInt "\<-\=0[bB]_\?\([01]\+_\?\)\+\>"
+syn match goBinaryError "\<-\=0[bB]_\?[01_]*\([^ \t01_)]\S*\|__\S*\|_\)\>"
hi def link goDecimalInt Integer
+hi def link goDecimalError Error
hi def link goHexadecimalInt Integer
+hi def link goHexadecimalError Error
hi def link goOctalInt Integer
+hi def link goOctalError Error
+hi def link goBinaryInt Integer
+hi def link goBinaryError Error
hi def link Integer Number
" Floating point
-syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
-syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
-syn match goFloat "\<\d\+[Ee][-+]\d\+\>"
+syn match goFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=\>"
+syn match goFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=\>"
hi def link goFloat Float
" Imaginary literals
-syn match goImaginary "\<\d\+i\>"
-syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
-syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
-syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>"
+syn match goImaginary "\<-\=\d\+i\>"
+syn match goImaginary "\<-\=\d\+[Ee][-+]\=\d\+i\>"
+syn match goImaginaryFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=i\>"
+syn match goImaginaryFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=i\>"
hi def link goImaginary Number
+hi def link goImaginaryFloat Float
" Spaces after "[]"
-if go_highlight_array_whitespace_error != 0
- syn match goSpaceError display "\(\[\]\)\@<=\s\+"
+if s:HighlightArrayWhitespaceError()
+ syn match goSpaceError display "\%(\[\]\)\@<=\s\+"
endif
" Spacing errors around the 'chan' keyword
-if go_highlight_chan_whitespace_error != 0
+if s:HighlightChanWhitespaceError()
" receive-only annotation on chan type
- syn match goSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@="
+ "
+ " \(\<chan\>\)\@<!<- (only pick arrow when it doesn't come after a chan)
+ " this prevents picking up 'chan<- chan<-' but not '<- chan'
+ syn match goSpaceError display "\%(\%(\<chan\>\)\@<!<-\)\@<=\s\+\%(\<chan\>\)\@="
+
" send-only annotation on chan type
- syn match goSpaceError display "\(\<chan\)\@<=\s\+\(<-\)\@="
+ "
+ " \(<-\)\@<!\<chan\> (only pick chan when it doesn't come after an arrow)
+ " this prevents picking up '<-chan <-chan' but not 'chan <-'
+ syn match goSpaceError display "\%(\%(<-\)\@<!\<chan\>\)\@<=\s\+\%(<-\)\@="
+
" value-ignoring receives in a few contexts
- syn match goSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+"
+ syn match goSpaceError display "\%(\%(^\|[={(,;]\)\s*<-\)\@<=\s\+"
endif
" Extra types commonly seen
-if go_highlight_extra_types != 0
- syn match goExtraType /\<bytes\.\(Buffer\)\>/
- syn match goExtraType /\<io\.\(Reader\|Writer\|ReadWriter\|ReadWriteCloser\)\>/
- syn match goExtraType /\<reflect\.\(Kind\|Type\|Value\)\>/
+if s:HighlightExtraTypes()
+ syn match goExtraType /\<bytes\.\%(Buffer\)\>/
+ syn match goExtraType /\<context\.\%(Context\)\>/
+ syn match goExtraType /\<io\.\%(Reader\|ReadSeeker\|ReadWriter\|ReadCloser\|ReadWriteCloser\|Writer\|WriteCloser\|Seeker\)\>/
+ syn match goExtraType /\<reflect\.\%(Kind\|Type\|Value\)\>/
syn match goExtraType /\<unsafe\.Pointer\>/
endif
" Space-tab error
-if go_highlight_space_tab_error != 0
+if s:HighlightSpaceTabError()
syn match goSpaceError display " \+\t"me=e-1
endif
" Trailing white space error
-if go_highlight_trailing_whitespace_error != 0
+if s:HighlightTrailingWhitespaceError()
syn match goSpaceError display excludenl "\s\+$"
endif
hi def link goExtraType Type
hi def link goSpaceError Error
+
+
+" included from: https://github.com/athom/more-colorful.vim/blob/master/after/syntax/go.vim
+"
+" Comments; their contents
+syn keyword goTodo contained NOTE
+hi def link goTodo Todo
+
+syn match goVarArgs /\.\.\./
+
+" Operators;
+if s:HighlightOperators()
+ " match single-char operators: - + % < > ! & | ^ * =
+ " and corresponding two-char operators: -= += %= <= >= != &= |= ^= *= ==
+ syn match goOperator /[-+%<>!&|^*=]=\?/
+ " match / and /=
+ syn match goOperator /\/\%(=\|\ze[^/*]\)/
+ " match two-char operators: << >> &^
+ " and corresponding three-char operators: <<= >>= &^=
+ syn match goOperator /\%(<<\|>>\|&^\)=\?/
+ " match remaining two-char operators: := && || <- ++ --
+ syn match goOperator /:=\|||\|<-\|++\|--/
+ " match ...
+
+ hi def link goPointerOperator goOperator
+ hi def link goVarArgs goOperator
+endif
+hi def link goOperator Operator
+
+" Functions;
+if s:HighlightFunctions() || s:HighlightFunctionParameters()
+ syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleParams skipwhite skipnl
+ syn match goReceiverVar /\w\+\ze\s\+\%(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained
+ syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl
+ syn match goFunction /\w\+/ nextgroup=goSimpleParams contained skipwhite skipnl
+ syn match goReceiverType /\w\+/ contained
+ if s:HighlightFunctionParameters()
+ syn match goSimpleParams /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType nextgroup=goFunctionReturn skipwhite skipnl
+ syn match goFunctionReturn /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType skipwhite skipnl
+ syn match goParamName /\w\+\%(\s*,\s*\w\+\)*\ze\s\+\%(\w\|\.\|\*\|\[\)/ contained nextgroup=goParamType skipwhite skipnl
+ syn match goParamType /\%([^,)]\|\_s\)\+,\?/ contained nextgroup=goParamName skipwhite skipnl
+ \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock
+ hi def link goReceiverVar goParamName
+ hi def link goParamName Identifier
+ endif
+ syn match goReceiver /(\s*\w\+\%(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl
+else
+ syn keyword goDeclaration func
+endif
+hi def link goFunction Function
+
+" Function calls;
+if s:HighlightFunctionCalls()
+ syn match goFunctionCall /\w\+\ze(/ contains=goBuiltins,goDeclaration
+endif
+hi def link goFunctionCall Type
+
+" Fields;
+if s:HighlightFields()
+ " 1. Match a sequence of word characters coming after a '.'
+ " 2. Require the following but dont match it: ( \@= see :h E59)
+ " - The symbols: / - + * % OR
+ " - The symbols: [] {} <> ) OR
+ " - The symbols: \n \r space OR
+ " - The symbols: , : .
+ " 3. Have the start of highlight (hs) be the start of matched
+ " pattern (s) offsetted one to the right (+1) (see :h E401)
+ syn match goField /\.\w\+\
+ \%(\%([\/\-\+*%]\)\|\
+ \%([\[\]{}<\>\)]\)\|\
+ \%([\!=\^|&]\)\|\
+ \%([\n\r\ ]\)\|\
+ \%([,\:.]\)\)\@=/hs=s+1
+endif
+hi def link goField Identifier
+
+" Structs & Interfaces;
+if s:HighlightTypes()
+ syn match goTypeConstructor /\<\w\+{\@=/
+ syn match goTypeDecl /\<type\>/ nextgroup=goTypeName skipwhite skipnl
+ syn match goTypeName /\w\+/ contained nextgroup=goDeclType skipwhite skipnl
+ syn match goDeclType /\<\%(interface\|struct\)\>/ skipwhite skipnl
+ hi def link goReceiverType Type
+else
+ syn keyword goDeclType struct interface
+ syn keyword goDeclaration type
+endif
+hi def link goTypeConstructor Type
+hi def link goTypeName Type
+hi def link goTypeDecl Keyword
+hi def link goDeclType Keyword
+
+" Variable Assignments
+if s:HighlightVariableAssignments()
+ syn match goVarAssign /\v[_.[:alnum:]]+(,\s*[_.[:alnum:]]+)*\ze(\s*([-^+|^\/%&]|\*|\<\<|\>\>|\&\^)?\=[^=])/
+ hi def link goVarAssign Special
+endif
+
+" Variable Declarations
+if s:HighlightVariableDeclarations()
+ syn match goVarDefs /\v\w+(,\s*\w+)*\ze(\s*:\=)/
+ hi def link goVarDefs Special
+endif
+
+" Build Constraints
+if s:HighlightBuildConstraints()
+ syn match goBuildKeyword display contained "+build"
+ " Highlight the known values of GOOS, GOARCH, and other +build options.
+ syn keyword goBuildDirectives contained
+ \ android darwin dragonfly freebsd linux nacl netbsd openbsd plan9
+ \ solaris windows 386 amd64 amd64p32 arm armbe arm64 arm64be ppc64
+ \ ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc
+ \ s390 s390x sparc sparc64 cgo ignore race
+
+ " Other words in the build directive are build tags not listed above, so
+ " avoid highlighting them as comments by using a matchgroup just for the
+ " start of the comment.
+ " The rs=s+2 option lets the \s*+build portion be part of the inner region
+ " instead of the matchgroup so it will be highlighted as a goBuildKeyword.
+ syn region goBuildComment matchgroup=goBuildCommentStart
+ \ start="//\s*+build\s"rs=s+2 end="$"
+ \ contains=goBuildKeyword,goBuildDirectives
+ hi def link goBuildCommentStart Comment
+ hi def link goBuildDirectives Type
+ hi def link goBuildKeyword PreProc
+endif
+
+if s:HighlightBuildConstraints() || s:FoldEnable('package_comment')
+ " One or more line comments that are followed immediately by a "package"
+ " declaration are treated like package documentation, so these must be
+ " matched as comments to avoid looking like working build constraints.
+ " The he, me, and re options let the "package" itself be highlighted by
+ " the usual rules.
+ exe 'syn region goPackageComment start=/\v(\/\/.*\n)+\s*package/'
+ \ . ' end=/\v\n\s*package/he=e-7,me=e-7,re=e-7'
+ \ . ' contains=@goCommentGroup,@Spell'
+ \ . (s:FoldEnable('package_comment') ? ' fold' : '')
+ exe 'syn region goPackageComment start=/\v^\s*\/\*.*\n(.*\n)*\s*\*\/\npackage/'
+ \ . ' end=/\v\*\/\n\s*package/he=e-7,me=e-7,re=e-7'
+ \ . ' contains=@goCommentGroup,@Spell'
+ \ . (s:FoldEnable('package_comment') ? ' fold' : '')
+ hi def link goPackageComment Comment
+endif
+
+" :GoCoverage commands
+hi def link goCoverageNormalText Comment
+
" Search backwards for a global declaration to start processing the syntax.
"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/
@@ -203,6 +478,9 @@ hi def link goSpaceError Error
" following as a more expensive/less precise workaround.
syn sync minlines=500
-let b:current_syntax = 'go'
+let b:current_syntax = "go"
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
" vim: sw=2 sts=2 et
diff --git a/runtime/syntax/hamster.vim b/runtime/syntax/hamster.vim
index 64d9598a71..975562da0f 100644
--- a/runtime/syntax/hamster.vim
+++ b/runtime/syntax/hamster.vim
@@ -9,7 +9,7 @@
" It allows the use of multiple news- and mailserver and combines them to one
" mail- and newsserver for the news/mail-client. It load faster than a normal
" newsreader because many threads can run simultaneous. It contains scorefile
-" for news and mail, a build-in script language, the GUI allows translation to
+" for news and mail, a built-in script language, the GUI allows translation to
" other languages, it can be used in a network and that's not all features...
"
" quit when a syntax file was already loaded
diff --git a/runtime/syntax/idl.vim b/runtime/syntax/idl.vim
index 6a4ce7e087..2f20dec2d7 100644
--- a/runtime/syntax/idl.vim
+++ b/runtime/syntax/idl.vim
@@ -7,7 +7,7 @@
" This is an experiment. IDL's structure is simple enough to permit a full
" grammar based approach to rather than using a few heuristics. The result
-" is large and somewhat repetative but seems to work.
+" is large and somewhat repetitive but seems to work.
" There are some Microsoft extensions to idl files that are here. Some of
" them are disabled by defining idl_no_ms_extensions.
diff --git a/runtime/syntax/iss.vim b/runtime/syntax/iss.vim
index e41de5db5a..34bb698368 100644
--- a/runtime/syntax/iss.vim
+++ b/runtime/syntax/iss.vim
@@ -2,10 +2,10 @@
" Language: Inno Setup File (iss file) and My InnoSetup extension
" Maintainer: Jason Mills (jmills@cs.mun.ca)
" Previous Maintainer: Dominique Stéphan (dominique@mggen.com)
-" Last Change: 2019 Sep 27
+" Last Change: 2021 Aug 30
"
" Todo:
-" - The paramter String: is matched as flag string (because of case ignore).
+" - The parameter String: is matched as flag string (because of case ignore).
" - Pascal scripting syntax is not recognized.
" - Embedded double quotes confuse string matches. e.g. "asfd""asfa"
diff --git a/runtime/syntax/mma.vim b/runtime/syntax/mma.vim
index 0683adc573..d2f22e9be5 100644
--- a/runtime/syntax/mma.vim
+++ b/runtime/syntax/mma.vim
@@ -12,7 +12,7 @@
"
" let filetype_m="mma"
"
-" I also recommend setting the default 'Comment' hilighting to something
+" I also recommend setting the default 'Comment' highlighting to something
" other than the color used for 'Function', since both are plentiful in
" most mathematica files, and they are often the same color (when using
" background=dark).
@@ -109,7 +109,7 @@ syntax match mmaemPHAsis "\%(^\|\s\)(\@<!\*[a-zA-Z0-9]\+\%([- \t':]\+[a-zA-Z0-9]
syntax region mmaComment start=+(\*+ end=+\*)+ skipempty contains=@mmaNotes,mmaItem,@mmaCommentStrings,mmaemPHAsis,mmaComment
" Function Comments:
-" just like a normal comment except the first sentance is Special ala Java
+" just like a normal comment except the first sentence is Special ala Java
" (** *)
" TODO - fix this for nesting, or not...
syntax region mmaFunctionComment start="(\*\*\+" end="\*\+)" contains=@mmaNotes,mmaItem,mmaFunctionTitle,@mmaCommentStrings,mmaemPHAsis,mmaComment
diff --git a/runtime/syntax/objc.vim b/runtime/syntax/objc.vim
index b29313a3cf..7c6e2d5128 100644
--- a/runtime/syntax/objc.vim
+++ b/runtime/syntax/objc.vim
@@ -64,7 +64,7 @@ syn keyword objcStorageClass nullable nonnull null_unspecified
" ObjC type specifier
syn keyword objcTypeSpecifier __kindof __covariant
-" ObjC Type Infomation Parameters
+" ObjC Type Information Parameters
syn keyword objcTypeInfoParams ObjectType KeyType
" shorthand
diff --git a/runtime/syntax/pascal.vim b/runtime/syntax/pascal.vim
index 3ab5c2e661..206df213a6 100644
--- a/runtime/syntax/pascal.vim
+++ b/runtime/syntax/pascal.vim
@@ -3,7 +3,7 @@
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Previous Maintainers: Xavier Crégut <xavier.cregut@enseeiht.fr>
" Mario Eusebio <bio@dq.fct.unl.pt>
-" Last Change: 2021 Apr 23
+" Last Change: 2021 May 20
" Contributors: Tim Chase <tchase@csc.com>,
" Stas Grabois <stsi@vtrails.com>,
diff --git a/runtime/syntax/postscr.vim b/runtime/syntax/postscr.vim
index d5dc9a22d6..5af57aa0b1 100644
--- a/runtime/syntax/postscr.vim
+++ b/runtime/syntax/postscr.vim
@@ -6,7 +6,7 @@
" URL: http://www.eandem.co.uk/mrw/vim
"
" Options Flags:
-" postscr_level - language level to use for highligting (1, 2, or 3)
+" postscr_level - language level to use for highlighting (1, 2, or 3)
" postscr_display - include display PS operators
" postscr_ghostscript - include GS extensions
" postscr_fonts - highlight standard font names (a lot for PS 3)
@@ -469,12 +469,12 @@ if postscr_level == 2 || postscr_level == 3
syn keyword postscrConstant contained SubsVector UnderlineThickness FamilyName FontBBox CurMID
syn keyword postscrConstant contained Weight
-" PS2 User paramters
+" PS2 User parameters
syn keyword postscrConstant contained MaxFontItem MinFontCompress MaxUPathItem MaxFormItem MaxPatternItem
syn keyword postscrConstant contained MaxScreenItem MaxOpStack MaxDictStack MaxExecStack MaxLocalVM
syn keyword postscrConstant contained VMReclaim VMThreshold
-" PS2 System paramters
+" PS2 System parameters
syn keyword postscrConstant contained SystemParamsPassword StartJobPassword BuildTime ByteOrder RealFormat
syn keyword postscrConstant contained MaxFontCache CurFontCache MaxOutlineCache CurOutlineCache
syn keyword postscrConstant contained MaxUPathCache CurUPathCache MaxFormCache CurFormCache
@@ -504,7 +504,7 @@ if postscr_level == 2 || postscr_level == 3
syn keyword postscrL2Operator accuratescreens checkscreen pagemargin pageparams setaccuratescreens setpage
syn keyword postscrL2Operator setpagemargin setpageparams
-" Misc compatability operators
+" Misc compatibility operators
syn keyword postscrL2Operator appletalktype buildtime byteorder checkpassword defaulttimeouts diskonline
syn keyword postscrL2Operator diskstatus manualfeed manualfeedtimeout margins mirrorprint pagecount
syn keyword postscrL2Operator pagestackorder printername processcolors sethardwareiomode setjobtimeout
diff --git a/runtime/syntax/redif.vim b/runtime/syntax/redif.vim
index 198d5c7530..365192284b 100644
--- a/runtime/syntax/redif.vim
+++ b/runtime/syntax/redif.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: ReDIF
" Maintainer: Axel Castellane <axel.castellane@polytechnique.edu>
-" Last Change: 2021 Jun 17
+" Last Change: 2021 Jul 28
" Original Author: Axel Castellane
" Source: http://openlib.org/acmes/root/docu/redif_1.html
" File Extension: rdf
diff --git a/runtime/syntax/scala.vim b/runtime/syntax/scala.vim
index 89a936ad17..16e114778d 100644
--- a/runtime/syntax/scala.vim
+++ b/runtime/syntax/scala.vim
@@ -3,8 +3,7 @@
" Maintainer: Derek Wyatt
" URL: https://github.com/derekwyatt/vim-scala
" License: Same as Vim
-" Last Change: 2021 Aug 11
-" by Jesse Atkinson, PR #8746
+" Last Change: 23 August 2021
" ----------------------------------------------------------------------------
if !exists('main_syntax')
@@ -103,9 +102,9 @@ syn match scalaTypeTypeDeclaration /(/ contained nextgroup=scalaTypeTypeExtensio
syn match scalaTypeTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeTypeDeclaration contains=scalaTypeTypeExtension skipwhite
syn match scalaTypeTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypeExtension,scalaTypeTypeEquals skipwhite
syn match scalaTypeTypeEquals /=\ze[^>]/ contained nextgroup=scalaTypeTypePostDeclaration skipwhite
-syn match scalaTypeTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained nextgroup=scalaTypeTypeDeclaration skipwhite
+syn match scalaTypeTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeTypeDeclaration skipwhite
syn match scalaTypeTypePostDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypePostExtension skipwhite
-syn match scalaTypeTypePostExtension /\%(⇒\|=>\|<:\|:>\|=:=\|::\)/ contained nextgroup=scalaTypeTypePostDeclaration skipwhite
+syn match scalaTypeTypePostExtension /\%(⇒\|=>\|<:\|:>\|=:=\|::\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeTypePostDeclaration skipwhite
hi link scalaTypeTypeDeclaration Type
hi link scalaTypeTypeExtension Keyword
hi link scalaTypeTypePostDeclaration Special
@@ -114,21 +113,23 @@ hi link scalaTypeTypePostExtension Keyword
syn match scalaTypeDeclaration /(/ contained nextgroup=scalaTypeExtension contains=scalaRoundBrackets skipwhite
syn match scalaTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeDeclaration contains=scalaTypeExtension skipwhite
syn match scalaTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeExtension skipwhite
-syn match scalaTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained nextgroup=scalaTypeDeclaration skipwhite
+syn match scalaTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeDeclaration skipwhite
hi link scalaTypeDeclaration Type
hi link scalaTypeExtension Keyword
hi link scalaTypePostExtension Keyword
syn match scalaTypeAnnotation /\%([_a-zA-Z0-9$\s]:\_s*\)\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration contains=scalaRoundBrackets
syn match scalaTypeAnnotation /)\_s*:\_s*\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration
-hi link scalaTypeAnnotation Normal
+hi clear scalaTypeAnnotation
-syn match scalaCaseFollowing /\<[_\.A-Za-z0-9$]\+\>/ contained
-syn match scalaCaseFollowing /`[^`]\+`/ contained
+syn match scalaCaseFollowing /\<[_\.A-Za-z0-9$]\+\>/ contained contains=scalaCapitalWord
+syn match scalaCaseFollowing /`[^`]\+`/ contained contains=scalaCapitalWord
hi link scalaCaseFollowing Special
-syn keyword scalaKeywordModifier abstract override final lazy implicit implicitly private protected sealed null require super
+syn keyword scalaKeywordModifier abstract override final lazy implicit private protected sealed null super
+syn keyword scalaSpecialFunction implicitly require
hi link scalaKeywordModifier Function
+hi link scalaSpecialFunction Function
syn keyword scalaSpecial this true false ne eq
syn keyword scalaSpecial new nextgroup=scalaInstanceDeclaration skipwhite
@@ -152,14 +153,14 @@ hi link scalaTripleIString String
syn match scalaInterpolation /\$[a-zA-Z0-9_$]\+/ contained
exe 'syn region scalaInterpolationB matchgroup=scalaInterpolationBoundary start=/\${/ end=/}/ contained contains=' . s:ContainedGroup()
hi link scalaInterpolation Function
-hi link scalaInterpolationB Normal
+hi clear scalaInterpolationB
syn region scalaFString matchgroup=scalaInterpolationBrackets start=/f"/ skip=/\\"/ end=/"/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedChar,scalaUnicodeChar
syn match scalaFInterpolation /\$[a-zA-Z0-9_$]\+\(%[-A-Za-z0-9\.]\+\)\?/ contained
exe 'syn region scalaFInterpolationB matchgroup=scalaInterpolationBoundary start=/${/ end=/}\(%[-A-Za-z0-9\.]\+\)\?/ contained contains=' . s:ContainedGroup()
hi link scalaFString String
hi link scalaFInterpolation Function
-hi link scalaFInterpolationB Normal
+hi clear scalaFInterpolationB
syn region scalaTripleString start=/"""/ end=/"""\%([^"]\|$\)/ contains=scalaEscapedChar,scalaUnicodeChar
syn region scalaTripleFString matchgroup=scalaInterpolationBrackets start=/f"""/ end=/"""\%([^"]\|$\)/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedChar,scalaUnicodeChar
@@ -200,7 +201,6 @@ hi link scalaDocLinks Function
hi link scalaParameterAnnotation Function
hi link scalaParamAnnotationValue Keyword
hi link scalaCommentAnnotation Function
-hi link scalaCommentCodeBlockBrackets String
hi link scalaCommentCodeBlock String
hi link scalaTodo Todo
diff --git a/runtime/syntax/scdoc.vim b/runtime/syntax/scdoc.vim
new file mode 100644
index 0000000000..25c9c5433b
--- /dev/null
+++ b/runtime/syntax/scdoc.vim
@@ -0,0 +1,52 @@
+" Syntax file for scdoc files
+" Maintainer: Gregory Anders <greg@gpanders.com>
+" Last Updated: 2021-08-04
+
+if exists('b:current_syntax')
+ finish
+endif
+let b:current_syntax = 'scdoc'
+
+syntax match scdocFirstLineError "\%^.*$"
+syntax match scdocFirstLineValid "\%^\S\+(\d[0-9A-Za-z]*)\%(\s\+\"[^"]*\"\%(\s\+\"[^"]*\"\)\=\)\=$"
+
+syntax region scdocCommentError start="^;\S" end="$" keepend
+syntax region scdocComment start="^; " end="$" keepend
+
+syntax region scdocHeaderError start="^#\{3,}" end="$" keepend
+syntax region scdocHeader start="^#\{1,2}" end="$" keepend
+
+syntax match scdocIndentError "^[ ]\+"
+
+syntax match scdocLineBreak "++$"
+
+syntax match scdocOrderedListMarker "^\s*\.\%(\s\+\S\)\@="
+syntax match scdocListMarker "^\s*-\%(\s\+\S\)\@="
+
+syntax match scdocTableStartMarker "^[\[|\]][\[\-\]]"
+syntax match scdocTableMarker "^[|:][\[\-\] ]"
+
+syntax region scdocBold concealends matchgroup=scdocBoldDelimiter start="\\\@<!\*" end="\\\@<!\*"
+syntax region scdocUnderline concealends matchgroup=scdocUnderlineDelimiter start="\<\\\@<!_" end="\\\@<!_\>"
+syntax region scdocPre matchgroup=scdocPreDelimiter start="^\t*```" end="^\t*```"
+
+hi link scdocFirstLineValid Comment
+hi link scdocComment Comment
+hi link scdocHeader Title
+hi link scdocOrderedListMarker Statement
+hi link scdocListMarker scdocOrderedListMarker
+hi link scdocLineBreak Special
+hi link scdocTableMarker Statement
+hi link scdocTableStartMarker scdocTableMarker
+
+hi link scdocFirstLineError Error
+hi link scdocCommentError Error
+hi link scdocHeaderError Error
+hi link scdocIndentError Error
+
+hi link scdocPreDelimiter Delimiter
+
+hi scdocBold term=bold cterm=bold gui=bold
+hi scdocUnderline term=underline cterm=underline gui=underline
+hi link scdocBoldDelimiter scdocBold
+hi link scdocUnderlineDelimiter scdocUnderline
diff --git a/runtime/syntax/scheme.vim b/runtime/syntax/scheme.vim
index e209729f57..c4454fc57c 100644
--- a/runtime/syntax/scheme.vim
+++ b/runtime/syntax/scheme.vim
@@ -1,10 +1,11 @@
" Vim syntax file
" Language: Scheme (R7RS)
-" Last Change: 2018-01-06
+" Last Change: 2021-01-03
" Author: Evan Hanson <evhan@foldling.org>
" Maintainer: Evan Hanson <evhan@foldling.org>
" Previous Author: Dirk van Deun <dirk@igwe.vub.ac.be>
" Previous Maintainer: Sergey Khorev <sergey.khorev@gmail.com>
+" Repository: https://git.foldling.org/vim-scheme.git
" URL: https://foldling.org/vim/syntax/scheme.vim
if exists('b:current_syntax')
@@ -14,6 +15,8 @@ endif
let s:cpo = &cpo
set cpo&vim
+syn spell notoplevel
+
syn match schemeParentheses "[^ '`\t\n()\[\]";]\+"
syn match schemeParentheses "[)\]]"
@@ -35,7 +38,7 @@ syn region schemeUnquote matchgroup=schemeParentheses start=/,@(/ end=/)/ contai
syn region schemeQuoteForm matchgroup=schemeData start=/(/ end=/)/ contained contains=ALLBUT,schemeQuasiquote,schemeQuasiquoteForm,schemeUnquote,schemeForm,schemeDatumCommentForm,schemeImport,@schemeImportCluster,@schemeSyntaxCluster
syn region schemeQuasiquoteForm matchgroup=schemeData start=/(/ end=/)/ contained contains=ALLBUT,schemeQuote,schemeForm,schemeDatumCommentForm,schemeImport,@schemeImportCluster,@schemeSyntaxCluster
-syn region schemeString start=/\(\\\)\@<!"/ skip=/\\[\\"]/ end=/"/
+syn region schemeString start=/\(\\\)\@<!"/ skip=/\\[\\"]/ end=/"/ contains=@Spell
syn region schemeSymbol start=/\(\\\)\@<!|/ skip=/\\[\\|]/ end=/|/
syn match schemeNumber /\(#[dbeio]\)*[+\-]*\([0-9]\+\|inf.0\|nan.0\)\(\/\|\.\)\?[0-9+\-@\ilns]*\>/
@@ -47,9 +50,9 @@ syn match schemeBoolean /#f\(alse\)\?/
syn match schemeCharacter /#\\.[^ `'\t\n\[\]()]*/
syn match schemeCharacter /#\\x[0-9a-fA-F]\+/
-syn match schemeComment /;.*$/
+syn match schemeComment /;.*$/ contains=@Spell
-syn region schemeMultilineComment start=/#|/ end=/|#/ contains=schemeMultilineComment
+syn region schemeMultilineComment start=/#|/ end=/|#/ contains=schemeMultilineComment,@Spell
syn region schemeForm matchgroup=schemeParentheses start="(" end=")" contains=ALLBUT,schemeUnquote,schemeDatumCommentForm,@schemeImportCluster
syn region schemeForm matchgroup=schemeParentheses start="\[" end="\]" contains=ALLBUT,schemeUnquote,schemeDatumCommentForm,@schemeImportCluster
@@ -63,7 +66,7 @@ else
syn region schemeImport matchgroup=schemeImport start="\(([ \t\n]*\)\@<=\(import\)\>" end=")"me=e-1 contained contains=schemeImportForm,schemeIdentifier,schemeComment,schemeDatumComment
endif
-syn match schemeImportKeyword "\(([ \t\n]*\)\@<=\(except\|only\|prefix\|rename\|srfi\)\>"
+syn match schemeImportKeyword "\(([ \t\n]*\)\@<=\(except\|only\|prefix\|rename\)\>"
syn region schemeImportForm matchgroup=schemeParentheses start="(" end=")" contained contains=schemeIdentifier,schemeComment,schemeDatumComment,@schemeImportCluster
syn cluster schemeImportCluster contains=schemeImportForm,schemeImportKeyword
diff --git a/runtime/syntax/sgml.vim b/runtime/syntax/sgml.vim
index d60040c5d9..00d58d11f2 100644
--- a/runtime/syntax/sgml.vim
+++ b/runtime/syntax/sgml.vim
@@ -174,7 +174,7 @@ syn match sgmlAbbrEndTag +/+
" SGML specific
" abbreviated regions
"
-" No highlighing, highlighing is done by contained elements.
+" No highlighting, highlighting is done by contained elements.
"
" PROVIDES: @sgmlRegionHook
"
@@ -192,7 +192,7 @@ syn match sgmlAbbrRegion
" real (non-empty) elements. We cannot do syntax folding
" as in xml, because end tags may be optional in sgml depending
" on the dtd.
-" No highlighing, highlighing is done by contained elements.
+" No highlighting, highlighting is done by contained elements.
"
" PROVIDES: @sgmlRegionHook
"
@@ -225,7 +225,7 @@ syn region sgmlRegion
"
" <tag id="lola"/>
"
-" TODO use sgmlEmptyTag intead of sgmlTag
+" TODO use sgmlEmptyTag instead of sgmlTag
syn match sgmlEmptyRegion
\ +<[^ /!?>"']\(\_[^"'<>]\|"\_[^"]*"\|'\_[^']*'\)*/>+
\ contains=sgmlEmptyTag
diff --git a/runtime/syntax/spup.vim b/runtime/syntax/spup.vim
index 743c7b5711..9284abf63f 100644
--- a/runtime/syntax/spup.vim
+++ b/runtime/syntax/spup.vim
@@ -25,7 +25,7 @@ endif
let s:cpo_save = &cpo
set cpo&vim
-" don't hightlight several keywords like subsections
+" don't highlight several keywords like subsections
"let strict_subsections = 1
" highlight types usually found in DECLARE section
@@ -177,7 +177,7 @@ syn cluster spupOrdinary contains=spupNumber,spupIdentifier,spupSymbol
syn cluster spupOrdinary add=spupError,spupString,spupComment
syn cluster spupTextproc contains=spupTextprocGeneric,spupTextprocError
-" define syncronizing; especially OPERATION sections can become very large
+" define synchronizing; especially OPERATION sections can become very large
syn sync clear
syn sync minlines=100
syn sync maxlines=500
diff --git a/runtime/syntax/st.vim b/runtime/syntax/st.vim
index 8160c7704a..ffa7820fe8 100644
--- a/runtime/syntax/st.vim
+++ b/runtime/syntax/st.vim
@@ -44,7 +44,7 @@ syn match stCharacter "$."
syn case ignore
-" the symols prefixed by a '#'
+" the symbols prefixed by a '#'
syn match stSymbol "\(#\<[a-z_][a-z0-9_]*\>\)"
syn match stSymbol "\(#'[^']*'\)"
@@ -58,7 +58,7 @@ syn match stFloat "\<\d\+e[-+]\=\d\+[fl]\=\>"
syn case match
-" a try to higlight paren mismatches
+" a try to highlight paren mismatches
syn region stParen transparent start='(' end=')' contains=ALLBUT,stParenError
syn match stParenError ")"
syn region stBlock transparent start='\[' end='\]' contains=ALLBUT,stBlockError
diff --git a/runtime/syntax/structurizr.vim b/runtime/syntax/structurizr.vim
new file mode 100644
index 0000000000..73629b1495
--- /dev/null
+++ b/runtime/syntax/structurizr.vim
@@ -0,0 +1,76 @@
+" Vim syntax file
+" Language: Structurizr DSL
+" Maintainer: Bastian Venthur <venthur@debian.org>
+" Last Change: 2021-08-16
+" Remark: For a language reference, see
+" https://github.com/structurizr/dsl
+
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn case ignore
+
+" comments
+syn match scomment "#.*$"
+syn match scomment "//.*$"
+syn region scomment start="/\*" end="\*/"
+
+" keywords
+syn keyword skeyword animation
+syn keyword skeyword autoLayout
+syn keyword skeyword branding
+syn keyword skeyword component
+syn keyword skeyword configuration
+syn keyword skeyword container
+syn keyword skeyword containerinstance
+syn keyword skeyword custom
+syn keyword skeyword deployment
+syn keyword skeyword deploymentenvironment
+syn keyword skeyword deploymentgroup
+syn keyword skeyword deploymentnode
+syn keyword skeyword dynamic
+syn keyword skeyword element
+syn keyword skeyword enterprise
+syn keyword skeyword exclude
+syn keyword skeyword filtered
+syn keyword skeyword group
+syn keyword skeyword healthcheck
+syn keyword skeyword impliedrelationships
+syn keyword skeyword include
+syn keyword skeyword infrastructurenode
+syn keyword skeyword model
+syn keyword skeyword person
+syn keyword skeyword perspectives
+syn keyword skeyword properties
+syn keyword skeyword relationship
+syn keyword skeyword softwaresystem
+syn keyword skeyword softwaresysteminstance
+syn keyword skeyword styles
+syn keyword skeyword systemcontext
+syn keyword skeyword systemlandscape
+syn keyword skeyword tags
+syn keyword skeyword terminology
+syn keyword skeyword theme
+syn keyword skeyword title
+syn keyword skeyword url
+syn keyword skeyword users
+syn keyword skeyword views
+syn keyword skeyword workspace
+
+syn match skeyword "\!adrs\s\+"
+syn match skeyword "\!constant\s\+"
+syn match skeyword "\!docs\s\+"
+syn match skeyword "\!identifiers\s\+"
+syn match skeyword "\!include\s\+"
+
+syn region sstring oneline start='"' end='"'
+
+syn region sblock start='{' end='}' fold transparent
+
+hi def link sstring string
+hi def link scomment comment
+hi def link skeyword keyword
+
+let b:current_syntax = "structurizr"
diff --git a/runtime/syntax/tmux.vim b/runtime/syntax/tmux.vim
index d5419982ad..4f435ab923 100644
--- a/runtime/syntax/tmux.vim
+++ b/runtime/syntax/tmux.vim
@@ -8,7 +8,7 @@ if exists("b:current_syntax")
finish
endif
-" Explicitly change compatiblity options to Vim's defaults because this file
+" Explicitly change compatibility options to Vim's defaults because this file
" uses line continuations.
let s:original_cpo = &cpo
set cpo&vim
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index 7aae7965a9..f695a1a1bf 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -12,7 +12,7 @@
if exists("b:current_syntax")
finish
endif
-let s:keepcpo= &cpo
+let s:keepcpo = &cpo
set cpo&vim
" vimTodo: contains common special-notices for comments {{{2