aboutsummaryrefslogtreecommitdiff
path: root/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/pack/dist/opt/termdebug/plugin/termdebug.vim')
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim331
1 files changed, 167 insertions, 164 deletions
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index f78a082cb7..9412a821e8 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -44,8 +44,13 @@
" - job_info && term_getjob -> nvim_get_chan_info
" - balloon -> vim.lsp.util.open_floating_preview
+func s:Echoerr(msg)
+ echohl ErrorMsg | echom $'[termdebug] {a:msg}' | echohl None
+endfunc
+
" In case this gets sourced twice.
if exists(':Termdebug')
+ call s:Echoerr('Termdebug already loaded.')
finish
endif
@@ -67,8 +72,8 @@ command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand(
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:stopped = v:true
+let s:running = v:false
let s:parsing_disasm_msg = 0
let s:asm_lines = []
@@ -86,9 +91,9 @@ endfunction
func s:Highlight(init, old, new)
let default = a:init ? 'default ' : ''
if a:new ==# 'light' && a:old !=# 'light'
- exe "hi " . default . "debugPC term=reverse ctermbg=lightblue guibg=lightblue"
+ exe $"hi {default}debugPC term=reverse ctermbg=lightblue guibg=lightblue"
elseif a:new ==# 'dark' && a:old !=# 'dark'
- exe "hi " . default . "debugPC term=reverse ctermbg=darkblue guibg=darkblue"
+ exe $"hi {default}debugPC term=reverse ctermbg=darkblue guibg=darkblue"
endif
endfunc
@@ -121,10 +126,6 @@ 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})
@@ -142,16 +143,16 @@ func s:StartDebug_internal(dict)
endif
let gdbcmd = s:GetCommand()
if !executable(gdbcmd[0])
- call s:Echoerr('Cannot execute debugger program "' .. gdbcmd[0] .. '"')
+ call s:Echoerr($'Cannot execute debugger program "{gdbcmd[0]}"')
return
endif
let s:ptywin = 0
let s:pid = 0
let s:asmwin = 0
- let s:asmbuf = 0
+ let s:asmbufnr = 0
let s:varwin = 0
- let s:varbuf = 0
+ let s:varbufnr = 0
if exists('#User#TermdebugStartPre')
doauto <nomodeline> User TermdebugStartPre
@@ -167,8 +168,8 @@ func s:StartDebug_internal(dict)
let b:save_signcolumn = &signcolumn
let s:signcolumn_buflist = [bufnr()]
- let s:save_columns = 0
- let s:allleft = 0
+ let s:saved_columns = 0
+ let s:allleft = v:false
let wide = 0
if exists('g:termdebug_config')
let wide = get(g:termdebug_config, 'wide', 0)
@@ -177,15 +178,15 @@ func s:StartDebug_internal(dict)
endif
if wide > 0
if &columns < wide
- let s:save_columns = &columns
+ let s:saved_columns = &columns
let &columns = wide
" If we make the Vim window wider, use the whole left half for the debug
" windows.
- let s:allleft = 1
+ let s:allleft = v:true
endif
- let s:vertical = 1
+ let s:vertical = v:true
else
- let s:vertical = 0
+ let s:vertical = v:false
endif
" Override using a terminal window by setting g:termdebug_use_prompt to 1.
@@ -226,24 +227,25 @@ endfunc
" Use when debugger didn't start or ended.
func s:CloseBuffers()
- exe 'bwipe! ' . s:ptybuf
- if s:asmbuf > 0 && bufexists(s:asmbuf)
- exe 'bwipe! ' . s:asmbuf
+ exe $'bwipe! {s:ptybufnr}'
+ if s:asmbufnr > 0 && bufexists(s:asmbufnr)
+ exe $'bwipe! {s:asmbufnr}'
endif
- if s:varbuf > 0 && bufexists(s:varbuf)
- exe 'bwipe! ' . s:varbuf
+ if s:varbufnr > 0 && bufexists(s:varbufnr)
+ exe $'bwipe! {s:varbufnr}'
endif
- let s:running = 0
+ let s:running = v:false
unlet! s:gdbwin
endfunc
-func s:CheckGdbRunning()
+func s:IsGdbStarted()
if !s:gdb_running
- call s:Echoerr(string(s:GetCommand()[0]) . ' exited unexpectedly')
+ let cmd_name = string(s:GetCommand()[0])
+ call s:Echoerr($'{cmd_name} exited unexpectedly')
call s:CloseBuffers()
- return ''
+ return v:false
endif
- return 'ok'
+ return v:true
endfunc
" Open a terminal window without a job, to run the debugged program in.
@@ -258,13 +260,13 @@ func s:StartDebug_term(dict)
return
endif
let pty_job_info = nvim_get_chan_info(s:pty_job_id)
- let s:ptybuf = pty_job_info['buffer']
+ let s:ptybufnr = pty_job_info['buffer']
let pty = pty_job_info['pty']
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.
- exe (&columns / 2 - 1) . "wincmd |"
+ exe $":{(&columns / 2 - 1)}wincmd |"
if s:allleft
" use the whole left column
wincmd H
@@ -279,11 +281,11 @@ func s:StartDebug_term(dict)
" hide terminal buffer
if s:comm_job_id == 0
call s:Echoerr('Invalid argument (or job table is full) while opening communication terminal window')
- exe 'bwipe! ' . s:ptybuf
+ exe 'bwipe! ' . s:ptybufnr
return
elseif s:comm_job_id == -1
call s:Echoerr('Failed to open the communication terminal window')
- exe 'bwipe! ' . s:ptybuf
+ exe $'bwipe! {s:ptybufnr}'
return
endif
let comm_job_info = nvim_get_chan_info(s:comm_job_id)
@@ -320,11 +322,11 @@ func s:StartDebug_term(dict)
let gdb_cmd += gdb_args
execute 'new'
- " call ch_log('executing "' . join(gdb_cmd) . '"')
+ " 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
call s:Echoerr('Invalid argument (or job table is full) while opening gdb terminal window')
- exe 'bwipe! ' . s:ptybuf
+ exe 'bwipe! ' . s:ptybufnr
return
elseif s:gdb_job_id == -1
call s:Echoerr('Failed to open the gdb terminal window')
@@ -334,18 +336,18 @@ func s:StartDebug_term(dict)
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:gdbbufnr = gdb_job_info['buffer']
let s:gdbwin = win_getid()
" Wait for the "startupdone" message before sending any commands.
let try_count = 0
while 1
- if s:CheckGdbRunning() != 'ok'
+ if !s:IsGdbStarted()
return
endif
for lnum in range(1, 200)
- if get(getbufline(s:gdbbuf, lnum), 0, '') =~ 'startupdone'
+ if get(getbufline(s:gdbbufnr, lnum), 0, '') =~ 'startupdone'
let try_count = 9999
break
endif
@@ -359,26 +361,26 @@ func s:StartDebug_term(dict)
endwhile
" Set arguments to be run.
- if len(proc_args)
- call chansend(s:gdb_job_id, 'server set args ' . join(proc_args) . "\r")
+ if !empty(proc_args)
+ call chansend(s:gdb_job_id, $"server set args {join(proc_args)}\r")
endif
" Connect gdb to the communication pty, using the GDB/MI interface.
" Prefix "server" to avoid adding this to the history.
- call chansend(s:gdb_job_id, 'server new-ui mi ' . commpty . "\r")
+ call chansend(s:gdb_job_id, $"server new-ui mi {commpty}\r")
" Wait for the response to show up, users may not notice the error and wonder
" why the debugger doesn't work.
let try_count = 0
while 1
- if s:CheckGdbRunning() != 'ok'
+ if !s:IsGdbStarted()
return
endif
let response = ''
for lnum in range(1, 200)
- let line1 = get(getbufline(s:gdbbuf, lnum), 0, '')
- let line2 = get(getbufline(s:gdbbuf, lnum + 1), 0, '')
+ let line1 = get(getbufline(s:gdbbufnr, lnum), 0, '')
+ let line2 = get(getbufline(s:gdbbufnr, lnum + 1), 0, '')
if line1 =~ 'new-ui mi '
" response can be in the same line or the next line
let response = line1 . line2
@@ -444,7 +446,7 @@ func s:StartDebug_prompt(dict)
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.
- exe (&columns / 2 - 1) . "wincmd |"
+ exe $":{(&columns / 2 - 1)}wincmd |"
endif
let gdb_args = get(a:dict, 'gdb_args', [])
@@ -465,14 +467,14 @@ func s:StartDebug_prompt(dict)
" Adding arguments requested by the user
let gdb_cmd += gdb_args
- " call ch_log('executing "' . join(gdb_cmd) . '"')
+ " 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')}),
\ })
if s:gdbjob == 0
call s:Echoerr('Invalid argument (or job table is full) while starting gdb job')
- exe 'bwipe! ' . s:ptybuf
+ exe $'bwipe! {s:ptybufnr}'
return
elseif s:gdbjob == -1
call s:Echoerr('Failed to start the gdb job')
@@ -481,7 +483,7 @@ func s:StartDebug_prompt(dict)
endif
exe $'au BufUnload <buffer={s:promptbuf}> ++once call jobstop(s:gdbjob)'
- let s:ptybuf = 0
+ let s:ptybufnr = 0
if has('win32')
" MS-Windows: run in a new console window for maximum compatibility
call s:SendCommand('set new-console on')
@@ -498,26 +500,26 @@ func s:StartDebug_prompt(dict)
return
endif
let pty_job_info = nvim_get_chan_info(s:pty_job_id)
- let s:ptybuf = pty_job_info['buffer']
+ let s:ptybufnr = pty_job_info['buffer']
let pty = pty_job_info['pty']
let s:ptywin = win_getid()
- call s:SendCommand('tty ' . pty)
+ call s:SendCommand($'tty {pty}')
" Since GDB runs in a prompt window, the environment has not been set to
" match a terminal window, need to do that now.
call s:SendCommand('set env TERM = xterm-color')
- call s:SendCommand('set env ROWS = ' . winheight(s:ptywin))
- call s:SendCommand('set env LINES = ' . winheight(s:ptywin))
- call s:SendCommand('set env COLUMNS = ' . winwidth(s:ptywin))
- call s:SendCommand('set env COLORS = ' . &t_Co)
- call s:SendCommand('set env VIM_TERMINAL = ' . v:version)
+ call s:SendCommand($'set env ROWS = {winheight(s:ptywin)}')
+ call s:SendCommand($'set env LINES = {winheight(s:ptywin)}')
+ call s:SendCommand($'set env COLUMNS = {winwidth(s:ptywin)}')
+ call s:SendCommand($'set env COLORS = {&t_Co}')
+ call s:SendCommand($'set env VIM_TERMINAL = {v:version}')
endif
call s:SendCommand('set print pretty on')
call s:SendCommand('set breakpoint pending on')
" Set arguments to be run
- if len(proc_args)
- call s:SendCommand('set args ' . join(proc_args))
+ if !empty(proc_args)
+ call s:SendCommand($'set args {join(proc_args)}')
endif
call s:StartDebugCommon(a:dict)
@@ -563,18 +565,18 @@ endfunc
" Send a command to gdb. "cmd" is the string without line terminator.
func s:SendCommand(cmd)
- "call ch_log('sending to gdb: ' . a:cmd)
+ " call ch_log($'sending to gdb: {a:cmd}')
if s:way == 'prompt'
- call chansend(s:gdbjob, a:cmd . "\n")
+ call chansend(s:gdbjob, $"{a:cmd}\n")
else
- call chansend(s:comm_job_id, a:cmd . "\r")
+ call chansend(s:comm_job_id, $"{a:cmd}\r")
endif
endfunc
" This is global so that a user can create their mappings with this.
func TermDebugSendCommand(cmd)
if s:way == 'prompt'
- call chansend(s:gdbjob, a:cmd . "\n")
+ call chansend(s:gdbjob, $"{a:cmd}\n")
else
let do_continue = 0
if !s:stopped
@@ -589,7 +591,7 @@ func TermDebugSendCommand(cmd)
sleep 10m
endif
" TODO: should we prepend CTRL-U to clear the command?
- call chansend(s:gdb_job_id, a:cmd . "\r")
+ call chansend(s:gdb_job_id, $"{a:cmd}\r")
if do_continue
Continue
endif
@@ -602,11 +604,11 @@ endfunc
func s:SendResumingCommand(cmd)
if s:stopped
" reset s:stopped here, it may take a bit of time before we get a response
- let s:stopped = 0
+ let s:stopped = v:false
" call ch_log('assume that program is running after this command')
call s:SendCommand(a:cmd)
" else
- " call ch_log('dropping command, program is running: ' . a:cmd)
+ " call ch_log($'dropping command, program is running: {a:cmd}')
endif
endfunc
@@ -651,7 +653,7 @@ endfunc
" Function called when gdb outputs text.
func s:GdbOutCallback(job_id, msgs, event)
- "call ch_log('received from gdb: ' . a:text)
+ " call ch_log($'received from gdb: {a:text}')
let comm_msgs = []
let lines = []
@@ -710,7 +712,7 @@ endfunc
" - change \\ to \
func s:DecodeMessage(quotedText, literal)
if a:quotedText[0] != '"'
- call s:Echoerr('DecodeMessage(): missing quote in ' . a:quotedText)
+ call s:Echoerr($'DecodeMessage(): missing quote in {a:quotedText}')
return
endif
let msg = a:quotedText
@@ -776,23 +778,23 @@ endfunc
func s:EndDebugCommon()
let curwinid = win_getid()
- if exists('s:ptybuf') && s:ptybuf
- exe 'bwipe! ' . s:ptybuf
+ if exists('s:ptybufnr') && s:ptybufnr
+ exe $'bwipe! {s:ptybufnr}'
endif
- if s:asmbuf > 0 && bufexists(s:asmbuf)
- exe 'bwipe! ' . s:asmbuf
+ if s:asmbufnr > 0 && bufexists(s:asmbufnr)
+ exe $'bwipe! {s:asmbufnr}'
endif
- if s:varbuf > 0 && bufexists(s:varbuf)
- exe 'bwipe! ' . s:varbuf
+ if s:varbufnr > 0 && bufexists(s:varbufnr)
+ exe $'bwipe! {s:varbufnr}'
endif
- let s:running = 0
+ let s:running = v:false
" Restore 'signcolumn' in all buffers for which it was set.
call win_gotoid(s:sourcewin)
let was_buf = bufnr()
for bufnr in s:signcolumn_buflist
if bufexists(bufnr)
- exe bufnr .. "buf"
+ exe $":{bufnr}buf"
if exists('b:save_signcolumn')
let &signcolumn = b:save_signcolumn
unlet b:save_signcolumn
@@ -800,15 +802,15 @@ func s:EndDebugCommon()
endif
endfor
if bufexists(was_buf)
- exe was_buf .. "buf"
+ exe $":{was_buf}buf"
endif
call s:DeleteCommands()
call win_gotoid(curwinid)
- if s:save_columns > 0
- let &columns = s:save_columns
+ if s:saved_columns > 0
+ let &columns = s:saved_columns
endif
if exists('#User#TermdebugStopPost')
@@ -824,7 +826,7 @@ func s:EndPromptDebug(job_id, exit_code, event)
endif
if bufexists(s:promptbuf)
- exe 'bwipe! ' . s:promptbuf
+ exe $'bwipe! {s:promptbuf}'
endif
call s:EndDebugCommon()
@@ -853,7 +855,7 @@ func s:HandleDisasmMsg(msg)
set nomodified
set filetype=asm
- let lnum = search('^' . s:asm_addr)
+ let lnum = search($'^{s:asm_addr}')
if lnum != 0
call sign_unplace('TermDebug', #{id: s:asm_id})
call sign_place(s:asm_id, 'TermDebug', 'debugPC', '%', #{lnum: lnum})
@@ -915,11 +917,8 @@ func s:HandleVariablesMsg(msg)
silent! %delete _
let spaceBuffer = 20
- call setline(1, 'Type' .
- \ repeat(' ', 16) .
- \ 'Name' .
- \ repeat(' ', 16) .
- \ 'Value')
+ let spaces = repeat(' ', 16)
+ call setline(1, $'Type{spaces}Name{spaces}Value')
let cnt = 1
let capture = '{name=".\{-}",\%(arg=".\{-}",\)\{0,1\}type=".\{-}"\%(,value=".\{-}"\)\{0,1\}}'
let varinfo = matchstr(a:msg, capture, 0, cnt)
@@ -1027,8 +1026,8 @@ func s:InstallCommands()
let map = g:termdebug_map_K
endif
if map
- let s:k_map_saved = maparg('K', 'n', 0, 1)
- if !empty(s:k_map_saved) && !s:k_map_saved.buffer || empty(s:k_map_saved)
+ let s:saved_K_map = maparg('K', 'n', 0, 1)
+ if !empty(s:saved_K_map) && !s:saved_K_map.buffer || empty(s:saved_K_map)
nnoremap K :Evaluate<CR>
endif
endif
@@ -1038,8 +1037,8 @@ func s:InstallCommands()
let map = get(g:termdebug_config, 'map_plus', 1)
endif
if map
- let s:plus_map_saved = maparg('+', 'n', 0, 1)
- if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer || empty(s:plus_map_saved)
+ let s:saved_plus_map = maparg('+', 'n', 0, 1)
+ if !empty(s:saved_plus_map) && !s:saved_plus_map.buffer || empty(s:saved_plus_map)
nnoremap <expr> + $'<Cmd>{v:count1}Up<CR>'
endif
endif
@@ -1049,8 +1048,8 @@ func s:InstallCommands()
let map = get(g:termdebug_config, 'map_minus', 1)
endif
if map
- let s:minus_map_saved = maparg('-', 'n', 0, 1)
- if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer || empty(s:minus_map_saved)
+ let s:saved_minus_map = maparg('-', 'n', 0, 1)
+ if !empty(s:saved_minus_map) && !s:saved_minus_map.buffer || empty(s:saved_minus_map)
nnoremap <expr> - $'<Cmd>{v:count1}Down<CR>'
endif
endif
@@ -1118,32 +1117,32 @@ func s:DeleteCommands()
delcommand Var
delcommand Winbar
- if exists('s:k_map_saved')
- if !empty(s:k_map_saved) && !s:k_map_saved.buffer
+ if exists('s:saved_K_map')
+ if !empty(s:saved_K_map) && !s:saved_K_map.buffer
nunmap K
- call mapset(s:k_map_saved)
- elseif empty(s:k_map_saved)
+ call mapset(s:saved_K_map)
+ elseif empty(s:saved_K_map)
nunmap K
endif
- unlet s:k_map_saved
+ unlet s:saved_K_map
endif
- if exists('s:plus_map_saved')
- if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer
+ if exists('s:saved_plus_map')
+ if !empty(s:saved_plus_map) && !s:saved_plus_map.buffer
nunmap +
- call mapset(s:plus_map_saved)
- elseif empty(s:plus_map_saved)
+ call mapset(s:saved_plus_map)
+ elseif empty(s:saved_plus_map)
nunmap +
endif
- unlet s:plus_map_saved
+ unlet s:saved_plus_map
endif
- if exists('s:minus_map_saved')
- if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer
+ if exists('s:saved_minus_map')
+ if !empty(s:saved_minus_map) && !s:saved_minus_map.buffer
nunmap -
- call mapset(s:minus_map_saved)
- elseif empty(s:minus_map_saved)
+ call mapset(s:saved_minus_map)
+ elseif empty(s:saved_minus_map)
nunmap -
endif
- unlet s:minus_map_saved
+ unlet s:saved_minus_map
endif
if has('menu')
@@ -1182,16 +1181,21 @@ func s:DeleteCommands()
let s:BreakpointSigns = []
endfunc
+func s:QuoteArg(x)
+ " Find all the occurrences of " and \ and escape them and double quote
+ " the resulting string.
+ return printf('"%s"', a:x->substitute('[\\"]', '\\&', 'g'))
+endfunc
+
" :Until - Execute until past a specified position or current line
func s:Until(at)
if s:stopped
" reset s:stopped here, it may take a bit of time before we get a response
- let s:stopped = 0
+ let s:stopped = v:false
" call ch_log('assume that program is running after this command')
" Use the fname:lnum format
- let at = empty(a:at) ?
- \ fnameescape(expand('%:p')) . ':' . line('.') : a:at
- call s:SendCommand('-exec-until ' . at)
+ let at = empty(a:at) ? s:QuoteArg($"{expand('%:p')}:{line('.')}") : a:at
+ call s:SendCommand($'-exec-until {at}')
" else
" call ch_log('dropping command, program is running: exec-until')
endif
@@ -1209,12 +1213,11 @@ func s:SetBreakpoint(at, tbreak=v:false)
endif
" Use the fname:lnum format, older gdb can't handle --source.
- let at = empty(a:at) ?
- \ fnameescape(expand('%:p')) . ':' . line('.') : a:at
+ let at = empty(a:at) ? s:QuoteArg($"{expand('%:p')}:{line('.')}") : a:at
if a:tbreak
- let cmd = '-break-insert -t ' . at
+ let cmd = $'-break-insert -t {at}'
else
- let cmd = '-break-insert ' . at
+ let cmd = $'-break-insert {at}'
endif
call s:SendCommand(cmd)
if do_continue
@@ -1233,7 +1236,7 @@ func s:ClearBreakpoint()
for id in s:breakpoint_locations[bploc]
if has_key(s:breakpoints, id)
" Assume this always works, the reply is simply "^done".
- call s:SendCommand('-break-delete ' . id)
+ call s:SendCommand($'-break-delete {id}')
for subid in keys(s:breakpoints[id])
call sign_unplace('TermDebug',
\ #{id: s:Breakpoint2SignNumber(id, subid)})
@@ -1250,18 +1253,18 @@ func s:ClearBreakpoint()
if empty(s:breakpoint_locations[bploc])
unlet s:breakpoint_locations[bploc]
endif
- echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.'
+ echomsg $'Breakpoint {nr} cleared from line {lnum}.'
else
- call s: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 . '.'
+ echomsg $'No breakpoint to remove at line {lnum}.'
endif
endfunc
func s:Run(args)
if a:args != ''
- call s:SendResumingCommand('-exec-arguments ' . a:args)
+ call s:SendResumingCommand($'-exec-arguments {a:args}')
endif
call s:SendResumingCommand('-exec-run')
endfunc
@@ -1275,13 +1278,13 @@ func s:Frame(arg)
" 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 .'"')
+ 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 .'"')
+ 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 .'"')
+ call s:SendCommand($'-interpreter-exec mi "frame function {a:arg}"')
endif
endfunc
@@ -1307,10 +1310,10 @@ func s:SendEval(expr)
endif
" encoding expression to prevent bad errors
- let expr = a:expr
- let expr = substitute(expr, '\\', '\\\\', 'g')
- let expr = substitute(expr, '"', '\\"', 'g')
- call s:SendCommand('-data-evaluate-expression "' . expr . '"')
+ let expr_escaped = a:expr
+ \ ->substitute('\\', '\\\\', 'g')
+ \ ->substitute('"', '\\"', 'g')
+ call s:SendCommand($'-data-evaluate-expression "{expr_escaped}"')
let s:evalexpr = exprLHS
endfunc
@@ -1322,9 +1325,9 @@ func s:Evaluate(range, arg)
return
endif
let expr = s:GetEvaluationExpression(a:range, a:arg)
- let s:evalFromBalloonExpr = 1
+ let s:evalFromBalloonExpr = v:true
let s:evalFromBalloonExprResult = ''
- let s:ignoreEvalError = 0
+ let s:ignoreEvalError = v:false
call s:SendEval(expr)
endfunc
@@ -1343,12 +1346,12 @@ func s:GetEvaluationExpression(range, arg)
let expr = s:CleanupExpr(@v)
call setpos('.', pos)
call setreg('v', reg, regt)
- let s:evalFromBalloonExpr = 1
+ let s:evalFromBalloonExpr = v:true
else
" no evaluation provided: get from C-expression under cursor
" TODO: allow filetype specific lookup #9057
let expr = expand('<cexpr>')
- let s:evalFromBalloonExpr = 1
+ let s:evalFromBalloonExpr = v:true
endif
return expr
endfunc
@@ -1376,8 +1379,8 @@ func s:CleanupExpr(expr)
return expr
endfunc
-let s:ignoreEvalError = 0
-let s:evalFromBalloonExpr = 0
+let s:ignoreEvalError = v:false
+let s:evalFromBalloonExpr = v:false
let s:evalFromBalloonExprResult = ''
let s:eval_float_win_id = -1
@@ -1400,9 +1403,9 @@ func s:HandleEvaluate(msg)
\ ->substitute(' ', '\1', '')
if s:evalFromBalloonExpr
if s:evalFromBalloonExprResult == ''
- let s:evalFromBalloonExprResult = s:evalexpr . ': ' . value
+ let s:evalFromBalloonExprResult = $'{s:evalexpr}: {value}'
else
- let s:evalFromBalloonExprResult .= ' = ' . value
+ let s:evalFromBalloonExprResult ..= $' = {value}'
endif
" NEOVIM:
" - Result pretty-printing is not implemented. Vim prettifies the result
@@ -1414,13 +1417,13 @@ func s:HandleEvaluate(msg)
" first message.
let s:eval_float_win_id = luaeval('select(2, vim.lsp.util.open_floating_preview(_A))', [s:evalFromBalloonExprResult])
else
- echomsg '"' . s:evalexpr . '": ' . value
+ echomsg $'"{s:evalexpr}": {value}'
endif
if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$'
" Looks like a pointer, also display what it points to.
- let s:ignoreEvalError = 1
- call s:SendEval('*' . s:evalexpr)
+ let s:ignoreEvalError = v:true
+ call s:SendEval($'*{s:evalexpr}')
endif
endfunc
@@ -1428,8 +1431,8 @@ endfunc
func s:HandleError(msg)
if s:ignoreEvalError
" Result of s:SendEval() failed, ignore.
- let s:ignoreEvalError = 0
- let s:evalFromBalloonExpr = 0
+ let s:ignoreEvalError = v:false
+ let s:evalFromBalloonExpr = v:false
return
endif
let msgVal = substitute(a:msg, '.*msg="\(.*\)"', '\1', '')
@@ -1471,7 +1474,7 @@ func s:GotoAsmwinOrCreateIt()
" 60 is approx spaceBuffer * 3
if winwidth(0) > (78 + 60)
let mdf = 'vert'
- exe mdf .. ' ' .. 60 .. 'new'
+ exe $'{mdf} :60new'
else
exe 'rightbelow new'
endif
@@ -1489,23 +1492,23 @@ func s:GotoAsmwinOrCreateIt()
setlocal signcolumn=no
setlocal modifiable
- if s:asmbuf > 0 && bufexists(s:asmbuf)
- exe 'buffer' . s:asmbuf
+ if s:asmbufnr > 0 && bufexists(s:asmbufnr)
+ exe $'buffer {s:asmbufnr}'
elseif empty(glob('Termdebug-asm-listing'))
silent file Termdebug-asm-listing
- let s:asmbuf = bufnr('Termdebug-asm-listing')
+ let s:asmbufnr = bufnr('Termdebug-asm-listing')
else
call s:Echoerr("You have a file/folder named 'Termdebug-asm-listing'.
\ Please exit and rename it because Termdebug may not work as expected.")
endif
if mdf != 'vert' && s:GetDisasmWindowHeight() > 0
- exe 'resize ' .. s:GetDisasmWindowHeight()
+ exe $'resize {s:GetDisasmWindowHeight()}'
endif
endif
if s:asm_addr != ''
- let lnum = search('^' . s:asm_addr)
+ let lnum = search($'^{s:asm_addr}')
if lnum == 0
if s:stopped
call s:SendCommand('disassemble $pc')
@@ -1544,7 +1547,7 @@ func s:GotoVariableswinOrCreateIt()
" 60 is approx spaceBuffer * 3
if winwidth(0) > (78 + 60)
let mdf = 'vert'
- exe mdf .. ' ' .. 60 .. 'new'
+ exe $'{mdf} :60new'
else
exe 'rightbelow new'
endif
@@ -1561,18 +1564,18 @@ func s:GotoVariableswinOrCreateIt()
setlocal signcolumn=no
setlocal modifiable
- if s:varbuf > 0 && bufexists(s:varbuf)
- exe 'buffer' . s:varbuf
+ if s:varbufnr > 0 && bufexists(s:varbufnr)
+ exe $'buffer {s:varbufnr}'
elseif empty(glob('Termdebug-variables-listing'))
silent file Termdebug-variables-listing
- let s:varbuf = bufnr('Termdebug-variables-listing')
+ let s:varbufnr = bufnr('Termdebug-variables-listing')
else
call s:Echoerr("You have a file/folder named 'Termdebug-variables-listing'.
\ Please exit and rename it because Termdebug may not work as expected.")
endif
if mdf != 'vert' && s:GetVariablesWindowHeight() > 0
- exe 'resize ' .. s:GetVariablesWindowHeight()
+ exe $'resize {s:GetVariablesWindowHeight()}'
endif
endif
@@ -1588,14 +1591,14 @@ func s:HandleCursor(msg)
if a:msg =~ '^\*stopped'
"call ch_log('program stopped')
- let s:stopped = 1
+ let s:stopped = v:true
if a:msg =~ '^\*stopped,reason="exited-normally"'
- let s:running = 0
+ let s:running = v:false
endif
elseif a:msg =~ '^\*running'
"call ch_log('program running')
- let s:stopped = 0
- let s:running = 1
+ let s:stopped = v:false
+ let s:running = v:true
endif
if a:msg =~ 'fullname='
@@ -1611,7 +1614,7 @@ func s:HandleCursor(msg)
let curwinid = win_getid()
if win_gotoid(s:asmwin)
- let lnum = search('^' . s:asm_addr)
+ let lnum = search($'^{s:asm_addr}')
if lnum == 0
call s:SendCommand('disassemble $pc')
else
@@ -1633,7 +1636,7 @@ func s:HandleCursor(msg)
if lnum =~ '^[0-9]*$'
call s:GotoSourcewinOrCreateIt()
if expand('%:p') != fnamemodify(fname, ':p')
- echomsg 'different fname: "' .. expand('%:p') .. '" vs "' .. fnamemodify(fname, ':p') .. '"'
+ echomsg $"different fname: '{expand('%:p')}' vs '{fnamemodify(fname, ':p')}'"
augroup Termdebug
" Always open a file read-only instead of showing the ATTENTION
" prompt, since it is unlikely we want to edit the file.
@@ -1645,17 +1648,17 @@ func s:HandleCursor(msg)
augroup END
if &modified
" TODO: find existing window
- exe 'split ' . fnameescape(fname)
+ exe $'split {fnameescape(fname)}'
let s:sourcewin = win_getid()
call s:InstallWinbar(0)
else
- exe 'edit ' . fnameescape(fname)
+ exe $'edit {fnameescape(fname)}'
endif
augroup Termdebug
au! SwapExists
augroup END
endif
- exe lnum
+ exe $":{lnum}"
normal! zv
call sign_unplace('TermDebug', #{id: s:pc_id})
call sign_place(s:pc_id, 'TermDebug', 'debugPC', fname,
@@ -1694,7 +1697,7 @@ func s:CreateBreakpoint(id, subid, enabled)
let label = 'F+'
endif
endif
- call sign_define('debugBreakpoint' .. nr,
+ call sign_define($'debugBreakpoint{nr}',
\ #{text: slice(label, 0, 2),
\ texthl: hiName})
endif
@@ -1712,7 +1715,7 @@ func s:HandleNewBreakpoint(msg, modifiedFlag)
if a:msg =~ 'pending='
let nr = substitute(a:msg, '.*number=\"\([0-9.]*\)\".*', '\1', '')
let target = substitute(a:msg, '.*pending=\"\([^"]*\)\".*', '\1', '')
- echomsg 'Breakpoint ' . nr . ' (' . target . ') pending.'
+ echomsg $'Breakpoint {nr} ({target}) pending.'
endif
return
endif
@@ -1757,9 +1760,9 @@ func s:HandleNewBreakpoint(msg, modifiedFlag)
if bufloaded(fname)
call s:PlaceSign(id, subid, entry)
- let posMsg = ' at line ' . lnum . '.'
+ let posMsg = $' at line {lnum}.'
else
- let posMsg = ' in ' . fname . ' at line ' . lnum . '.'
+ let posMsg = $' in {fname} at line {lnum}.'
endif
if !a:modifiedFlag
let actionTaken = 'created'
@@ -1768,14 +1771,14 @@ func s:HandleNewBreakpoint(msg, modifiedFlag)
else
let actionTaken = 'enabled'
endif
- echomsg 'Breakpoint ' . nr . ' ' . actionTaken . posMsg
+ echom $'Breakpoint {nr} {actionTaken}{posMsg}'
endfor
endfunc
func s:PlaceSign(id, subid, entry)
let nr = printf('%d.%d', a:id, a:subid)
call sign_place(s:Breakpoint2SignNumber(a:id, a:subid), 'TermDebug',
- \ 'debugBreakpoint' .. nr, a:entry['fname'],
+ \ $'debugBreakpoint{nr}', a:entry['fname'],
\ #{lnum: a:entry['lnum'], priority: 110})
let a:entry['placed'] = 1
endfunc
@@ -1796,7 +1799,7 @@ func s:HandleBreakpointDelete(msg)
endif
endfor
unlet s:breakpoints[id]
- echomsg 'Breakpoint ' . id . ' cleared.'
+ echomsg $'Breakpoint {id} cleared.'
endif
endfunc
@@ -1808,7 +1811,7 @@ func s:HandleProgramRun(msg)
return
endif
let s:pid = nr
- "call ch_log('Detected process ID: ' . s:pid)
+ " call ch_log($'Detected process ID: {s:pid}')
endfunc
" Handle a BufRead autocommand event: place any signs.