From e6d3f87dfd71dde94aebce600fd11cb954af1ba9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 8 Apr 2023 19:27:58 +0800 Subject: fix(termdebug): handle partial lines passed to callback (#22950) Problem: Job callbacks in termdebug cannot handle partial lines. Solution: Add a wrapper function that handles partial lines and only passes full lines to the real callback. Fix #22929. --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 99fd7dba42..d653f71281 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -245,7 +245,7 @@ func s:StartDebug_term(dict) " Create a hidden terminal window to communicate with gdb let s:comm_job_id = jobstart('tail -f /dev/null;#gdb communication', { - \ 'on_stdout': function('s:CommOutput'), + \ 'on_stdout': function('s:JobOutCallback', {'last_line': '', 'real_cb': function('s:CommOutput')}), \ 'pty': v:true, \ }) " hide terminal buffer @@ -430,7 +430,7 @@ func s:StartDebug_prompt(dict) " call ch_log('executing "' . join(gdb_cmd) . '"') let s:gdbjob = jobstart(gdb_cmd, { \ 'on_exit': function('s:EndPromptDebug'), - \ 'on_stdout': function('s:GdbOutCallback'), + \ 'on_stdout': function('s:JobOutCallback', {'last_line': '', 'real_cb': function('s:GdbOutCallback')}), \ }) if s:gdbjob == 0 echoerr 'invalid argument (or job table is full) while starting gdb job' @@ -594,6 +594,23 @@ func s:PromptInterrupt() endif endfunc +" Wrapper around job callback that handles partial lines (:h channel-lines). +" It should be called from a Dictionary with the following keys: +" - last_line: the last (partial) line received +" - real_cb: a callback that assumes full lines +func s:JobOutCallback(jobid, data, event) dict + let eof = (a:data == ['']) + let msgs = a:data + let msgs[0] = self.last_line .. msgs[0] + if eof + let self.last_line = '' + else + let self.last_line = msgs[-1] + unlet msgs[-1] + endif + call self.real_cb(a:jobid, msgs, a:event) +endfunc + " Function called when gdb outputs text. func s:GdbOutCallback(job_id, msgs, event) "call ch_log('received from gdb: ' . a:text) -- cgit From 880f7d12fea31ea85d14b419ef8dcbb16dee2cf4 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:10:36 +0200 Subject: feat!: remove vimballs (#22402) Vimball is an outdated feature that is rarely used these days. It is not a maintenance burden on its own, but it is nonetheless dead weight and something we'd need to tell users to ignore when they inevitably ask what it is. See: https://github.com/neovim/neovim/pull/21369#issuecomment-1347615173 --- runtime/pack/dist/opt/vimball/autoload/vimball.vim | 775 --------------------- runtime/pack/dist/opt/vimball/doc/vimball.txt | 273 -------- .../pack/dist/opt/vimball/plugin/vimballPlugin.vim | 43 -- 3 files changed, 1091 deletions(-) delete mode 100644 runtime/pack/dist/opt/vimball/autoload/vimball.vim delete mode 100644 runtime/pack/dist/opt/vimball/doc/vimball.txt delete mode 100644 runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/vimball/autoload/vimball.vim b/runtime/pack/dist/opt/vimball/autoload/vimball.vim deleted file mode 100644 index 9c7dcbda0f..0000000000 --- a/runtime/pack/dist/opt/vimball/autoload/vimball.vim +++ /dev/null @@ -1,775 +0,0 @@ -" vimball.vim : construct a file containing both paths and files -" Author: Charles E. Campbell -" Date: Apr 11, 2016 -" Version: 37 -" GetLatestVimScripts: 1502 1 :AutoInstall: vimball.vim -" Copyright: (c) 2004-2011 by Charles E. Campbell -" The VIM LICENSE applies to Vimball.vim, and Vimball.txt -" (see |copyright|) except use "Vimball" instead of "Vim". -" No warranty, express or implied. -" *** *** Use At-Your-Own-Risk! *** *** - -" --------------------------------------------------------------------- -" Load Once: {{{1 -if &cp || exists("g:loaded_vimball") - finish -endif -let g:loaded_vimball = "v37" -if v:version < 702 - echohl WarningMsg - echo "***warning*** this version of vimball needs vim 7.2" - echohl Normal - finish -endif -let s:keepcpo= &cpo -set cpo&vim -"DechoTabOn - -" ===================================================================== -" Constants: {{{1 -if !exists("s:USAGE") - let s:USAGE = 0 - let s:WARNING = 1 - let s:ERROR = 2 - - " determine if cygwin is in use or not - if !exists("g:netrw_cygwin") - if has("win32") || has("win95") || has("win64") || has("win16") - if &shell =~ '\%(\\|\\)\%(\.exe\)\=$' - let g:netrw_cygwin= 1 - else - let g:netrw_cygwin= 0 - endif - else - let g:netrw_cygwin= 0 - endif - endif - - " set up g:vimball_mkdir if the mkdir() call isn't defined - if !exists("*mkdir") - if exists("g:netrw_local_mkdir") - let g:vimball_mkdir= g:netrw_local_mkdir - elseif executable("mkdir") - let g:vimball_mkdir= "mkdir" - elseif executable("makedir") - let g:vimball_mkdir= "makedir" - endif - if !exists(g:vimball_mkdir) - call vimball#ShowMesg(s:WARNING,"(vimball) g:vimball_mkdir undefined") - endif - endif -endif - -" ===================================================================== -" Functions: {{{1 - -" --------------------------------------------------------------------- -" vimball#MkVimball: creates a vimball given a list of paths to files {{{2 -" Input: -" line1,line2: a range of lines containing paths to files to be included in the vimball -" writelevel : if true, force a write to filename.vmb, even if it exists -" (usually accomplished with :MkVimball! ... -" filename : base name of file to be created (ie. filename.vmb) -" Output: a filename.vmb using vimball format: -" path -" filesize -" [file] -" path -" filesize -" [file] -fun! vimball#MkVimball(line1,line2,writelevel,...) range -" call Dfunc("MkVimball(line1=".a:line1." line2=".a:line2." writelevel=".a:writelevel." vimballname<".a:1.">) a:0=".a:0) - if a:1 =~ '\.vim$' || a:1 =~ '\.txt$' - let vbname= substitute(a:1,'\.\a\{3}$','.vmb','') - else - let vbname= a:1 - endif - if vbname !~ '\.vmb$' - let vbname= vbname.'.vmb' - endif -" call Decho("vbname<".vbname.">") - if !a:writelevel && a:1 =~ '[\/]' - call vimball#ShowMesg(s:ERROR,"(MkVimball) vimball name<".a:1."> should not include slashes; use ! to insist") -" call Dret("MkVimball : vimball name<".a:1."> should not include slashes") - return - endif - if !a:writelevel && filereadable(vbname) - call vimball#ShowMesg(s:ERROR,"(MkVimball) file<".vbname."> exists; use ! to insist") -" call Dret("MkVimball : file<".vbname."> already exists; use ! to insist") - return - endif - - " user option bypass - call vimball#SaveSettings() - - if a:0 >= 2 - " allow user to specify where to get the files - let home= expand(a:2) - else - " use first existing directory from rtp - let home= vimball#VimballHome() - endif - - " save current directory - let curdir = getcwd() - call s:ChgDir(home) - - " record current tab, initialize while loop index - let curtabnr = tabpagenr() - let linenr = a:line1 -" call Decho("curtabnr=".curtabnr) - - while linenr <= a:line2 - let svfile = getline(linenr) -" call Decho("svfile<".svfile.">") - - if !filereadable(svfile) - call vimball#ShowMesg(s:ERROR,"unable to read file<".svfile.">") - call s:ChgDir(curdir) - call vimball#RestoreSettings() -" call Dret("MkVimball") - return - endif - - " create/switch to mkvimball tab - if !exists("vbtabnr") - tabnew - sil! file Vimball - let vbtabnr= tabpagenr() - else - exe "tabn ".vbtabnr - endif - - let lastline= line("$") + 1 - if lastline == 2 && getline("$") == "" - call setline(1,'" Vimball Archiver by Charles E. Campbell') - call setline(2,'UseVimball') - call setline(3,'finish') - let lastline= line("$") + 1 - endif - call setline(lastline ,substitute(svfile,'$',' [[[1','')) - call setline(lastline+1,0) - - " write the file from the tab -" call Decho("exe $r ".fnameescape(svfile)) - exe "$r ".fnameescape(svfile) - - call setline(lastline+1,line("$") - lastline - 1) -" call Decho("lastline=".lastline." line$=".line("$")) - - " restore to normal tab - exe "tabn ".curtabnr - let linenr= linenr + 1 - endwhile - - " write the vimball - exe "tabn ".vbtabnr - call s:ChgDir(curdir) - setlocal ff=unix - if a:writelevel -" call Decho("exe w! ".fnameescape(vbname)) - exe "w! ".fnameescape(vbname) - else -" call Decho("exe w ".fnameescape(vbname)) - exe "w ".fnameescape(vbname) - endif -" call Decho("Vimball<".vbname."> created") - echo "Vimball<".vbname."> created" - - " remove the evidence - setlocal nomod bh=wipe - exe "tabn ".curtabnr - exe "tabc! ".vbtabnr - - " restore options - call vimball#RestoreSettings() - -" call Dret("MkVimball") -endfun - -" --------------------------------------------------------------------- -" vimball#Vimball: extract and distribute contents from a vimball {{{2 -" (invoked the the UseVimball command embedded in -" vimballs' prologue) -fun! vimball#Vimball(really,...) -" call Dfunc("vimball#Vimball(really=".a:really.") a:0=".a:0) - - if v:version < 701 || (v:version == 701 && !exists('*fnameescape')) - echoerr "your vim is missing the fnameescape() function (pls upgrade to vim 7.2 or later)" -" call Dret("vimball#Vimball : needs 7.1 with patch 299 or later") - return - endif - - if getline(1) !~ '^" Vimball Archiver' - echoerr "(Vimball) The current file does not appear to be a Vimball!" -" call Dret("vimball#Vimball") - return - endif - - " set up standard settings - call vimball#SaveSettings() - let curtabnr = tabpagenr() - let vimballfile = expand("%:tr") - - " set up vimball tab -" call Decho("setting up vimball tab") - tabnew - sil! file Vimball - let vbtabnr= tabpagenr() - let didhelp= "" - - " go to vim plugin home - if a:0 > 0 - " let user specify the directory where the vimball is to be unpacked. - " If, however, the user did not specify a full path, set the home to be below the current directory - let home= expand(a:1) - if has("win32") || has("win95") || has("win64") || has("win16") - if home !~ '^\a:[/\\]' - let home= getcwd().'/'.a:1 - endif - elseif home !~ '^/' - let home= getcwd().'/'.a:1 - endif - else - let home= vimball#VimballHome() - endif -" call Decho("home<".home.">") - - " save current directory and remove older same-named vimball, if any - let curdir = getcwd() -" call Decho("home<".home.">") -" call Decho("curdir<".curdir.">") - - call s:ChgDir(home) - let s:ok_unablefind= 1 - call vimball#RmVimball(vimballfile) - unlet s:ok_unablefind - - let linenr = 4 - let filecnt = 0 - - " give title to listing of (extracted) files from Vimball Archive - if a:really - echohl Title | echomsg "Vimball Archive" | echohl None - else - echohl Title | echomsg "Vimball Archive Listing" | echohl None - echohl Statement | echomsg "files would be placed under: ".home | echohl None - endif - - " apportion vimball contents to various files -" call Decho("exe tabn ".curtabnr) - exe "tabn ".curtabnr -" call Decho("linenr=".linenr." line$=".line("$")) - while 1 < linenr && linenr < line("$") - let fname = substitute(getline(linenr),'\t\[\[\[1$','','') - let fname = substitute(fname,'\\','/','g') - let fsize = substitute(getline(linenr+1),'^\(\d\+\).\{-}$','\1','')+0 - let fenc = substitute(getline(linenr+1),'^\d\+\s*\(\S\{-}\)$','\1','') - let filecnt = filecnt + 1 -" call Decho("fname<".fname."> fsize=".fsize." filecnt=".filecnt. " fenc=".fenc) - - if a:really - echomsg "extracted <".fname.">: ".fsize." lines" - else - echomsg "would extract <".fname.">: ".fsize." lines" - endif -" call Decho("using L#".linenr.": will extract file<".fname.">") -" call Decho("using L#".(linenr+1).": fsize=".fsize) - - " Allow AsNeeded/ directory to take place of plugin/ directory - " when AsNeeded/filename is filereadable or was present in VimballRecord - if fname =~ '\ instead of <".fname.">") - let fname= anfname - endif - endif - - " make directories if they don't exist yet - if a:really -" call Decho("making directories if they don't exist yet (fname<".fname.">)") - let fnamebuf= substitute(fname,'\\','/','g') - let dirpath = substitute(home,'\\','/','g') -" call Decho("init: fnamebuf<".fnamebuf.">") -" call Decho("init: dirpath <".dirpath.">") - while fnamebuf =~ '/' - let dirname = dirpath."/".substitute(fnamebuf,'/.*$','','') - let dirpath = dirname - let fnamebuf = substitute(fnamebuf,'^.\{-}/\(.*\)$','\1','') -" call Decho("dirname<".dirname.">") -" call Decho("dirpath<".dirpath.">") - if !isdirectory(dirname) -" call Decho("making <".dirname.">") - if exists("g:vimball_mkdir") - call system(g:vimball_mkdir." ".shellescape(dirname)) - else - call mkdir(dirname) - endif - call s:RecordInVar(home,"rmdir('".dirname."')") - endif - endwhile - endif - call s:ChgDir(home) - - " grab specified qty of lines and place into "a" buffer - " (skip over path/filename and qty-lines) - let linenr = linenr + 2 - let lastline = linenr + fsize - 1 -" call Decho("exe ".linenr.",".lastline."yank a") - " no point in handling a zero-length file - if lastline >= linenr - exe "silent ".linenr.",".lastline."yank a" - - " copy "a" buffer into tab -" call Decho('copy "a buffer into tab#'.vbtabnr) - exe "tabn ".vbtabnr - setlocal ma - sil! %d - silent put a - 1 - sil! d - - " write tab to file - if a:really - let fnamepath= home."/".fname -" call Decho("exe w! ".fnameescape(fnamepath)) - if fenc != "" - exe "silent w! ++enc=".fnameescape(fenc)." ".fnameescape(fnamepath) - else - exe "silent w! ".fnameescape(fnamepath) - endif - echo "wrote ".fnameescape(fnamepath) - call s:RecordInVar(home,"call delete('".fnamepath."')") - endif - - " return to tab with vimball -" call Decho("exe tabn ".curtabnr) - exe "tabn ".curtabnr - - " set up help if it's a doc/*.txt file -" call Decho("didhelp<".didhelp."> fname<".fname.">") - if a:really && didhelp == "" && fname =~ 'doc/[^/]\+\.\(txt\|..x\)$' - let didhelp= substitute(fname,'^\(.*\") - endif - endif - - " update for next file -" call Decho("update linenr= [linenr=".linenr."] + [fsize=".fsize."] = ".(linenr+fsize)) - let linenr= linenr + fsize - endwhile - - " set up help -" call Decho("about to set up help: didhelp<".didhelp.">") - if didhelp != "" - let htpath= home."/".didhelp -" call Decho("exe helptags ".htpath) - exe "helptags ".fnameescape(htpath) - echo "did helptags" - endif - - " make sure a "Press ENTER..." prompt appears to keep the messages showing! - while filecnt <= &ch - echomsg " " - let filecnt= filecnt + 1 - endwhile - - " record actions in <.VimballRecord> - call s:RecordInFile(home) - - " restore events, delete tab and buffer - exe "sil! tabn ".vbtabnr - setlocal nomod bh=wipe - exe "sil! tabn ".curtabnr - exe "sil! tabc! ".vbtabnr - call vimball#RestoreSettings() - call s:ChgDir(curdir) - -" call Dret("vimball#Vimball") -endfun - -" --------------------------------------------------------------------- -" vimball#RmVimball: remove any files, remove any directories made by any {{{2 -" previous vimball extraction based on a file of the current -" name. -" Usage: RmVimball (assume current file is a vimball; remove) -" RmVimball vimballname -fun! vimball#RmVimball(...) -" call Dfunc("vimball#RmVimball() a:0=".a:0) - if exists("g:vimball_norecord") -" call Dret("vimball#RmVimball : (g:vimball_norecord)") - return - endif - - if a:0 == 0 - let curfile= expand("%:tr") -" call Decho("case a:0=0: curfile<".curfile."> (used expand(%:tr))") - else - if a:1 =~ '[\/]' - call vimball#ShowMesg(s:USAGE,"RmVimball vimballname [path]") -" call Dret("vimball#RmVimball : suspect a:1<".a:1.">") - return - endif - let curfile= a:1 -" call Decho("case a:0=".a:0.": curfile<".curfile.">") - endif - if curfile =~ '\.vmb$' - let curfile= substitute(curfile,'\.vmb','','') - elseif curfile =~ '\.vba$' - let curfile= substitute(curfile,'\.vba','','') - endif - if a:0 >= 2 - let home= expand(a:2) - else - let home= vimball#VimballHome() - endif - let curdir = getcwd() -" call Decho("home <".home.">") -" call Decho("curfile<".curfile.">") -" call Decho("curdir <".curdir.">") - - call s:ChgDir(home) - if filereadable(".VimballRecord") -" call Decho(".VimballRecord is readable") -" call Decho("curfile<".curfile.">") - keepalt keepjumps 1split - sil! keepalt keepjumps e .VimballRecord - let keepsrch= @/ -" call Decho('search for ^\M'.curfile.'.\m: ') -" call Decho('search for ^\M'.curfile.'.\m{vba|vmb}: ') -" call Decho('search for ^\M'.curfile.'\m[-0-9.]*\.{vba|vmb}: ') - if search('^\M'.curfile."\m: ".'cw') - let foundit= 1 - elseif search('^\M'.curfile.".\mvmb: ",'cw') - let foundit= 2 - elseif search('^\M'.curfile.'\m[-0-9.]*\.vmb: ','cw') - let foundit= 2 - elseif search('^\M'.curfile.".\mvba: ",'cw') - let foundit= 1 - elseif search('^\M'.curfile.'\m[-0-9.]*\.vba: ','cw') - let foundit= 1 - else - let foundit = 0 - endif - if foundit - if foundit == 1 - let exestring = substitute(getline("."),'^\M'.curfile.'\m\S\{-}\.vba: ','','') - else - let exestring = substitute(getline("."),'^\M'.curfile.'\m\S\{-}\.vmb: ','','') - endif - let s:VBRstring= substitute(exestring,'call delete(','','g') - let s:VBRstring= substitute(s:VBRstring,"[')]",'','g') -" call Decho("exe ".exestring) - sil! keepalt keepjumps exe exestring - sil! keepalt keepjumps d - let exestring= strlen(substitute(exestring,'call delete(.\{-})|\=',"D","g")) -" call Decho("exestring<".exestring.">") - echomsg "removed ".exestring." files" - else - let s:VBRstring= '' - let curfile = substitute(curfile,'\.vmb','','') -" call Decho("unable to find <".curfile."> in .VimballRecord") - if !exists("s:ok_unablefind") - call vimball#ShowMesg(s:WARNING,"(RmVimball) unable to find <".curfile."> in .VimballRecord") - endif - endif - sil! keepalt keepjumps g/^\s*$/d - sil! keepalt keepjumps wq! - let @/= keepsrch - endif - call s:ChgDir(curdir) - -" call Dret("vimball#RmVimball") -endfun - -" --------------------------------------------------------------------- -" vimball#Decompress: attempts to automatically decompress vimballs {{{2 -fun! vimball#Decompress(fname,...) -" call Dfunc("Decompress(fname<".a:fname.">) a:0=".a:0) - - " decompression: - if expand("%") =~ '.*\.gz' && executable("gunzip") - " handle *.gz with gunzip - silent exe "!gunzip ".shellescape(a:fname) - if v:shell_error != 0 - call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) gunzip may have failed with <".a:fname.">") - endif - let fname= substitute(a:fname,'\.gz$','','') - exe "e ".escape(fname,' \') - if a:0 == 0| call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)") | endif - - elseif expand("%") =~ '.*\.gz' && executable("gzip") - " handle *.gz with gzip -d - silent exe "!gzip -d ".shellescape(a:fname) - if v:shell_error != 0 - call vimball#ShowMesg(s:WARNING,'(vimball#Decompress) "gzip -d" may have failed with <'.a:fname.">") - endif - let fname= substitute(a:fname,'\.gz$','','') - exe "e ".escape(fname,' \') - if a:0 == 0| call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)") | endif - - elseif expand("%") =~ '.*\.bz2' && executable("bunzip2") - " handle *.bz2 with bunzip2 - silent exe "!bunzip2 ".shellescape(a:fname) - if v:shell_error != 0 - call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) bunzip2 may have failed with <".a:fname.">") - endif - let fname= substitute(a:fname,'\.bz2$','','') - exe "e ".escape(fname,' \') - if a:0 == 0| call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)") | endif - - elseif expand("%") =~ '.*\.bz2' && executable("bzip2") - " handle *.bz2 with bzip2 -d - silent exe "!bzip2 -d ".shellescape(a:fname) - if v:shell_error != 0 - call vimball#ShowMesg(s:WARNING,'(vimball#Decompress) "bzip2 -d" may have failed with <'.a:fname.">") - endif - let fname= substitute(a:fname,'\.bz2$','','') - exe "e ".escape(fname,' \') - if a:0 == 0| call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)") | endif - - elseif expand("%") =~ '.*\.zip' && executable("unzip") - " handle *.zip with unzip - silent exe "!unzip ".shellescape(a:fname) - if v:shell_error != 0 - call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) unzip may have failed with <".a:fname.">") - endif - let fname= substitute(a:fname,'\.zip$','','') - exe "e ".escape(fname,' \') - if a:0 == 0| call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)") | endif - endif - - if a:0 == 0| setlocal noma bt=nofile fmr=[[[,]]] fdm=marker | endif - -" call Dret("Decompress") -endfun - -" --------------------------------------------------------------------- -" vimball#ShowMesg: {{{2 -fun! vimball#ShowMesg(level,msg) -" call Dfunc("vimball#ShowMesg(level=".a:level." msg<".a:msg.">)") - - let rulerkeep = &ruler - let showcmdkeep = &showcmd - set noruler noshowcmd - redraw! - - if &fo =~# '[ta]' - echomsg "***vimball*** ".a:msg - else - if a:level == s:WARNING || a:level == s:USAGE - echohl WarningMsg - elseif a:level == s:ERROR - echohl Error - endif - echomsg "***vimball*** ".a:msg - echohl None - endif - - if a:level != s:USAGE - call inputsave()|let ok= input("Press to continue")|call inputrestore() - endif - - let &ruler = rulerkeep - let &showcmd = showcmdkeep - -" call Dret("vimball#ShowMesg") -endfun -" ===================================================================== -" s:ChgDir: change directory (in spite of Windoze) {{{2 -fun! s:ChgDir(newdir) -" call Dfunc("ChgDir(newdir<".a:newdir.">)") - if (has("win32") || has("win95") || has("win64") || has("win16")) - try - exe 'silent cd '.fnameescape(substitute(a:newdir,'/','\\','g')) - catch /^Vim\%((\a\+)\)\=:E/ - call mkdir(fnameescape(substitute(a:newdir,'/','\\','g'))) - exe 'silent cd '.fnameescape(substitute(a:newdir,'/','\\','g')) - endtry - else - try - exe 'silent cd '.fnameescape(a:newdir) - catch /^Vim\%((\a\+)\)\=:E/ - call mkdir(fnameescape(a:newdir)) - exe 'silent cd '.fnameescape(a:newdir) - endtry - endif -" call Dret("ChgDir : curdir<".getcwd().">") -endfun - -" --------------------------------------------------------------------- -" s:RecordInVar: record a un-vimball command in the .VimballRecord file {{{2 -fun! s:RecordInVar(home,cmd) -" call Dfunc("RecordInVar(home<".a:home."> cmd<".a:cmd.">)") - if a:cmd =~ '^rmdir' -" if !exists("s:recorddir") -" let s:recorddir= substitute(a:cmd,'^rmdir',"call s:Rmdir",'') -" else -" let s:recorddir= s:recorddir."|".substitute(a:cmd,'^rmdir',"call s:Rmdir",'') -" endif - elseif !exists("s:recordfile") - let s:recordfile= a:cmd - else - let s:recordfile= s:recordfile."|".a:cmd - endif -" call Dret("RecordInVar : s:recordfile<".(exists("s:recordfile")? s:recordfile : "")."> s:recorddir<".(exists("s:recorddir")? s:recorddir : "").">") -endfun - -" --------------------------------------------------------------------- -" s:RecordInFile: {{{2 -fun! s:RecordInFile(home) -" call Dfunc("s:RecordInFile()") - if exists("g:vimball_norecord") -" call Dret("s:RecordInFile : g:vimball_norecord") - return - endif - - if exists("s:recordfile") || exists("s:recorddir") - let curdir= getcwd() - call s:ChgDir(a:home) - keepalt keepjumps 1split - - let cmd= expand("%:tr").": " -" call Decho("cmd<".cmd.">") - - sil! keepalt keepjumps e .VimballRecord - setlocal ma - $ - if exists("s:recordfile") && exists("s:recorddir") - let cmd= cmd.s:recordfile."|".s:recorddir - elseif exists("s:recorddir") - let cmd= cmd.s:recorddir - elseif exists("s:recordfile") - let cmd= cmd.s:recordfile - else -" call Dret("s:RecordInFile : neither recordfile nor recorddir exist") - return - endif -" call Decho("cmd<".cmd.">") - - " put command into buffer, write .VimballRecord `file - keepalt keepjumps put=cmd - sil! keepalt keepjumps g/^\s*$/d - sil! keepalt keepjumps wq! - call s:ChgDir(curdir) - - if exists("s:recorddir") -" call Decho("unlet s:recorddir<".s:recorddir.">") - unlet s:recorddir - endif - if exists("s:recordfile") -" call Decho("unlet s:recordfile<".s:recordfile.">") - unlet s:recordfile - endif - else -" call Decho("s:record[file|dir] doesn't exist") - endif - -" call Dret("s:RecordInFile") -endfun - -" --------------------------------------------------------------------- -" vimball#VimballHome: determine/get home directory path (usually from rtp) {{{2 -fun! vimball#VimballHome() -" call Dfunc("vimball#VimballHome()") - if exists("g:vimball_home") - let home= g:vimball_home - else - " go to vim plugin home - for home in split(&rtp,',') + [''] - if isdirectory(home) && filewritable(home) | break | endif - let basehome= substitute(home,'[/\\]\.vim$','','') - if isdirectory(basehome) && filewritable(basehome) - let home= basehome."/.vim" - break - endif - endfor - if home == "" - " just pick the first directory - let home= substitute(&rtp,',.*$','','') - endif - if (has("win32") || has("win95") || has("win64") || has("win16")) - let home= substitute(home,'/','\\','g') - endif - endif - " insure that the home directory exists -" call Decho("picked home<".home.">") - if !isdirectory(home) - if exists("g:vimball_mkdir") -" call Decho("home<".home."> isn't a directory -- making it now with g:vimball_mkdir<".g:vimball_mkdir.">") -" call Decho("system(".g:vimball_mkdir." ".shellescape(home).")") - call system(g:vimball_mkdir." ".shellescape(home)) - else -" call Decho("home<".home."> isn't a directory -- making it now with mkdir()") - call mkdir(home) - endif - endif -" call Dret("vimball#VimballHome <".home.">") - return home -endfun - -" --------------------------------------------------------------------- -" vimball#SaveSettings: {{{2 -fun! vimball#SaveSettings() -" call Dfunc("SaveSettings()") - let s:makeep = getpos("'a") - let s:regakeep= @a - if exists("+acd") - let s:acdkeep = &acd - endif - let s:eikeep = &ei - let s:fenkeep = &l:fen - let s:hidkeep = &hidden - let s:ickeep = &ic - let s:lzkeep = &lz - let s:pmkeep = &pm - let s:repkeep = &report - let s:vekeep = &ve - let s:ffkeep = &l:ff - let s:swfkeep = &l:swf - if exists("+acd") - setlocal ei=all ve=all noacd nofen noic report=999 nohid bt= ma lz pm= ff=unix noswf - else - setlocal ei=all ve=all nofen noic report=999 nohid bt= ma lz pm= ff=unix noswf - endif - " vimballs should be in unix format - setlocal ff=unix -" call Dret("SaveSettings") -endfun - -" --------------------------------------------------------------------- -" vimball#RestoreSettings: {{{2 -fun! vimball#RestoreSettings() -" call Dfunc("RestoreSettings()") - let @a = s:regakeep - if exists("+acd") - let &acd = s:acdkeep - endif - let &l:fen = s:fenkeep - let &hidden = s:hidkeep - let &ic = s:ickeep - let &lz = s:lzkeep - let &pm = s:pmkeep - let &report = s:repkeep - let &ve = s:vekeep - let &ei = s:eikeep - let &l:ff = s:ffkeep - if s:makeep[0] != 0 - " restore mark a -" call Decho("restore mark-a: makeep=".string(makeep)) - call setpos("'a",s:makeep) - endif - if exists("+acd") - unlet s:acdkeep - endif - unlet s:regakeep s:eikeep s:fenkeep s:hidkeep s:ickeep s:repkeep s:vekeep s:makeep s:lzkeep s:pmkeep s:ffkeep -" call Dret("RestoreSettings") -endfun - -let &cpo = s:keepcpo -unlet s:keepcpo - -" --------------------------------------------------------------------- -" Modelines: {{{1 -" vim: fdm=marker diff --git a/runtime/pack/dist/opt/vimball/doc/vimball.txt b/runtime/pack/dist/opt/vimball/doc/vimball.txt deleted file mode 100644 index 602fe85954..0000000000 --- a/runtime/pack/dist/opt/vimball/doc/vimball.txt +++ /dev/null @@ -1,273 +0,0 @@ -*vimball.txt* For Vim version 7.4. Last change: 2012 Jan 17 - - ---------------- - Vimball Archiver - ---------------- - -Author: Charles E. Campbell, Jr. - (remove NOSPAM from Campbell's email first) -Copyright: (c) 2004-2012 by Charles E. Campbell, Jr. *Vimball-copyright* - The VIM LICENSE (see |copyright|) applies to the files in this - package, including vimballPlugin.vim, vimball.vim, and pi_vimball.txt. - except use "vimball" instead of "VIM". Like anything else that's free, - vimball.vim and its associated files are provided *as is* and comes with - no warranty of any kind, either expressed or implied. No guarantees - of merchantability. No guarantees of suitability for any purpose. By - using this plugin, you agree that in no event will the copyright - holder be liable for any damages resulting from the use of this - software. Use at your own risk! - -============================================================================== -1. Contents *vba* *vimball* *vimball-contents* - - 1. Contents......................................: |vimball-contents| - 2. Vimball Introduction..........................: |vimball-intro| - 3. Vimball Manual................................: |vimball-manual| - MkVimball.....................................: |:MkVimball| - UseVimball....................................: |:UseVimball| - RmVimball.....................................: |:RmVimball| - 4. Vimball History...............................: |vimball-history| - - -============================================================================== -2. Vimball Introduction *vimball-intro* - - Vimball is intended to make life simpler for users of plugins. All - a user needs to do with a vimball is: > - vim someplugin.vba - :so % - :q -< and the plugin and all its components will be installed into their - appropriate directories. Note that one doesn't need to be in any - particular directory when one does this. Plus, any help for the - plugin will also be automatically installed. - - If a user has decided to use the AsNeeded plugin, vimball is smart - enough to put scripts nominally intended for .vim/plugin/ into - .vim/AsNeeded/ instead. - - Removing a plugin that was installed with vimball is really easy: > - vim - :RmVimball someplugin -< This operation is not at all easy for zips and tarballs, for example. - - Vimball examines the user's |'runtimepath'| to determine where to put - the scripts. The first directory mentioned on the runtimepath is - usually used if possible. Use > - :echo &rtp -< to see that directory. - - -============================================================================== -3. Vimball Manual *vimball-manual* - -MAKING A VIMBALL *:MkVimball* - :[range]MkVimball[!] filename [path] - - The range is composed of lines holding paths to files to be included - in your new vimball, omitting the portion of the paths that is - normally specified by the runtimepath (|'rtp'|). As an example: > - plugin/something.vim - doc/something.txt -< using > - :[range]MkVimball filename -< - on this range of lines will create a file called "filename.vba" which - can be used by Vimball.vim to re-create these files. If the - "filename.vba" file already exists, then MkVimball will issue a - warning and not create the file. Note that these paths are relative - to your .vim (vimfiles) directory, and the files should be in that - directory. The vimball plugin normally uses the first |'runtimepath'| - directory that exists as a prefix; don't use absolute paths, unless - the user has specified such a path. - - If you use the exclamation point (!), then MkVimball will create the - "filename.vba" file, overwriting it if it already exists. This - behavior resembles that for |:w|. - - If you wish to force slashes into the filename, that can also be done - by using the exclamation mark (ie. :MkVimball! path/filename). - - The tip at https://vim.wikia.com/wiki/Using_VimBall_with_%27Make%27 - has a good idea on how to automate the production of vimballs using - make. - - -MAKING DIRECTORIES VIA VIMBALLS *g:vimball_mkdir* - - First, the |mkdir()| command is tried (not all systems support it). - - If it doesn't exist, then if g:vimball_mkdir doesn't exist, it is set - as follows: > - |g:netrw_local_mkdir|, if it exists - "mkdir" , if it is executable - "makedir" , if it is executable - Otherwise , it is undefined. -< One may explicitly specify the directory making command using - g:vimball_mkdir. This command is used to make directories that - are needed as indicated by the vimball. - - -CONTROLLING THE VIMBALL EXTRACTION DIRECTORY *g:vimball_home* - - You may override the use of the |'runtimepath'| by specifying a - variable, g:vimball_home. - - *vimball-extract* - vim filename.vba - - Simply editing a Vimball will cause Vimball.vim to tell the user to - source the file to extract its contents. - - Extraction will only proceed if the first line of a putative vimball - file holds the "Vimball Archiver by Charles E. Campbell, Jr., Ph.D." - line. - -LISTING FILES IN A VIMBALL *:VimballList* - - :VimballList - - This command will tell Vimball to list the files in the archive, along - with their lengths in lines. - -MANUALLY INVOKING VIMBALL EXTRACTION *:UseVimball* - - :UseVimball [path] - - This command is contained within the vimball itself; it invokes the - vimball#Vimball() routine which is responsible for unpacking the - vimball. One may choose to execute it by hand instead of sourcing - the vimball; one may also choose to specify a path for the - installation, thereby overriding the automatic choice of the first - existing directory on the |'runtimepath'|. - -REMOVING A VIMBALL *:RmVimball* - - :RmVimball vimballfile [path] - - This command removes all files generated by the specified vimball - (but not any directories it may have made). One may choose a path - for de-installation, too (see |'runtimepath'|); otherwise, the - default is the first existing directory on the |'runtimepath'|. - To implement this, a file (.VimballRecord) is made in that directory - containing a record of what files need to be removed for all vimballs - used thus far. - -PREVENTING LOADING - - If for some reason you don't want to be able to extract plugins - using vimballs: you may prevent the loading of vimball.vim by - putting the following two variables in your <.vimrc>: > - - let g:loaded_vimballPlugin= 1 - let g:loaded_vimball = 1 -< -WINDOWS *vimball-windows* - - Many vimball files are compressed with gzip. Windows, unfortunately, - does not come provided with a tool to decompress gzip'ped files. - Fortunately, there are a number of tools available for Windows users - to un-gzip files: -> - Item Tool/Suite Free Website - ---- ---------- ---- ------- - 7zip tool y https://www.7-zip.org/ - Winzip tool n https://www.winzip.com/downwz.htm - unxutils suite y https://unxutils.sourceforge.net/ - cygwin suite y https://www.cygwin.com/ - GnuWin32 suite y https://gnuwin32.sourceforge.net/ - MinGW suite y https://www.mingw.org/ -< - -============================================================================== -4. Vimball History *vimball-history* {{{1 - - 34 : Sep 22, 2011 * "UseVimball path" now supports a non-full path by - prepending the current directory to it. - 33 : Apr 02, 2011 * Gave priority to *.vmb over *.vba - * Changed silent! to sil! (shorter) - * Safed |'swf'| setting (during vimball extraction, - its now turned off) - 32 : May 19, 2010 * (Christian Brabandt) :so someplugin.vba and - :so someplugin.vba.gz (and the other supported - compression types) now works - * (Jan Steffens) added support for xz compression - * fenc extraction was erroneously picking up the - end of the line number when no file encoding - was present. Fixed. - * By request, beginning the switchover from the vba - extension to vmb. Currently both are supported; - MkVimball, however, now will create *.vmb files. - Feb 11, 2011 * motoyakurotsu reported an error with vimball's - handling of zero-length files - 30 : Dec 08, 2008 * fnameescape() inserted to protect error - messaging using corrupted filenames from - causing problems - * RmVimball supports filenames that would - otherwise be considered to have "magic" - characters (ie. Abc[1].vba) - Feb 18, 2009 * s:Escape(), g:vimball_shq, and g:netrw_shq - removed (shellescape() used directly) - Oct 05, 2009 * (Nikolai Weibull) suggested that MkVimball - be allowed to use slashes in the filename. - 26 : May 27, 2008 * g:vimball_mkdir usage installed. Makes the - $HOME/.vim (or $HOME\vimfiles) directory if - necessary. - May 30, 2008 * (tnx to Bill McCarthy) found and fixed a bug: - vimball wasn't updating plugins to AsNeeded/ - when it should - 25 : Mar 24, 2008 * changed vimball#Vimball() to recognize doc/*.??x - files as help files, too. - Apr 18, 2008 * RmVimball command is now protected by saving and - restoring settings -- in particular, acd was - causing problems as reported by Zhang Shuhan - 24 : Nov 15, 2007 * g:vimball_path_escape used by s:Path() to - prevent certain characters from causing trouble - (defunct: |fnameescape()| and |shellescape()| - now used instead) - 22 : Mar 21, 2007 * uses setlocal instead of set during BufEnter - 21 : Nov 27, 2006 * (tnx to Bill McCarthy) vimball had a header - handling problem and it now changes \s to /s - 20 : Nov 20, 2006 * substitute() calls have all had the 'e' flag - removed. - 18 : Aug 01, 2006 * vimballs now use folding to easily display their - contents. - * if a user has AsNeeded/somefile, then vimball - will extract plugin/somefile to the AsNeeded/ - directory - 17 : Jun 28, 2006 * changes all \s to /s internally for Windows - 16 : Jun 15, 2006 * A. Mechelynck's idea to allow users to specify - installation root paths implemented for - UseVimball, MkVimball, and RmVimball. - * RmVimball implemented - 15 : Jun 13, 2006 * bugfix - 14 : May 26, 2006 * bugfixes - 13 : May 01, 2006 * exists("&acd") used to determine if the acd - option exists - 12 : May 01, 2006 * bugfix - the |'acd'| option is not always defined - 11 : Apr 27, 2006 * VimballList would create missing subdirectories that - the vimball specified were needed. Fixed. - 10 : Apr 27, 2006 * moved all setting saving/restoration to a pair of - functions. Included some more settings in them - which frequently cause trouble. - 9 : Apr 26, 2006 * various changes to support Windows' predilection - for backslashes and spaces in file and directory - names. - 7 : Apr 25, 2006 * bypasses foldenable - * uses more exe and less norm! (:yank :put etc) - * does better at insuring a "Press ENTER" prompt - appears to keep its messages visible - 4 : Mar 31, 2006 * BufReadPost seems to fire twice; BufReadEnter - only fires once, so the "Source this file..." - message is now issued only once. - 3 : Mar 20, 2006 * removed query, now requires sourcing to be - extracted (:so %). Message to that effect - included. - * :VimballList now shows files that would be - extracted. - 2 : Mar 20, 2006 * query, :UseVimball included - 1 : Mar 20, 2006 * initial release - - -============================================================================== -vim:tw=78:ts=8:ft=help:fdm=marker diff --git a/runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim b/runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim deleted file mode 100644 index d7473a0296..0000000000 --- a/runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim +++ /dev/null @@ -1,43 +0,0 @@ -" vimballPlugin : construct a file containing both paths and files -" Author: Charles E. Campbell -" Copyright: (c) 2004-2014 by Charles E. Campbell -" The VIM LICENSE applies to Vimball.vim, and Vimball.txt -" (see |copyright|) except use "Vimball" instead of "Vim". -" No warranty, express or implied. -" *** *** Use At-Your-Own-Risk! *** *** -" -" (Rom 2:1 WEB) Therefore you are without excuse, O man, whoever you are who -" judge. For in that which you judge another, you condemn yourself. For -" you who judge practice the same things. -" GetLatestVimScripts: 1502 1 :AutoInstall: vimball.vim - -" --------------------------------------------------------------------- -" Load Once: {{{1 -if &cp || exists("g:loaded_vimballPlugin") - finish -endif -let g:loaded_vimballPlugin = "v37" -let s:keepcpo = &cpo -set cpo&vim - -" ------------------------------------------------------------------------------ -" Public Interface: {{{1 -com! -range -complete=file -nargs=+ -bang MkVimball call vimball#MkVimball(,,0,) -com! -nargs=? -complete=dir UseVimball call vimball#Vimball(1,) -com! -nargs=0 VimballList call vimball#Vimball(0) -com! -nargs=* -complete=dir RmVimball call vimball#SaveSettings()|call vimball#RmVimball()|call vimball#RestoreSettings() -augroup Vimball - au! - au BufEnter *.vba,*.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)")|endif - au SourceCmd *.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz let s:origfile=expand("%")|if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if s:origfile!=expand("")|close|endif - au SourceCmd *.vba if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif - au BufEnter *.vmb,*.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)")|endif - au SourceCmd *.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz let s:origfile=expand("%")|if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if s:origfile!=expand("")|close|endif - au SourceCmd *.vmb if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif -augroup END - -" ===================================================================== -" Restoration And Modelines: {{{1 -" vim: fdm=marker -let &cpo= s:keepcpo -unlet s:keepcpo -- cgit From e3f36377c156749bbdafc46d8a8cd017f378b4b5 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 23 Apr 2023 15:22:55 +0200 Subject: vim-patch:71badf9547e8 (#23285) Update runtime files https://github.com/vim/vim/commit/71badf9547e8f89571b9a095183671cbb333d528 Co-authored-by: Bram Moolenaar --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index d653f71281..2c3f61c9d4 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -910,7 +910,7 @@ func s:InstallCommands() command Program call s:GotoProgram() command Source call s:GotoSourcewinOrCreateIt() command Asm call s:GotoAsmwinOrCreateIt() - command Winbar call s:InstallWinbar() + command Winbar call s:InstallWinbar(1) let map = 1 if exists('g:termdebug_config') @@ -931,14 +931,7 @@ func s:InstallCommands() endif if has('menu') && &mouse != '' - " install the window toolbar by default, can be disabled in the config - let winbar = 1 - if exists('g:termdebug_config') - let winbar = get(g:termdebug_config, 'winbar', 1) - endif - if winbar - call s:InstallWinbar() - endif + call s:InstallWinbar(0) let popup = 1 if exists('g:termdebug_config') @@ -963,7 +956,7 @@ endfunc " let s:winbar_winids = [] " Install the window toolbar in the current window. -func s:InstallWinbar() +func s:InstallWinbar(force) " if has('menu') && &mouse != '' " nnoremenu WinBar.Step :Step " nnoremenu WinBar.Next :Over @@ -1370,7 +1363,7 @@ func s:GotoSourcewinOrCreateIt() if !win_gotoid(s:sourcewin) new let s:sourcewin = win_getid(winnr()) - call s:InstallWinbar() + call s:InstallWinbar(0) endif endfunc @@ -1493,7 +1486,7 @@ func s:HandleCursor(msg) " TODO: find existing window exe 'split ' . fnameescape(fname) let s:sourcewin = win_getid(winnr()) - call s:InstallWinbar() + call s:InstallWinbar(0) else exe 'edit ' . fnameescape(fname) endif -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 2c3f61c9d4..43c3d7541f 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1328,11 +1328,11 @@ function! s:OpenHoverPreview(lines, filetype) abort \ }) if a:filetype isnot v:null - call nvim_win_set_option(float_win_id, 'filetype', a:filetype) + call nvim_set_option_value('filetype', a:filetype, { 'win' : float_win_id }) endif - call nvim_buf_set_option(buf, 'modified', v:false) - call nvim_buf_set_option(buf, 'modifiable', v:false) + call nvim_set_option_value('modified', v:false, { 'buf' : buf }) + call nvim_set_option_value('modifiable', v:false, { 'buf' : buf }) " Unlike preview window, :pclose does not close window. Instead, close " hover window automatically when cursor is moved. -- cgit From 57fda7688b815f1d99e645d371a06332948ac197 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 24 Jun 2023 22:14:57 +0800 Subject: vim-patch:9.0.1659: Termdebug: default highlight cleared if changing colorscheme (#24139) Problem: Termdebug: default highlight cleared when changing colorscheme. Solution: Use a ColorScheme autocommand. (Christian Brabandt, closes vim/vim#12566, closes vim/vim#12555) https://github.com/vim/vim/commit/279de0cd1f58ea520826a3dd1c5562a71157b23b Co-authored-by: Christian Brabandt --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 43c3d7541f..7140c275e6 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: 2022 Nov 10 +" Last Change: 2023 Jun 24 " " WORK IN PROGRESS - The basics works stable, more to come " Note: In general you need at least GDB 7.12 because this provides the @@ -87,6 +87,8 @@ func s:Breakpoint2SignNumber(id, subid) return s:break_id + a:id * 1000 + a:subid endfunction +" Define or adjust the default highlighting, using background "new". +" When the 'background' option is set then "old" has the old value. func s:Highlight(init, old, new) let default = a:init ? 'default ' : '' if a:new ==# 'light' && a:old !=# 'light' @@ -96,9 +98,21 @@ func s:Highlight(init, old, new) endif endfunc -call s:Highlight(1, '', &background) -hi default debugBreakpoint term=reverse ctermbg=red guibg=red -hi default debugBreakpointDisabled term=reverse ctermbg=gray guibg=gray +" Define the default highlighting, using the current 'background' value. +func s:InitHighlight() + call s:Highlight(1, '', &background) + hi default debugBreakpoint term=reverse ctermbg=red guibg=red + hi default debugBreakpointDisabled term=reverse ctermbg=gray guibg=gray +endfunc + +" Setup an autocommand to redefine the default highlight when the colorscheme +" is changed. +func s:InitAutocmd() + augroup TermDebug + autocmd! + autocmd ColorScheme * call s:InitHighlight() + augroup END +endfunc " Get the command to execute the debugger as a list, defaults to ["gdb"]. func s:GetCommand() @@ -1664,5 +1678,8 @@ func s:BufUnloaded() endfor endfunc +call s:InitHighlight() +call s:InitAutocmd() + let &cpo = s:keepcpo unlet s:keepcpo -- cgit From e59cf3b3a9ee0f9e9b4d2e01059dbdf185eb5685 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 25 Jun 2023 08:12:41 +0800 Subject: vim-patch:9.0.1663: Termdebug on MS-Windows: some file names are not recognized (#24145) Problem: Termdebug on MS-Windows: some file names are not recognized. Solution: Do not always change \t and \n. (Christian Brabandt, closes vim/vim#12565, closes vim/vim#12560, closes vim/vim#12550) https://github.com/vim/vim/commit/c9a4a8ab28da2b11856a3f08ccba2e91f46b85c3 Co-authored-by: Christian Brabandt --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 7140c275e6..d4b49e85c8 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -640,7 +640,7 @@ func s:GdbOutCallback(job_id, msgs, event) for msg in a:msgs if msg =~ '^\^error,msg=' if exists('s:evalexpr') - \ && s:DecodeMessage(msg[11:]) + \ && s:DecodeMessage(msg[11:], v:false) \ =~ 'A syntax error in expression, near\|No symbol .* in current context' " Silently drop evaluation errors. call remove(a:msgs, index) @@ -648,7 +648,7 @@ func s:GdbOutCallback(job_id, msgs, event) continue endif elseif msg[0] == '~' - call add(lines, s:DecodeMessage(msg[1:])) + call add(lines, s:DecodeMessage(msg[1:], v:false)) call remove(a:msgs, index) continue endif @@ -670,21 +670,20 @@ func s:GdbOutCallback(job_id, msgs, event) call s:CommOutput(a:job_id, a:msgs, a:event) endfunc -" Decode a message from gdb. quotedText starts with a ", return the text up +" Decode a message from gdb. "quotedText" starts with a ", return the text up " to the next ", unescaping characters: -" - remove line breaks -" - change \\t to \t +" - remove line breaks (unless "literal" is v:true) +" - change \\t to \t (unless "literal" is v:true) " - change \0xhh to \xhh (disabled for now) " - change \ooo to octal " - change \\ to \ -func s:DecodeMessage(quotedText) +func s:DecodeMessage(quotedText, literal) if a:quotedText[0] != '"' echoerr 'DecodeMessage(): missing quote in ' . a:quotedText return endif - return a:quotedText - \ ->substitute('^"\|".*\|\\n', '', 'g') - \ ->substitute('\\t', "\t", 'g') + let msg = a:quotedText + \ ->substitute('^"\|".*', '', 'g') " multi-byte characters arrive in octal form " NULL-values must be kept encoded as those break the string otherwise \ ->substitute('\\000', s:NullRepl, 'g') @@ -696,6 +695,13 @@ func s:DecodeMessage(quotedText) " \ ->substitute('\\0x00', s:NullRepl, 'g') \ ->substitute('\\\\', '\', 'g') \ ->substitute(s:NullRepl, '\\000', 'g') + if !a:literal + return msg + \ ->substitute('\\t', "\t", 'g') + \ ->substitute('\\n', '', 'g') + else + return msg + endif endfunc const s:NullRepl = 'XXXNULLXXX' @@ -704,7 +710,7 @@ func s:GetFullname(msg) if a:msg !~ 'fullname' return '' endif - let name = s:DecodeMessage(substitute(a:msg, '.*fullname=', '', '')) + let name = s:DecodeMessage(substitute(a:msg, '.*fullname=', '', ''), v:true) if has('win32') && name =~ ':\\\\' " sometimes the name arrives double-escaped let name = substitute(name, '\\\\', '\\', 'g') @@ -717,11 +723,11 @@ func s:GetAsmAddr(msg) if a:msg !~ 'addr=' return '' endif - let addr = s:DecodeMessage(substitute(a:msg, '.*addr=', '', '')) + let addr = s:DecodeMessage(substitute(a:msg, '.*addr=', '', ''), v:false) return addr endfunc -function s:EndTermDebug(job_id, exit_code, event) +func s:EndTermDebug(job_id, exit_code, event) let s:running = v:false if s:starting return -- cgit From 421c66f741bf4ed4de6bf15df19160df0f90db4b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 29 Jun 2023 07:04:46 +0800 Subject: vim-patch:9.0.1671: Termdebug: error with more than 99 breakpoints (#24194) Problem: Termdebug: error with more than 99 breakpoints. Solution: Use a different sign for breakpoint 100 and over. (closes vim/vim#12589, closes vim/vim#12588) https://github.com/vim/vim/commit/e7d9ca2b3bf99b0b759be8952e02c77110a354c1 Co-authored-by: skywind3000 --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index d4b49e85c8..e8b78b3f5f 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1543,8 +1543,18 @@ func s:CreateBreakpoint(id, subid, enabled) else let hiName = "debugBreakpoint" endif + let label = '' + if exists('g:termdebug_config') + let label = get(g:termdebug_config, 'sign', '') + endif + if label == '' + let label = substitute(nr, '\..*', '', '') + if strlen(label) > 2 + let label = strpart(label, strlen(label) - 2) + endif + endif call sign_define('debugBreakpoint' .. nr, - \ #{text: substitute(nr, '\..*', '', ''), + \ #{text: strpart(label, 0, 2), \ texthl: hiName}) endif endfunc -- cgit From 1cf942204f98395d8909e5499dda462af0cc12f7 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 9 Aug 2023 23:44:16 +0200 Subject: vim-patch:bd76c89e31ac (#24630) update matchit (vim/vim#12611) https://github.com/vim/vim/commit/bd76c89e31ac9d9efd00ec8dda9c32436415dbbb Co-authored-by: Christian Brabandt --- runtime/pack/dist/opt/matchit/autoload/matchit.vim | 17 ++-- runtime/pack/dist/opt/matchit/doc/matchit.txt | 26 ++++- runtime/pack/dist/opt/matchit/plugin/matchit.vim | 105 +++++++++++++-------- 3 files changed, 98 insertions(+), 50 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/matchit/autoload/matchit.vim b/runtime/pack/dist/opt/matchit/autoload/matchit.vim index eafb7c0551..dc2aba696d 100644 --- a/runtime/pack/dist/opt/matchit/autoload/matchit.vim +++ b/runtime/pack/dist/opt/matchit/autoload/matchit.vim @@ -1,6 +1,6 @@ " matchit.vim: (global plugin) Extended "%" matching " autload script of matchit plugin, see ../plugin/matchit.vim -" Last Change: Jun 10, 2021 +" Last Change: Jan 24, 2022 " Neovim does not support scriptversion if has("vimscript-4") @@ -42,6 +42,10 @@ function s:RestoreOptions() let restore_options = " ve=" .. &ve .. restore_options set ve= endif + if &smartcase + let restore_options = " smartcase " .. restore_options + set nosmartcase + endif return restore_options endfunction @@ -134,9 +138,6 @@ function matchit#Match_wrapper(word, forward, mode) range let curcol = match(matchline, regexp) " If there is no match, give up. if curcol == -1 - " Make sure macros abort properly - "exe "norm! \" - call feedkeys("\e", 'tni') return s:CleanUp(restore_options, a:mode, startpos) endif let endcol = matchend(matchline, regexp) @@ -756,15 +757,15 @@ endfun fun! s:ParseSkip(str) let skip = a:str if skip[1] == ":" - if skip[0] == "s" + if skip[0] ==# "s" let skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" .. \ strpart(skip,2) .. "'" - elseif skip[0] == "S" + elseif skip[0] ==# "S" let skip = "synIDattr(synID(line('.'),col('.'),1),'name') !~? '" .. \ strpart(skip,2) .. "'" - elseif skip[0] == "r" + elseif skip[0] ==# "r" let skip = "strpart(getline('.'),0,col('.'))=~'" .. strpart(skip,2) .. "'" - elseif skip[0] == "R" + elseif skip[0] ==# "R" let skip = "strpart(getline('.'),0,col('.'))!~'" .. strpart(skip,2) .. "'" endif endif diff --git a/runtime/pack/dist/opt/matchit/doc/matchit.txt b/runtime/pack/dist/opt/matchit/doc/matchit.txt index 45033ce3f1..5daf9788d6 100644 --- a/runtime/pack/dist/opt/matchit/doc/matchit.txt +++ b/runtime/pack/dist/opt/matchit/doc/matchit.txt @@ -1,10 +1,10 @@ -*matchit.txt* Extended "%" matching +*matchit.txt* Extended "%" matching For instructions on installing this file, type `:help matchit-install` inside Vim. -For Vim version 8.2. Last change: 2021 Dec 24 +For Vim version 9.0. Last change: 2023 June 28 VIM REFERENCE MANUAL by Benji Fisher et al @@ -150,8 +150,7 @@ To use the matchit plugin add this line to your |vimrc|: > The script should start working the next time you start Vim. -To use the matchit plugin after startup, you can use this command (note the -omitted '!'): > +To use the matchit plugin after Vim has started, execute this command: > packadd matchit (Earlier versions of the script did nothing unless a |buffer-variable| named @@ -175,6 +174,22 @@ fail to skip matching groups in comments and strings. If the |filetype| mechanism is turned off, the |b:match_words| variable will probably not be defined automatically. +2.1 Temporarily disable the matchit plugin *matchit-disable* *:MatchDisable* + +To temporarily reset the plugins, that are setup you can run the following +command: > + :MatchDisable + +This will delete all the defined key mappings to the Vim default. +Now the "%" command will work like before loading the plugin |%| + +2.2 Re-enable the matchit plugin *:MatchEnable* + +To re-enable the plugin, after it was disabled, use the following command: > + :MatchEnable + +This will resetup the key mappings. + ============================================================================== 3. Configuration *matchit-configure* @@ -243,6 +258,9 @@ Examples: comment character) you can > :let b:match_skip = 'r:\(^\|[^\\]\)\(\\\\\)*%' < + See the $VIMRUNTIME/ftplugin/vim.vim for an example that uses both + syntax and a regular expression. + ============================================================================== 4. Supporting a New Language *matchit-newlang* *b:match_words* diff --git a/runtime/pack/dist/opt/matchit/plugin/matchit.vim b/runtime/pack/dist/opt/matchit/plugin/matchit.vim index 51ba3a7f51..d6c735d7b4 100644 --- a/runtime/pack/dist/opt/matchit/plugin/matchit.vim +++ b/runtime/pack/dist/opt/matchit/plugin/matchit.vim @@ -1,7 +1,7 @@ " matchit.vim: (global plugin) Extended "%" matching " Maintainer: Christian Brabandt -" Version: 1.18 -" Last Change: 2020 Dec 23 +" Version: 1.19 +" Last Change: 2023, June 28th " Repository: https://github.com/chrisbra/matchit " Previous URL:http://www.vim.org/script.php?script_id=39 " Previous Maintainer: Benji Fisher PhD @@ -46,44 +46,65 @@ let g:loaded_matchit = 1 let s:save_cpo = &cpo set cpo&vim -nnoremap (MatchitNormalForward) :call matchit#Match_wrapper('',1,'n') -nnoremap (MatchitNormalBackward) :call matchit#Match_wrapper('',0,'n') -xnoremap (MatchitVisualForward) :call matchit#Match_wrapper('',1,'v') - \:if col("''") != col("$") \| exe ":normal! m'" \| endifgv`` -xnoremap (MatchitVisualBackward) :call matchit#Match_wrapper('',0,'v')m'gv`` -onoremap (MatchitOperationForward) :call matchit#Match_wrapper('',1,'o') -onoremap (MatchitOperationBackward) :call matchit#Match_wrapper('',0,'o') - -" Analogues of [{ and ]} using matching patterns: -nnoremap (MatchitNormalMultiBackward) :call matchit#MultiMatch("bW", "n") -nnoremap (MatchitNormalMultiForward) :call matchit#MultiMatch("W", "n") -xnoremap (MatchitVisualMultiBackward) :call matchit#MultiMatch("bW", "n")m'gv`` -xnoremap (MatchitVisualMultiForward) :call matchit#MultiMatch("W", "n")m'gv`` -onoremap (MatchitOperationMultiBackward) :call matchit#MultiMatch("bW", "o") -onoremap (MatchitOperationMultiForward) :call matchit#MultiMatch("W", "o") - -" text object: -xmap (MatchitVisualTextObject) (MatchitVisualMultiBackward)o(MatchitVisualMultiForward) - -if !exists("g:no_plugin_maps") - nmap % (MatchitNormalForward) - nmap g% (MatchitNormalBackward) - xmap % (MatchitVisualForward) - xmap g% (MatchitVisualBackward) - omap % (MatchitOperationForward) - omap g% (MatchitOperationBackward) +fun MatchEnable() + nnoremap (MatchitNormalForward) :call matchit#Match_wrapper('',1,'n') + nnoremap (MatchitNormalBackward) :call matchit#Match_wrapper('',0,'n') + xnoremap (MatchitVisualForward) :call matchit#Match_wrapper('',1,'v') + \:if col("''") != col("$") \| exe ":normal! m'" \| endifgv`` + xnoremap (MatchitVisualBackward) :call matchit#Match_wrapper('',0,'v')m'gv`` + onoremap (MatchitOperationForward) :call matchit#Match_wrapper('',1,'o') + onoremap (MatchitOperationBackward) :call matchit#Match_wrapper('',0,'o') " Analogues of [{ and ]} using matching patterns: - nmap [% (MatchitNormalMultiBackward) - nmap ]% (MatchitNormalMultiForward) - xmap [% (MatchitVisualMultiBackward) - xmap ]% (MatchitVisualMultiForward) - omap [% (MatchitOperationMultiBackward) - omap ]% (MatchitOperationMultiForward) - - " Text object - xmap a% (MatchitVisualTextObject) -endif + nnoremap (MatchitNormalMultiBackward) :call matchit#MultiMatch("bW", "n") + nnoremap (MatchitNormalMultiForward) :call matchit#MultiMatch("W", "n") + xnoremap (MatchitVisualMultiBackward) :call matchit#MultiMatch("bW", "n")m'gv`` + xnoremap (MatchitVisualMultiForward) :call matchit#MultiMatch("W", "n")m'gv`` + onoremap (MatchitOperationMultiBackward) :call matchit#MultiMatch("bW", "o") + onoremap (MatchitOperationMultiForward) :call matchit#MultiMatch("W", "o") + + " text object: + xmap (MatchitVisualTextObject) (MatchitVisualMultiBackward)o(MatchitVisualMultiForward) + + if !exists("g:no_plugin_maps") + nmap % (MatchitNormalForward) + nmap g% (MatchitNormalBackward) + xmap % (MatchitVisualForward) + xmap g% (MatchitVisualBackward) + omap % (MatchitOperationForward) + omap g% (MatchitOperationBackward) + + " Analogues of [{ and ]} using matching patterns: + nmap [% (MatchitNormalMultiBackward) + nmap ]% (MatchitNormalMultiForward) + xmap [% (MatchitVisualMultiBackward) + xmap ]% (MatchitVisualMultiForward) + omap [% (MatchitOperationMultiBackward) + omap ]% (MatchitOperationMultiForward) + + " Text object + xmap a% (MatchitVisualTextObject) + endif +endfun + +fun MatchDisable() + " remove all the setup keymappings + nunmap % + nunmap g% + xunmap % + xunmap g% + ounmap % + ounmap g% + + nunmap [% + nunmap ]% + xunmap [% + xunmap ]% + ounmap [% + ounmap ]% + + xunmap a% +endfun " Call this function to turn on debugging information. Every time the main " script is run, buffer variables will be saved. These can be used directly @@ -91,6 +112,14 @@ endif if !exists(":MatchDebug") command! -nargs=0 MatchDebug call matchit#Match_debug() endif +if !exists(":MatchDisable") + command! -nargs=0 MatchDisable :call MatchDisable() +endif +if !exists(":MatchEnable") + command! -nargs=0 MatchEnable :call MatchEnable() +endif + +call MatchEnable() let &cpo = s:save_cpo unlet s:save_cpo -- cgit From 949dd14d8b2acfc8feda7410ed35e28a2d895992 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 21 Aug 2023 09:28:58 +0100 Subject: vim-patch:9f2962141514 Runtime(termdebug): Add support to view local and argument variables closes: 12403 https://github.com/vim/vim/commit/9f29621415146abc046471440515e9e34f3e57a1 Rename the existing "s:running" (#16790) to "s:gdb_running" to not clash with the "s:running" introduced in this patch (which instead relates to whether the debugged program is currently running in gdb). Keep the file `:retab`bed as before. Co-authored-by: laburnumT --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 195 +++++++++++++++++---- 1 file changed, 165 insertions(+), 30 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index e8b78b3f5f..a8480fcc43 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -75,6 +75,7 @@ let s:pc_id = 12 let s:asm_id = 13 let s:break_id = 14 " breakpoint number is added to this let s:stopped = 1 +let s:running = 0 let s:parsing_disasm_msg = 0 let s:asm_lines = [] @@ -151,6 +152,9 @@ func s:StartDebug_internal(dict) let s:ptywin = 0 let s:pid = 0 let s:asmwin = 0 + let s:asmbuf = 0 + let s:varwin = 0 + let s:varbuf = 0 if exists('#User#TermdebugStartPre') doauto User TermdebugStartPre @@ -159,7 +163,7 @@ func s:StartDebug_internal(dict) " Uncomment this line to write logging in "debuglog". " call ch_logfile('debuglog', 'w') - let s:sourcewin = win_getid(winnr()) + let s:sourcewin = win_getid() " Remember the old value of 'signcolumn' for each buffer that it's set in, so " that we can restore the value for all buffers. @@ -207,11 +211,17 @@ func s:StartDebug_internal(dict) endif if s:GetDisasmWindow() - let curwinid = win_getid(winnr()) + let curwinid = win_getid() call s:GotoAsmwinOrCreateIt() call win_gotoid(curwinid) endif + if s:GetVariablesWindow() + let curwinid = win_getid() + call s:GotoVariableswinOrCreateIt() + call win_gotoid(curwinid) + endif + if exists('#User#TermdebugStartPost') doauto User TermdebugStartPost endif @@ -220,11 +230,18 @@ endfunc " Use when debugger didn't start or ended. func s:CloseBuffers() exe 'bwipe! ' . s:ptybuf + if s:asmbuf > 0 + exe 'bwipe! ' . s:asmbuf + endif + if s:varbuf > 0 + exe 'bwipe! ' . s:varbuf + endif + s:running = 0 unlet! s:gdbwin endfunc func s:CheckGdbRunning() - if !s:running + if !s:gdb_running echoerr string(s:GetCommand()[0]) . ' exited unexpectedly' call s:CloseBuffers() return '' @@ -246,7 +263,7 @@ func s:StartDebug_term(dict) let pty_job_info = nvim_get_chan_info(s:pty_job_id) let s:ptybuf = pty_job_info['buffer'] let pty = pty_job_info['pty'] - let s:ptywin = win_getid(winnr()) + let s:ptywin = win_getid() if s:vertical " Assuming the source code window will get a signcolumn, use two more " columns for that, thus one less for the terminal window. @@ -317,11 +334,11 @@ func s:StartDebug_term(dict) call s:CloseBuffers() return endif - let s:running = v:true + let s:gdb_running = v:true let s:starting = v:true let gdb_job_info = nvim_get_chan_info(s:gdb_job_id) let s:gdbbuf = gdb_job_info['buffer'] - let s:gdbwin = win_getid(winnr()) + let s:gdbwin = win_getid() " Wait for the "startupdone" message before sending any commands. let try_count = 0 @@ -409,7 +426,7 @@ func s:StartDebug_prompt(dict) else new endif - let s:gdbwin = win_getid(winnr()) + let s:gdbwin = win_getid() let s:promptbuf = bufnr('') call prompt_setprompt(s:promptbuf, 'gdb> ') set buftype=prompt @@ -476,7 +493,7 @@ func s:StartDebug_prompt(dict) let pty_job_info = nvim_get_chan_info(s:pty_job_id) let s:ptybuf = pty_job_info['buffer'] let pty = pty_job_info['pty'] - let s:ptywin = win_getid(winnr()) + let s:ptywin = win_getid() call s:SendCommand('tty ' . pty) " Since GDB runs in a prompt window, the environment has not been set to @@ -655,7 +672,7 @@ func s:GdbOutCallback(job_id, msgs, event) let index += 1 endfor - let curwinid = win_getid(winnr()) + let curwinid = win_getid() call win_gotoid(s:gdbwin) " Add the output above the current prompt. @@ -728,7 +745,7 @@ func s:GetAsmAddr(msg) endfunc func s:EndTermDebug(job_id, exit_code, event) - let s:running = v:false + let s:gdb_running = v:false if s:starting return endif @@ -737,13 +754,20 @@ func s:EndTermDebug(job_id, exit_code, event) doauto User TermdebugStopPre endif + if s:asmbuf > 0 + exe 'bwipe! ' . s:asmbuf + endif + if s:varbuf > 0 + exe 'bwipe! ' . s:varbuf + endif + let s:running = 0 unlet s:gdbwin call s:EndDebugCommon() endfunc func s:EndDebugCommon() - let curwinid = win_getid(winnr()) + let curwinid = win_getid() if exists('s:ptybuf') && s:ptybuf exe 'bwipe! ' . s:ptybuf @@ -785,7 +809,7 @@ func s:EndPromptDebug(job_id, exit_code, event) doauto User TermdebugStopPre endif - let curwinid = win_getid(winnr()) + let curwinid = win_getid() call win_gotoid(s:gdbwin) close if curwinid != s:gdbwin @@ -813,9 +837,9 @@ endfunc " - CommOutput: ^error,msg="No function contains specified address." func s:HandleDisasmMsg(msg) if a:msg =~ '^\^done' - let curwinid = win_getid(winnr()) + let curwinid = win_getid() if win_gotoid(s:asmwin) - silent normal! gg0"_dG + silent! %delete _ call setline(1, s:asm_lines) set nomodified set filetype=asm @@ -857,6 +881,49 @@ func s:HandleDisasmMsg(msg) endif endfunc +func s:ParseVarinfo(varinfo) + let dict = {} + let nameIdx = matchstrpos(a:varinfo, '{name="\([^"]*\)"') + let dict['name'] = a:varinfo[nameIdx[1] + 7 : nameIdx[2] - 2] + let typeIdx = matchstrpos(a:varinfo, ',type="\([^"]*\)"') + let dict['type'] = a:varinfo[typeIdx[1] + 7 : typeIdx[2] - 2] + let valueIdx = matchstrpos(a:varinfo, ',value="\(.*\)"}') + if valueIdx[1] == -1 + let dict['value'] = 'Complex value' + else + let dict['value'] = a:varinfo[valueIdx[1] + 8 : valueIdx[2] - 3] + endif + return dict +endfunc + +func s:HandleVariablesMsg(msg) + let curwinid = win_getid() + if win_gotoid(s:varwin) + + silent! %delete _ + let spaceBuffer = 20 + call setline(1, 'Type' . + \ repeat(' ', 16) . + \ 'Name' . + \ repeat(' ', 16) . + \ 'Value') + let cnt = 1 + let capture = '{name=".\{-}",\%(arg=".\{-}",\)\{0,1\}type=".\{-}"\%(,value=".\{-}"\)\{0,1\}}' + let varinfo = matchstr(a:msg, capture, 0, cnt) + while varinfo != '' + let vardict = s:ParseVarinfo(varinfo) + call setline(cnt + 1, vardict['type'] . + \ repeat(' ', max([20 - len(vardict['type']), 1])) . + \ vardict['name'] . + \ repeat(' ', max([20 - len(vardict['name']), 1])) . + \ vardict['value']) + let cnt += 1 + let varinfo = matchstr(a:msg, capture, 0, cnt) + endwhile + endif + call win_gotoid(curwinid) +endfunc + func s:CommOutput(job_id, msgs, event) for msg in a:msgs @@ -885,6 +952,8 @@ func s:CommOutput(job_id, msgs, event) elseif msg =~ '^disassemble' let s:parsing_disasm_msg = 1 let s:asm_lines = [] + elseif msg =~ '^\^done,variables=' + call s:HandleVariablesMsg(msg) endif endif endfor @@ -930,6 +999,7 @@ func s:InstallCommands() command Program call s:GotoProgram() command Source call s:GotoSourcewinOrCreateIt() command Asm call s:GotoAsmwinOrCreateIt() + command Var call s:GotoVariableswinOrCreateIt() command Winbar call s:InstallWinbar(1) let map = 1 @@ -962,11 +1032,11 @@ func s:InstallCommands() if popup let s:saved_mousemodel = &mousemodel let &mousemodel = 'popup_setpos' - an 1.200 PopUp.-SEP3- - an 1.210 PopUp.Set\ breakpoint :Break - an 1.220 PopUp.Clear\ breakpoint :Clear - an 1.230 PopUp.Run\ until :Until - an 1.240 PopUp.Evaluate :Evaluate + an 1.200 PopUp.-SEP3- + an 1.210 PopUp.Set\ breakpoint :Break + an 1.220 PopUp.Clear\ breakpoint :Clear + an 1.230 PopUp.Run\ until :Until + an 1.240 PopUp.Evaluate :Evaluate endif endif @@ -984,7 +1054,7 @@ func s:InstallWinbar(force) " nnoremenu WinBar.Cont :Continue " nnoremenu WinBar.Stop :Stop " nnoremenu WinBar.Eval :Evaluate - " call add(s:winbar_winids, win_getid(winnr())) + " call add(s:winbar_winids, win_getid()) " endif endfunc @@ -1005,6 +1075,7 @@ func s:DeleteCommands() delcommand Program delcommand Source delcommand Asm + delcommand Var delcommand Winbar if exists('s:k_map_saved') @@ -1019,7 +1090,7 @@ func s:DeleteCommands() if has('menu') " Remove the WinBar entries from all windows where it was added. - " let curwinid = win_getid(winnr()) + " let curwinid = win_getid() " for winid in s:winbar_winids " if win_gotoid(winid) " aunmenu WinBar.Step @@ -1382,7 +1453,7 @@ endfunc func s:GotoSourcewinOrCreateIt() if !win_gotoid(s:sourcewin) new - let s:sourcewin = win_getid(winnr()) + let s:sourcewin = win_getid() call s:InstallWinbar(0) endif endfunc @@ -1415,19 +1486,21 @@ func s:GotoAsmwinOrCreateIt() exe 'new' endif - let s:asmwin = win_getid(winnr()) + let s:asmwin = win_getid() setlocal nowrap setlocal number setlocal noswapfile setlocal buftype=nofile + setlocal bufhidden=wipe + setlocal signcolumn=no setlocal modifiable - let asmbuf = bufnr('Termdebug-asm-listing') - if asmbuf > 0 - exe 'buffer' . asmbuf + if s:asmbuf > 0 + exe 'buffer' . s:asmbuf else - exe 'file Termdebug-asm-listing' + silent file Termdebug-asm-listing + let s:asmbuf = bufnr('Termdebug-asm-listing') endif if s:GetDisasmWindowHeight() > 0 @@ -1448,17 +1521,75 @@ func s:GotoAsmwinOrCreateIt() endif endfunc +func s:GetVariablesWindow() + if exists('g:termdebug_config') + return get(g:termdebug_config, 'variables_window', 0) + endif + if exists('g:termdebug_disasm_window') + return g:termdebug_variables_window + endif + return 0 +endfunc + +func s:GetVariablesWindowHeight() + if exists('g:termdebug_config') + return get(g:termdebug_config, 'variables_window_height', 0) + endif + if exists('g:termdebug_variables_window') && g:termdebug_variables_window > 1 + return g:termdebug_variables_window + endif + return 0 +endfunc + +func s:GotoVariableswinOrCreateIt() + if !win_gotoid(s:varwin) + if win_gotoid(s:sourcewin) + exe 'rightbelow new' + else + exe 'new' + endif + + let s:varwin = win_getid() + + setlocal nowrap + setlocal noswapfile + setlocal buftype=nofile + setlocal bufhidden=wipe + setlocal signcolumn=no + setlocal modifiable + + if s:varbuf > 0 + exe 'buffer' . s:varbuf + else + silent file Termdebug-variables-listing + let s:varbuf = bufnr('Termdebug-variables-listing') + endif + + if s:GetVariablesWindowHeight() > 0 + exe 'resize ' .. s:GetVariablesWindowHeight() + endif + endif + + if s:running + call s:SendCommand('-stack-list-variables 2') + endif +endfunc + " Handle stopping and running message from gdb. " Will update the sign that shows the current position. func s:HandleCursor(msg) - let wid = win_getid(winnr()) + let wid = win_getid() if a:msg =~ '^\*stopped' "call ch_log('program stopped') let s:stopped = 1 + if a:msg =~ '^\*stopped,reason="exited-normally"' + let s:running = 0 + endif elseif a:msg =~ '^\*running' "call ch_log('program running') let s:stopped = 0 + let s:running = 1 endif if a:msg =~ 'fullname=' @@ -1472,7 +1603,7 @@ func s:HandleCursor(msg) if asm_addr != '' let s:asm_addr = asm_addr - let curwinid = win_getid(winnr()) + let curwinid = win_getid() if win_gotoid(s:asmwin) let lnum = search('^' . s:asm_addr) if lnum == 0 @@ -1487,6 +1618,10 @@ func s:HandleCursor(msg) endif endif + if s:running && s:stopped && bufwinnr('Termdebug-variables-listing') != -1 + call s:SendCommand('-stack-list-variables 2') + endif + if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname) let lnum = substitute(a:msg, '.*line="\([^"]*\)".*', '\1', '') if lnum =~ '^[0-9]*$' @@ -1505,7 +1640,7 @@ func s:HandleCursor(msg) if &modified " TODO: find existing window exe 'split ' . fnameescape(fname) - let s:sourcewin = win_getid(winnr()) + let s:sourcewin = win_getid() call s:InstallWinbar(0) else exe 'edit ' . fnameescape(fname) -- cgit From 464472b4f75c91f36fa224600377ab1d1a467e14 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 21 Aug 2023 10:34:50 +0100 Subject: vim-patch:f6fb52b667ee runtime(termdebug): refactor error printing (vim/vim#12856) // vs not act like exception from vim or termdebug https://github.com/vim/vim/commit/f6fb52b667eecb58bdd9b26bd462d5da61697cf7 Co-authored-by: Shane-XB-Qian --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index a8480fcc43..10e17bd5e0 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -128,6 +128,10 @@ func s:GetCommand() return type(cmd) == v:t_list ? copy(cmd) : [cmd] endfunc +func s:Echoerr(msg) + echohl ErrorMsg | echom '[termdebug] ' .. a:msg | echohl None +endfunc + func s:StartDebug(bang, ...) " First argument is the command to debug, second core file or process ID. call s:StartDebug_internal({'gdb_args': a:000, 'bang': a:bang}) @@ -140,12 +144,12 @@ endfunc func s:StartDebug_internal(dict) if exists('s:gdbwin') - echoerr 'Terminal debugger already running, cannot run two' + call s:Echoerr('Terminal debugger already running, cannot run two') return endif let gdbcmd = s:GetCommand() if !executable(gdbcmd[0]) - echoerr 'Cannot execute debugger program "' .. gdbcmd[0] .. '"' + call s:Echoerr('Cannot execute debugger program "' .. gdbcmd[0] .. '"') return endif @@ -242,7 +246,7 @@ endfunc func s:CheckGdbRunning() if !s:gdb_running - echoerr string(s:GetCommand()[0]) . ' exited unexpectedly' + call s:Echoerr(string(s:GetCommand()[0]) . ' exited unexpectedly') call s:CloseBuffers() return '' endif @@ -254,10 +258,10 @@ func s:StartDebug_term(dict) execute s:vertical ? 'vnew' : 'new' let s:pty_job_id = termopen('tail -f /dev/null;#gdb program') if s:pty_job_id == 0 - echoerr 'invalid argument (or job table is full) while opening terminal window' + call s:Echoerr('Invalid argument (or job table is full) while opening terminal window') return elseif s:pty_job_id == -1 - echoerr 'Failed to open the program terminal window' + call s:Echoerr('Failed to open the program terminal window') return endif let pty_job_info = nvim_get_chan_info(s:pty_job_id) @@ -281,11 +285,11 @@ func s:StartDebug_term(dict) \ }) " hide terminal buffer if s:comm_job_id == 0 - echoerr 'invalid argument (or job table is full) while opening communication terminal window' + call s:Echoerr('Invalid argument (or job table is full) while opening communication terminal window') exe 'bwipe! ' . s:ptybuf return elseif s:comm_job_id == -1 - echoerr 'Failed to open the communication terminal window' + call s:Echoerr('Failed to open the communication terminal window') exe 'bwipe! ' . s:ptybuf return endif @@ -326,11 +330,11 @@ func s:StartDebug_term(dict) " call ch_log('executing "' . join(gdb_cmd) . '"') let s:gdb_job_id = termopen(gdb_cmd, {'on_exit': function('s:EndTermDebug')}) if s:gdb_job_id == 0 - echoerr 'invalid argument (or job table is full) while opening gdb terminal window' + call s:Echoerr('Invalid argument (or job table is full) while opening gdb terminal window') exe 'bwipe! ' . s:ptybuf return elseif s:gdb_job_id == -1 - echoerr 'Failed to open the gdb terminal window' + call s:Echoerr('Failed to open the gdb terminal window') call s:CloseBuffers() return endif @@ -386,7 +390,7 @@ func s:StartDebug_term(dict) " response can be in the same line or the next line let response = line1 . line2 if response =~ 'Undefined command' - echoerr 'Sorry, your gdb is too old, gdb 7.12 is required' + call s:Echoerr('Sorry, your gdb is too old, gdb 7.12 is required') " CHECKME: possibly send a "server show version" here call s:CloseBuffers() return @@ -405,7 +409,7 @@ func s:StartDebug_term(dict) endif let try_count += 1 if try_count > 100 - echoerr 'Cannot check if your gdb works, continuing anyway' + call s:Echoerr('Cannot check if your gdb works, continuing anyway') break endif sleep 10m @@ -464,11 +468,11 @@ func s:StartDebug_prompt(dict) \ 'on_stdout': function('s:JobOutCallback', {'last_line': '', 'real_cb': function('s:GdbOutCallback')}), \ }) if s:gdbjob == 0 - echoerr 'invalid argument (or job table is full) while starting gdb job' + call s:Echoerr('Invalid argument (or job table is full) while starting gdb job') exe 'bwipe! ' . s:ptybuf return elseif s:gdbjob == -1 - echoerr 'Failed to start the gdb job' + call s:Echoerr('Failed to start the gdb job') call s:CloseBuffers() return endif @@ -484,10 +488,10 @@ func s:StartDebug_prompt(dict) wincmd x | wincmd j belowright let s:pty_job_id = termopen('tail -f /dev/null;#gdb program') if s:pty_job_id == 0 - echoerr 'invalid argument (or job table is full) while opening terminal window' + call s:Echoerr('Invalid argument (or job table is full) while opening terminal window') return elseif s:pty_job_id == -1 - echoerr 'Failed to open the program terminal window' + call s:Echoerr('Failed to open the program terminal window') return endif let pty_job_info = nvim_get_chan_info(s:pty_job_id) @@ -616,7 +620,7 @@ func s:PromptInterrupt() " Using job_stop() does not work on MS-Windows, need to send SIGTRAP to " the debugger program so that gdb responds again. if s:pid == 0 - echoerr 'Cannot interrupt gdb, did not find a process ID' + call s:Echoerr('Cannot interrupt gdb, did not find a process ID') else call debugbreak(s:pid) endif @@ -696,7 +700,7 @@ endfunc " - change \\ to \ func s:DecodeMessage(quotedText, literal) if a:quotedText[0] != '"' - echoerr 'DecodeMessage(): missing quote in ' . a:quotedText + call s:Echoerr('DecodeMessage(): missing quote in ' . a:quotedText) return endif let msg = a:quotedText @@ -1189,7 +1193,7 @@ func s:ClearBreakpoint() endif echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.' else - echoerr 'Internal error trying to remove breakpoint at line ' . lnum . '!' + call s:Echoerr('Internal error trying to remove breakpoint at line ' . lnum . '!') endif else echomsg 'No breakpoint to remove at line ' . lnum . '.' @@ -1447,7 +1451,7 @@ func s:HandleError(msg) return endif let msgVal = substitute(a:msg, '.*msg="\(.*\)"', '\1', '') - echoerr substitute(msgVal, '\\"', '"', 'g') + call s:Echoerr(substitute(msgVal, '\\"', '"', 'g')) endfunc func s:GotoSourcewinOrCreateIt() -- cgit From ec971288267dece8f1bc492847b3ae6e5271acd0 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 21 Aug 2023 10:46:06 +0100 Subject: vim-patch:19968fc4ec2c runtime(termdebug): re-indent lines (vim/vim#12857) https://github.com/vim/vim/commit/19968fc4ec2c36c7d528c7326acf43e5d663ba39 Co-authored-by: Shane-XB-Qian --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 10e17bd5e0..83857221de 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1637,9 +1637,9 @@ func s:HandleCursor(msg) " prompt, since it is unlikely we want to edit the file. " The file may be changed but not saved, warn for that. au SwapExists * echohl WarningMsg - \ | echo 'Warning: file is being edited elsewhere' - \ | echohl None - \ | let v:swapchoice = 'o' + \ | echo 'Warning: file is being edited elsewhere' + \ | echohl None + \ | let v:swapchoice = 'o' augroup END if &modified " TODO: find existing window -- cgit From af78060b188236cca9ef3479cbab94df56c89721 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 21 Aug 2023 11:06:44 +0100 Subject: fix(termdebug): trim suffixed "\r" in CommOutput Vim splits lines on "\r", then trims any prefixed "\n". But in Nvim, job output lines are split on "\n" (like readfile() in binary mode), so trim any suffixed "\r" instead. This gets rid of the trailing "^M" character in messages parsed from the jobs. --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 83857221de..c490fbf441 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -875,7 +875,9 @@ func s:HandleDisasmMsg(msg) else let value = substitute(a:msg, '^\~\"[ ]*', '', '') let value = substitute(value, '^=>[ ]*', '', '') - let value = substitute(value, '\\n\"\r$', '', '') + " Nvim already trims the final "\r" in s:CommOutput() + " let value = substitute(value, '\\n\"\r$', '', '') + let value = substitute(value, '\\n\"$', '', '') let value = substitute(value, '\r', '', '') let value = substitute(value, '\\t', ' ', 'g') @@ -929,11 +931,10 @@ func s:HandleVariablesMsg(msg) endfunc func s:CommOutput(job_id, msgs, event) - for msg in a:msgs - " remove prefixed NL - if msg[0] == "\n" - let msg = msg[1:] + " Nvim job lines are split on "\n", so trim a suffixed CR. + if msg[-1:] == "\r" + let msg = msg[:-2] endif if s:parsing_disasm_msg -- cgit From c413b42c456bc48ef58d4e2ac9b3862787819282 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 22 Aug 2023 20:54:41 +0100 Subject: fix(termdebug): prompt mode breaks with &splitbelow set Unlike Vim, termopen() doesn't split, so you can't use the modifier like that. Remove the fragile :wincmd shenanigans. --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index c490fbf441..4108a6a19f 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -204,9 +204,9 @@ func s:StartDebug_internal(dict) endif if !has('win32') && !use_prompt let s:way = 'terminal' - else + else let s:way = 'prompt' - endif + endif if s:way == 'prompt' call s:StartDebug_prompt(a:dict) @@ -484,9 +484,8 @@ func s:StartDebug_prompt(dict) else " Unix: Run the debugged program in a terminal window. Open it below the " gdb window. - execute 'new' - wincmd x | wincmd j - belowright let s:pty_job_id = termopen('tail -f /dev/null;#gdb program') + belowright new + let s:pty_job_id = termopen('tail -f /dev/null;#gdb program') if s:pty_job_id == 0 call s:Echoerr('Invalid argument (or job table is full) while opening terminal window') return -- cgit From 21477bdb27571b6d7c51038192b74a3ec53e8110 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 22 Aug 2023 19:52:49 +0100 Subject: vim-patch:a76f3221cdcf runtime(termdebug): Fix various Termdebug issues (vim/vim#12875) * Fix some Termdebug issues after vim/vim#12403 * Fix :Asm in Termdebug prompt mode * Fix Termdebug s:DecodeMessage escaping logic https://github.com/vim/vim/commit/a76f3221cdcfff6880213839de4d04cf0c7c60f8 Adjust disassembly message forwarding for Nvim, as its callback can receive many lines at once. Currently, just forward each disassembly line individually to s:CommOutput(); it's possible to do this in batch instead, but this is simpler. I suggested moving to a GDB MI-based approach for the disassemble stuff upstream, which should simplify the logic a lot if implemented (and possibly allow for getting rid of the `&"disassemble ...` special-casing). Also, correct "(gdb)" to include a trailing space; the stray GDB prompts were being ignored by s:CommOutput() anyway, so this had caused no ill effects. --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 82 ++++++++++++---------- 1 file changed, 44 insertions(+), 38 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 4108a6a19f..a2c5ba0867 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -234,10 +234,10 @@ endfunc " Use when debugger didn't start or ended. func s:CloseBuffers() exe 'bwipe! ' . s:ptybuf - if s:asmbuf > 0 + if s:asmbuf > 0 && bufexists(s:asmbuf) exe 'bwipe! ' . s:asmbuf endif - if s:varbuf > 0 + if s:varbuf > 0 && bufexists(s:varbuf) exe 'bwipe! ' . s:varbuf endif s:running = 0 @@ -649,30 +649,36 @@ endfunc func s:GdbOutCallback(job_id, msgs, event) "call ch_log('received from gdb: ' . a:text) - " Drop the gdb prompt, we have our own. - " Drop status and echo'd commands. - call filter(a:msgs, { index, val -> - \ val !=# '(gdb)' && val !=# '^done' && val[0] !=# '&'}) - + let comm_msgs = [] let lines = [] - let index = 0 for msg in a:msgs + " Disassembly messages need to be forwarded as-is. + if s:parsing_disasm_msg || msg =~ '^&"disassemble' + call s:CommOutput(a:job_id, [msg], a:event) + continue + endif + + " Drop the gdb prompt, we have our own. + " Drop status and echo'd commands. + if msg == '(gdb) ' || msg == '^done' || msg[0] == '&' + continue + endif + if msg =~ '^\^error,msg=' if exists('s:evalexpr') \ && s:DecodeMessage(msg[11:], v:false) \ =~ 'A syntax error in expression, near\|No symbol .* in current context' " Silently drop evaluation errors. - call remove(a:msgs, index) unlet s:evalexpr continue endif elseif msg[0] == '~' call add(lines, s:DecodeMessage(msg[1:], v:false)) - call remove(a:msgs, index) continue endif - let index += 1 + + call add(comm_msgs, msg) endfor let curwinid = win_getid() @@ -687,12 +693,13 @@ func s:GdbOutCallback(job_id, msgs, event) endif call win_gotoid(curwinid) - call s:CommOutput(a:job_id, a:msgs, a:event) + call s:CommOutput(a:job_id, comm_msgs, a:event) endfunc " Decode a message from gdb. "quotedText" starts with a ", return the text up -" to the next ", unescaping characters: +" to the next unescaped ", unescaping characters: " - remove line breaks (unless "literal" is v:true) +" - change \" to " " - change \\t to \t (unless "literal" is v:true) " - change \0xhh to \xhh (disabled for now) " - change \ooo to octal @@ -703,24 +710,25 @@ func s:DecodeMessage(quotedText, literal) return endif let msg = a:quotedText - \ ->substitute('^"\|".*', '', 'g') - " multi-byte characters arrive in octal form - " NULL-values must be kept encoded as those break the string otherwise + \ ->substitute('^"\|[^\\]\zs".*', '', 'g') + \ ->substitute('\\"', '"', 'g') + "\ multi-byte characters arrive in octal form + "\ NULL-values must be kept encoded as those break the string otherwise \ ->substitute('\\000', s:NullRepl, 'g') \ ->substitute('\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g') - " Note: GDB docs also mention hex encodings - the translations below work - " but we keep them out for performance-reasons until we actually see - " those in mi-returns - " \ ->substitute('\\0x\(\x\x\)', {-> eval('"\x' .. submatch(1) .. '"')}, 'g') - " \ ->substitute('\\0x00', s:NullRepl, 'g') + "\ Note: GDB docs also mention hex encodings - the translations below work + "\ but we keep them out for performance-reasons until we actually see + "\ those in mi-returns + "\ \ ->substitute('\\0x\(\x\x\)', {-> eval('"\x' .. submatch(1) .. '"')}, 'g') + "\ \ ->substitute('\\0x00', s:NullRepl, 'g') \ ->substitute('\\\\', '\', 'g') \ ->substitute(s:NullRepl, '\\000', 'g') if !a:literal - return msg + return msg \ ->substitute('\\t', "\t", 'g') \ ->substitute('\\n', '', 'g') else - return msg + return msg endif endfunc const s:NullRepl = 'XXXNULLXXX' @@ -757,15 +765,7 @@ func s:EndTermDebug(job_id, exit_code, event) doauto User TermdebugStopPre endif - if s:asmbuf > 0 - exe 'bwipe! ' . s:asmbuf - endif - if s:varbuf > 0 - exe 'bwipe! ' . s:varbuf - endif - let s:running = 0 unlet s:gdbwin - call s:EndDebugCommon() endfunc @@ -775,6 +775,13 @@ func s:EndDebugCommon() if exists('s:ptybuf') && s:ptybuf exe 'bwipe! ' . s:ptybuf endif + if s:asmbuf > 0 && bufexists(s:asmbuf) + exe 'bwipe! ' . s:asmbuf + endif + if s:varbuf > 0 && bufexists(s:varbuf) + exe 'bwipe! ' . s:varbuf + endif + let s:running = 0 " Restore 'signcolumn' in all buffers for which it was set. call win_gotoid(s:sourcewin) @@ -824,7 +831,6 @@ func s:EndPromptDebug(job_id, exit_code, event) "call ch_log("Returning from EndPromptDebug()") endfunc -" - CommOutput: disassemble $pc " - CommOutput: &"disassemble $pc\n" " - CommOutput: ~"Dump of assembler code for function main(int, char**):\n" " - CommOutput: ~" 0x0000555556466f69 <+0>:\tpush rbp\n" @@ -834,7 +840,6 @@ endfunc " - CommOutput: ~"End of assembler dump.\n" " - CommOutput: ^done -" - CommOutput: disassemble $pc " - CommOutput: &"disassemble $pc\n" " - CommOutput: &"No function contains specified address.\n" " - CommOutput: ^error,msg="No function contains specified address." @@ -866,12 +871,12 @@ func s:HandleDisasmMsg(msg) call s:SendCommand('disassemble $pc,+100') endif let s:parsing_disasm_msg = 0 - elseif a:msg =~ '\&\"disassemble \$pc' + elseif a:msg =~ '^&"disassemble \$pc' if a:msg =~ '+100' " This is our second disasm attempt let s:parsing_disasm_msg = 2 endif - else + elseif a:msg !~ '^&"disassemble' let value = substitute(a:msg, '^\~\"[ ]*', '', '') let value = substitute(value, '^=>[ ]*', '', '') " Nvim already trims the final "\r" in s:CommOutput() @@ -953,9 +958,10 @@ func s:CommOutput(job_id, msgs, event) call s:HandleEvaluate(msg) elseif msg =~ '^\^error,msg=' call s:HandleError(msg) - elseif msg =~ '^disassemble' + elseif msg =~ '^&"disassemble' let s:parsing_disasm_msg = 1 let s:asm_lines = [] + call s:HandleDisasmMsg(msg) elseif msg =~ '^\^done,variables=' call s:HandleVariablesMsg(msg) endif @@ -1500,7 +1506,7 @@ func s:GotoAsmwinOrCreateIt() setlocal signcolumn=no setlocal modifiable - if s:asmbuf > 0 + if s:asmbuf > 0 && bufexists(s:asmbuf) exe 'buffer' . s:asmbuf else silent file Termdebug-asm-listing @@ -1562,7 +1568,7 @@ func s:GotoVariableswinOrCreateIt() setlocal signcolumn=no setlocal modifiable - if s:varbuf > 0 + if s:varbuf > 0 && bufexists(s:varbuf) exe 'buffer' . s:varbuf else silent file Termdebug-variables-listing -- cgit From 8aad4b84250a6e4d667bd7d15622164cd95fa1af Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 22 Aug 2023 22:39:29 +0100 Subject: fix(termdebug): send SIGINT when interrupting prompt mode Unlike Vim's job_stop(), Nvim's jobstop() does not take a signal argument, and always sends SIGTERM/KILL. :Stop and Ctrl-C in prompt mode is supposed to interrupt the program like in terminal mode, not kill GDB. Also, maybe libuv's kill() works on Windows? If so, the logic above could be removed, but I don't have a Windows machine available to test that. Also "set nomodified" when ending prompt mode, like Vim (avoids E37). --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index a2c5ba0867..ab569772f5 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -624,7 +624,7 @@ func s:PromptInterrupt() call debugbreak(s:pid) endif else - call jobstop(s:gdbjob) + call v:lua.vim.uv.kill(jobpid(s:gdbjob), 'sigint') endif endfunc @@ -821,6 +821,7 @@ func s:EndPromptDebug(job_id, exit_code, event) let curwinid = win_getid() call win_gotoid(s:gdbwin) + set nomodified close if curwinid != s:gdbwin call win_gotoid(curwinid) -- cgit From 92ef2b2bcd4f8082e1b05af0663ffef422461e6a Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 23 Aug 2023 09:18:17 +0100 Subject: vim-patch:2ae7ffe0bc3c runtime(termdebug): add frame related commands (vim/vim#12511) implementing `:Frame`, `:Up` and `:Down' https://github.com/vim/vim/commit/2ae7ffe0bc3c3ed9fcae35ef23a2b78908580201 Use maparg() for saving K as it's since been ported (and supports Lua callbacks and the other API fields). Use the 3 argument variant of mapset(), as the single argument one isn't ported yet (v8.2.4861). Co-authored-by: Simon Sobisch --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 94 ++++++++++++++++++++-- 1 file changed, 86 insertions(+), 8 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index ab569772f5..781c34396d 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1005,6 +1005,10 @@ func s:InstallCommands() command Continue call chansend(s:gdb_job_id, "continue\r") endif + command -nargs=* Frame call s:Frame() + command -nargs=* Up call s:Up() + command -nargs=* Down call s:Down() + command -range -nargs=* Evaluate call s:Evaluate(, ) command Gdb call win_gotoid(s:gdbwin) command Program call s:GotoProgram() @@ -1020,17 +1024,29 @@ func s:InstallCommands() let map = g:termdebug_map_K endif if map - " let s:k_map_saved = maparg('K', 'n', 0, 1) - let s:k_map_saved = {} - for map in nvim_get_keymap('n') - if map.lhs ==# 'K' - let s:k_map_saved = map - break - endif - endfor + let s:k_map_saved = maparg('K', 'n', 0, 1) nnoremap K :Evaluate endif + let map = 1 + if exists('g:termdebug_config') + let map = get(g:termdebug_config, 'map_plus', 1) + endif + if map + let s:plus_map_saved = maparg('+', 'n', 0, 1) + nnoremap + :Up + endif + + let map = 1 + if exists('g:termdebug_config') + let map = get(g:termdebug_config, 'map_minus', 1) + endif + if map + let s:minus_map_saved = maparg('-', 'n', 0, 1) + nnoremap - :Down + endif + + if has('menu') && &mouse != '' call s:InstallWinbar(0) @@ -1081,6 +1097,9 @@ func s:DeleteCommands() delcommand Arguments delcommand Stop delcommand Continue + delcommand Frame + delcommand Up + delcommand Down delcommand Evaluate delcommand Gdb delcommand Program @@ -1098,6 +1117,24 @@ func s:DeleteCommands() endif unlet s:k_map_saved endif + if exists('s:plus_map_saved') + if empty(s:plus_map_saved) + nunmap + + else + " call mapset(s:plus_map_saved) + call mapset('n', 0, s:plus_map_saved) + endif + unlet s:plus_map_saved + endif + if exists('s:minus_map_saved') + if empty(s:minus_map_saved) + nunmap - + else + " call mapset(s:minus_map_saved) + call mapset('n', 0, s:minus_map_saved) + endif + unlet s:minus_map_saved + endif if has('menu') " Remove the WinBar entries from all windows where it was added. @@ -1214,6 +1251,47 @@ func s:Run(args) call s:SendResumingCommand('-exec-run') endfunc +" :Frame - go to a specfic frame in the stack +func s:Frame(arg) + " Note: we explicit do not use mi's command + " call s:SendCommand('-stack-select-frame "' . a:arg .'"') + " as we only get a "done" mi response and would have to open the file + " 'manually' - using cli command "frame" provides us with the mi response + " already parsed and allows for more formats + if a:arg =~ '^\d\+$' || a:arg == '' + " specify frame by number + call s:SendCommand('-interpreter-exec mi "frame ' . a:arg .'"') + elseif a:arg =~ '^0x[0-9a-fA-F]\+$' + " specify frame by stack address + call s:SendCommand('-interpreter-exec mi "frame address ' . a:arg .'"') + else + " specify frame by function name + call s:SendCommand('-interpreter-exec mi "frame function ' . a:arg .'"') + endif +endfunc + +" :Up - go one frame in the stack "higher" +func s:Up(arg) + if a:arg != '' + let s:cmd = '"up ' . a:arg . '"' + else + let s:cmd = '"up"' + endif + " the 'correct' one would be -stack-select-frame N, but we don't know N + call s:SendCommand('-interpreter-exec console ' . s:cmd) +endfunc + +" :Down - go one frame in the stack "below" +func s:Down(arg) + if a:arg != '' + let s:cmd = '"down ' . a:arg . '"' + else + let s:cmd = '"down"' + endif + " the 'correct' one would be -stack-select-frame N, but we don't know N + call s:SendCommand('-interpreter-exec console ' . s:cmd) +endfunc + func s:SendEval(expr) " check for "likely" boolean expressions, in which case we take it as lhs if a:expr =~ "[=!<>]=" -- cgit From e3b385bed5d27a3c50687526737e8e146c3abddc Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 23 Aug 2023 17:41:21 +0100 Subject: vim-patch:3d3a9152fa6d runtime(termdebug): more termdebug fixes and improvements (vim/vim#12892) - Fix and attempt to simplify :Frame/:Up/:Down documentation. - Accept a count instead for :Up/:Down/+/-. - Update the "Last Change" dates. - Fix a missing :let (caused an error if gdb fails to start). - Wipe the prompt buffer when ending prompt mode (if it exists and wasn't wiped by the user first). Avoids issues with stale prompt buffers (such as E95 when starting a new prompt mode session). - Kill the gdb job if the prompt buffer is unloaded (similar to what's done for a terminal buffer). Fixes not being able to start a new termdebug session if the buffer was wiped by the user, for example. https://github.com/vim/vim/commit/3d3a9152fa6de7038fdfd6d6de25230ed825552a --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 43 ++++++++-------------- 1 file changed, 15 insertions(+), 28 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 781c34396d..e0f2c84f2d 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: 2023 Jun 24 +" Last Change: 2023 Aug 23 " " WORK IN PROGRESS - The basics works stable, more to come " Note: In general you need at least GDB 7.12 because this provides the @@ -240,7 +240,7 @@ func s:CloseBuffers() if s:varbuf > 0 && bufexists(s:varbuf) exe 'bwipe! ' . s:varbuf endif - s:running = 0 + let s:running = 0 unlet! s:gdbwin endfunc @@ -476,6 +476,7 @@ func s:StartDebug_prompt(dict) call s:CloseBuffers() return endif + exe $'au BufUnload ++once call jobstop(s:gdbjob)' let s:ptybuf = 0 if has('win32') @@ -819,12 +820,8 @@ func s:EndPromptDebug(job_id, exit_code, event) doauto User TermdebugStopPre endif - let curwinid = win_getid() - call win_gotoid(s:gdbwin) - set nomodified - close - if curwinid != s:gdbwin - call win_gotoid(curwinid) + if bufexists(s:promptbuf) + exe 'bwipe! ' . s:promptbuf endif call s:EndDebugCommon() @@ -1006,8 +1003,8 @@ func s:InstallCommands() endif command -nargs=* Frame call s:Frame() - command -nargs=* Up call s:Up() - command -nargs=* Down call s:Down() + command -count=1 Up call s:Up() + command -count=1 Down call s:Down() command -range -nargs=* Evaluate call s:Evaluate(, ) command Gdb call win_gotoid(s:gdbwin) @@ -1034,7 +1031,7 @@ func s:InstallCommands() endif if map let s:plus_map_saved = maparg('+', 'n', 0, 1) - nnoremap + :Up + nnoremap + $'{v:count1}Up' endif let map = 1 @@ -1043,7 +1040,7 @@ func s:InstallCommands() endif if map let s:minus_map_saved = maparg('-', 'n', 0, 1) - nnoremap - :Down + nnoremap - $'{v:count1}Down' endif @@ -1270,26 +1267,16 @@ func s:Frame(arg) endif endfunc -" :Up - go one frame in the stack "higher" -func s:Up(arg) - if a:arg != '' - let s:cmd = '"up ' . a:arg . '"' - else - let s:cmd = '"up"' - endif +" :Up - go a:count frames in the stack "higher" +func s:Up(count) " the 'correct' one would be -stack-select-frame N, but we don't know N - call s:SendCommand('-interpreter-exec console ' . s:cmd) + call s:SendCommand($'-interpreter-exec console "up {a:count}"') endfunc -" :Down - go one frame in the stack "below" -func s:Down(arg) - if a:arg != '' - let s:cmd = '"down ' . a:arg . '"' - else - let s:cmd = '"down"' - endif +" :Down - go a:count frames in the stack "below" +func s:Down(count) " the 'correct' one would be -stack-select-frame N, but we don't know N - call s:SendCommand('-interpreter-exec console ' . s:cmd) + call s:SendCommand($'-interpreter-exec console "down {a:count}"') endfunc func s:SendEval(expr) -- cgit From 0bd82b540eb492c2c41f8b18be9ac749008ee340 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 25 Aug 2023 11:22:50 +0100 Subject: refactor(termdebug): reindent some things Mostly to make it more consistent and to match Vim more where applicable. --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 196 ++++++++++----------- 1 file changed, 98 insertions(+), 98 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index e0f2c84f2d..c436e015cc 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -246,9 +246,9 @@ endfunc func s:CheckGdbRunning() if !s:gdb_running - call s:Echoerr(string(s:GetCommand()[0]) . ' exited unexpectedly') - call s:CloseBuffers() - return '' + call s:Echoerr(string(s:GetCommand()[0]) . ' exited unexpectedly') + call s:CloseBuffers() + return '' endif return 'ok' endfunc @@ -464,9 +464,9 @@ func s:StartDebug_prompt(dict) " call ch_log('executing "' . join(gdb_cmd) . '"') let s:gdbjob = jobstart(gdb_cmd, { - \ 'on_exit': function('s:EndPromptDebug'), - \ 'on_stdout': function('s:JobOutCallback', {'last_line': '', 'real_cb': function('s:GdbOutCallback')}), - \ }) + \ 'on_exit': function('s:EndPromptDebug'), + \ 'on_stdout': function('s:JobOutCallback', {'last_line': '', 'real_cb': function('s:GdbOutCallback')}), + \ }) if s:gdbjob == 0 call s:Echoerr('Invalid argument (or job table is full) while starting gdb job') exe 'bwipe! ' . s:ptybuf @@ -1197,7 +1197,7 @@ func s:SetBreakpoint(at) " Use the fname:lnum format, older gdb can't handle --source. let at = empty(a:at) ? - \ fnameescape(expand('%:p')) . ':' . line('.') : a:at + \ fnameescape(expand('%:p')) . ':' . line('.') : a:at call s:SendCommand('-break-insert ' . at) if do_continue Continue @@ -1417,101 +1417,101 @@ function! s:CloseFloatingHoverOnCursorMove(win_id, opened) abort endfunction function! s:CloseFloatingHoverOnBufEnter(win_id, bufnr) abort - let winnr = win_id2win(a:win_id) - if winnr == 0 - " Float window was already closed - autocmd! nvim_termdebug_close_hover - return - endif - if winnr == winnr() - " Cursor is moving into floating window. Do not close it - return - endif - if bufnr('%') == a:bufnr - " When current buffer opened hover window, it's not another buffer. Skipped - return - endif + let winnr = win_id2win(a:win_id) + if winnr == 0 + " Float window was already closed autocmd! nvim_termdebug_close_hover - call nvim_win_close(a:win_id, v:true) - endfunction + return + endif + if winnr == winnr() + " Cursor is moving into floating window. Do not close it + return + endif + if bufnr('%') == a:bufnr + " When current buffer opened hover window, it's not another buffer. Skipped + return + endif + autocmd! nvim_termdebug_close_hover + call nvim_win_close(a:win_id, v:true) +endfunction " Open preview window. Window is open in: " - Floating window on Neovim (0.4.0 or later) " - Preview window on Neovim (0.3.0 or earlier) or Vim function! s:OpenHoverPreview(lines, filetype) abort - " Use local variable since parameter is not modifiable - let lines = a:lines - let bufnr = bufnr('%') - - let use_float_win = s:ShouldUseFloatWindow() - if use_float_win - let pos = getpos('.') - - " Calculate width and height - let width = 0 - for index in range(len(lines)) - let line = lines[index] - let lw = strdisplaywidth(line) - if lw > width - let width = lw - endif - let lines[index] = line - endfor - - let height = len(lines) - - " Calculate anchor - " Prefer North, but if there is no space, fallback into South - let bottom_line = line('w0') + winheight(0) - 1 - if pos[1] + height <= bottom_line - let vert = 'N' - let row = 1 - else - let vert = 'S' - let row = 0 + " Use local variable since parameter is not modifiable + let lines = a:lines + let bufnr = bufnr('%') + + let use_float_win = s:ShouldUseFloatWindow() + if use_float_win + let pos = getpos('.') + + " Calculate width and height + let width = 0 + for index in range(len(lines)) + let line = lines[index] + let lw = strdisplaywidth(line) + if lw > width + let width = lw endif + let lines[index] = line + endfor - " Prefer West, but if there is no space, fallback into East - if pos[2] + width <= &columns - let hor = 'W' - let col = 0 - else - let hor = 'E' - let col = 1 - endif + let height = len(lines) - let buf = nvim_create_buf(v:false, v:true) - call nvim_buf_set_lines(buf, 0, -1, v:true, lines) - " using v:true for second argument of nvim_open_win make the floating - " window disappear - let float_win_id = nvim_open_win(buf, v:false, { - \ 'relative': 'cursor', - \ 'anchor': vert . hor, - \ 'row': row, - \ 'col': col, - \ 'width': width, - \ 'height': height, - \ 'style': 'minimal', - \ }) - - if a:filetype isnot v:null - call nvim_set_option_value('filetype', a:filetype, { 'win' : float_win_id }) - endif + " Calculate anchor + " Prefer North, but if there is no space, fallback into South + let bottom_line = line('w0') + winheight(0) - 1 + if pos[1] + height <= bottom_line + let vert = 'N' + let row = 1 + else + let vert = 'S' + let row = 0 + endif - call nvim_set_option_value('modified', v:false, { 'buf' : buf }) - call nvim_set_option_value('modifiable', v:false, { 'buf' : buf }) - - " Unlike preview window, :pclose does not close window. Instead, close - " hover window automatically when cursor is moved. - let call_after_move = printf('CloseFloatingHoverOnCursorMove(%d, %s)', float_win_id, string(pos)) - let call_on_bufenter = printf('CloseFloatingHoverOnBufEnter(%d, %d)', float_win_id, bufnr) - augroup nvim_termdebug_close_hover - execute 'autocmd CursorMoved,CursorMovedI,InsertEnter call ' . call_after_move - execute 'autocmd BufEnter * call ' . call_on_bufenter - augroup END + " Prefer West, but if there is no space, fallback into East + if pos[2] + width <= &columns + let hor = 'W' + let col = 0 else - echomsg a:lines[0] + let hor = 'E' + let col = 1 + endif + + let buf = nvim_create_buf(v:false, v:true) + call nvim_buf_set_lines(buf, 0, -1, v:true, lines) + " using v:true for second argument of nvim_open_win make the floating + " window disappear + let float_win_id = nvim_open_win(buf, v:false, { + \ 'relative': 'cursor', + \ 'anchor': vert . hor, + \ 'row': row, + \ 'col': col, + \ 'width': width, + \ 'height': height, + \ 'style': 'minimal', + \ }) + + if a:filetype isnot v:null + call nvim_set_option_value('filetype', a:filetype, { 'win' : float_win_id }) endif + + call nvim_set_option_value('modified', v:false, { 'buf' : buf }) + call nvim_set_option_value('modifiable', v:false, { 'buf' : buf }) + + " Unlike preview window, :pclose does not close window. Instead, close + " hover window automatically when cursor is moved. + let call_after_move = printf('CloseFloatingHoverOnCursorMove(%d, %s)', float_win_id, string(pos)) + let call_on_bufenter = printf('CloseFloatingHoverOnBufEnter(%d, %d)', float_win_id, bufnr) + augroup nvim_termdebug_close_hover + execute 'autocmd CursorMoved,CursorMovedI,InsertEnter call ' . call_after_move + execute 'autocmd BufEnter * call ' . call_on_bufenter + augroup END + else + echomsg a:lines[0] + endif endfunction " Handle an error. @@ -1681,15 +1681,15 @@ func s:HandleCursor(msg) let curwinid = win_getid() if win_gotoid(s:asmwin) - let lnum = search('^' . s:asm_addr) - if lnum == 0 - call s:SendCommand('disassemble $pc') - else - call sign_unplace('TermDebug', #{id: s:asm_id}) - call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum}) - endif + let lnum = search('^' . s:asm_addr) + if lnum == 0 + call s:SendCommand('disassemble $pc') + else + call sign_unplace('TermDebug', #{id: s:asm_id}) + call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum}) + endif - call win_gotoid(curwinid) + call win_gotoid(curwinid) endif endif endif -- cgit From 3222f0ad0079ce4bd4e45886a00e4fe4685fb5dd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 16 Oct 2023 16:36:25 +0800 Subject: vim-patch:dbf749bd5aae (#25665) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runtime: Fix more typos (vim/vim#13354) * Fix more typos * Fix typos in ignored runtime/ directory https://github.com/vim/vim/commit/dbf749bd5aaef6ea2d28bce081349785d174d96a Co-authored-by: Viktor Szépe --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index c436e015cc..a0710476a9 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1248,7 +1248,7 @@ func s:Run(args) call s:SendResumingCommand('-exec-run') endfunc -" :Frame - go to a specfic frame in the stack +" :Frame - go to a specific frame in the stack func s:Frame(arg) " Note: we explicit do not use mi's command " call s:SendCommand('-stack-select-frame "' . a:arg .'"') -- cgit From 5a2543c1598a0cf97b8eca0573139c9c20d6c93a Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 3 Nov 2023 00:22:02 +0100 Subject: docs: small fixes (#25831) Co-authored-by: Peter Aronoff --- runtime/pack/dist/opt/matchit/doc/matchit.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/matchit/doc/matchit.txt b/runtime/pack/dist/opt/matchit/doc/matchit.txt index 5daf9788d6..88d0c38e4d 100644 --- a/runtime/pack/dist/opt/matchit/doc/matchit.txt +++ b/runtime/pack/dist/opt/matchit/doc/matchit.txt @@ -1,4 +1,4 @@ -*matchit.txt* Extended "%" matching +*matchit.txt* Extended |%| matching For instructions on installing this file, type `:help matchit-install` -- cgit From 89d785e53015d7ba6a7f10e97a750b8d3431d3a9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 07:19:21 +0800 Subject: vim-patch:ca48202b6f46 runtime(termdebug): improve window handling, shorten var types closes vim/vim#13474 https://github.com/vim/vim/commit/ca48202b6f46cfb40a0d1d80033a2f3e8cb7b813 Co-authored-by: shane.xb.qian --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index a0710476a9..0deea4f6f7 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -894,7 +894,9 @@ func s:ParseVarinfo(varinfo) let nameIdx = matchstrpos(a:varinfo, '{name="\([^"]*\)"') let dict['name'] = a:varinfo[nameIdx[1] + 7 : nameIdx[2] - 2] let typeIdx = matchstrpos(a:varinfo, ',type="\([^"]*\)"') - let dict['type'] = a:varinfo[typeIdx[1] + 7 : typeIdx[2] - 2] + " 'type' maybe is a url-like string, + " try to shorten it and show only the /tail + let dict['type'] = (a:varinfo[typeIdx[1] + 7 : typeIdx[2] - 2])->fnamemodify(':t') let valueIdx = matchstrpos(a:varinfo, ',value="\(.*\)"}') if valueIdx[1] == -1 let dict['value'] = 'Complex value' @@ -1556,8 +1558,15 @@ endfunc func s:GotoAsmwinOrCreateIt() if !win_gotoid(s:asmwin) + let mdf = '' if win_gotoid(s:sourcewin) - exe 'rightbelow new' + " 60 is approx spaceBuffer * 3 + if winwidth(0) > (78 + 60) + let mdf = 'vert' + exe mdf .. ' ' .. 60 .. 'new' + else + exe 'rightbelow new' + endif else exe 'new' endif @@ -1579,7 +1588,7 @@ func s:GotoAsmwinOrCreateIt() let s:asmbuf = bufnr('Termdebug-asm-listing') endif - if s:GetDisasmWindowHeight() > 0 + if mdf != 'vert' && s:GetDisasmWindowHeight() > 0 exe 'resize ' .. s:GetDisasmWindowHeight() endif endif @@ -1619,8 +1628,15 @@ endfunc func s:GotoVariableswinOrCreateIt() if !win_gotoid(s:varwin) + let mdf = '' if win_gotoid(s:sourcewin) - exe 'rightbelow new' + " 60 is approx spaceBuffer * 3 + if winwidth(0) > (78 + 60) + let mdf = 'vert' + exe mdf .. ' ' .. 60 .. 'new' + else + exe 'rightbelow new' + endif else exe 'new' endif @@ -1641,7 +1657,7 @@ func s:GotoVariableswinOrCreateIt() let s:varbuf = bufnr('Termdebug-variables-listing') endif - if s:GetVariablesWindowHeight() > 0 + if mdf != 'vert' && s:GetVariablesWindowHeight() > 0 exe 'resize ' .. s:GetVariablesWindowHeight() endif endif -- cgit From 77bb69d7b0d1ae8d9526b658eeea07b2d58ae78d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 08:38:25 +0800 Subject: vim-patch:7fbbd7fdc6df (#25944) runtime(termdebug): handle buffer-local mappings properly closes: vim/vim#13475 https://github.com/vim/vim/commit/7fbbd7fdc6df9dc198b3735cfbe8dbe8afd646f9 Co-authored-by: shane.xb.qian --- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 0deea4f6f7..73fbc8c922 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: 2023 Aug 23 +" Last Change: 2023 Nov 02 " " WORK IN PROGRESS - The basics works stable, more to come " Note: In general you need at least GDB 7.12 because this provides the @@ -1024,7 +1024,9 @@ func s:InstallCommands() endif if map let s:k_map_saved = maparg('K', 'n', 0, 1) - nnoremap K :Evaluate + if !empty(s:k_map_saved) && !s:k_map_saved.buffer || empty(s:k_map_saved) + nnoremap K :Evaluate + endif endif let map = 1 @@ -1033,7 +1035,9 @@ func s:InstallCommands() endif if map let s:plus_map_saved = maparg('+', 'n', 0, 1) - nnoremap + $'{v:count1}Up' + if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer || empty(s:plus_map_saved) + nnoremap + $'{v:count1}Up' + endif endif let map = 1 @@ -1042,7 +1046,9 @@ func s:InstallCommands() endif if map let s:minus_map_saved = maparg('-', 'n', 0, 1) - nnoremap - $'{v:count1}Down' + if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer || empty(s:minus_map_saved) + nnoremap - $'{v:count1}Down' + endif endif @@ -1108,29 +1114,32 @@ func s:DeleteCommands() delcommand Winbar if exists('s:k_map_saved') - if empty(s:k_map_saved) + if !empty(s:k_map_saved) && !s:k_map_saved.buffer nunmap K - else " call mapset(s:k_map_saved) call mapset('n', 0, s:k_map_saved) + elseif empty(s:k_map_saved) + nunmap K endif unlet s:k_map_saved endif if exists('s:plus_map_saved') - if empty(s:plus_map_saved) + if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer nunmap + - else " call mapset(s:plus_map_saved) call mapset('n', 0, s:plus_map_saved) + elseif empty(s:plus_map_saved) + nunmap + endif unlet s:plus_map_saved endif if exists('s:minus_map_saved') - if empty(s:minus_map_saved) + if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer nunmap - - else " call mapset(s:minus_map_saved) call mapset('n', 0, s:minus_map_saved) + elseif empty(s:minus_map_saved) + nunmap - endif unlet s:minus_map_saved endif @@ -1926,3 +1935,5 @@ call s:InitAutocmd() let &cpo = s:keepcpo unlet s:keepcpo + +" vim: sw=2 sts=2 et -- cgit From f748a73a357710db6094d4a428cd056f5df226a9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 19:48:50 +0800 Subject: vim-patch:8.2.4861: it is not easy to restore saved mappings Problem: It is not easy to restore saved mappings. Solution: Make mapset() accept a dict argument. (Ernie Rael, closes vim/vim#10295) https://github.com/vim/vim/commit/51d04d16f21e19d6eded98f9530d84089102f925 Co-authored-by: Ernie Rael --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 73fbc8c922..8beca8ffb3 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1116,8 +1116,7 @@ func s:DeleteCommands() if exists('s:k_map_saved') if !empty(s:k_map_saved) && !s:k_map_saved.buffer nunmap K - " call mapset(s:k_map_saved) - call mapset('n', 0, s:k_map_saved) + call mapset(s:k_map_saved) elseif empty(s:k_map_saved) nunmap K endif @@ -1126,8 +1125,7 @@ func s:DeleteCommands() if exists('s:plus_map_saved') if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer nunmap + - " call mapset(s:plus_map_saved) - call mapset('n', 0, s:plus_map_saved) + call mapset(s:plus_map_saved) elseif empty(s:plus_map_saved) nunmap + endif @@ -1136,8 +1134,7 @@ func s:DeleteCommands() if exists('s:minus_map_saved') if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer nunmap - - " call mapset(s:minus_map_saved) - call mapset('n', 0, s:minus_map_saved) + call mapset(s:minus_map_saved) elseif empty(s:minus_map_saved) nunmap - endif -- cgit From 74e23b3b2ad91d4308c409b4f7419a1d3955a5bb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Nov 2023 05:44:30 +0800 Subject: vim-patch:2dd613f57bf1 (#26009) runtime(termdebug): improve the breakpoint sign label (vim/vim#13525) // related vim/vim#12589 // that should be the last chat (I) with Bram, r.i.p https://github.com/vim/vim/commit/2dd613f57bf17eb8ff050bcb5510eb0279f5c9ab Co-authored-by: Shane-XB-Qian --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/pack/dist/opt') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 8beca8ffb3..1b5baa9a8b 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -1781,9 +1781,9 @@ func s:CreateBreakpoint(id, subid, enabled) let label = get(g:termdebug_config, 'sign', '') endif if label == '' - let label = substitute(nr, '\..*', '', '') - if strlen(label) > 2 - let label = strpart(label, strlen(label) - 2) + let label = printf('%02X', a:id) + if a:id > 255 + let label = 'F+' endif endif call sign_define('debugBreakpoint' .. nr, -- cgit