diff --git a/README.md b/README.md index db6e025..1f21681 100644 --- a/README.md +++ b/README.md @@ -1353,17 +1353,31 @@ Vimsector uses them, they will not be replaced. So to customise the signs, define them in your `vimrc`. * `vimspectorBP`: A breakpoint. +* `vimspectorBPCond`: A conditional breakpoint. * `vimspectorBPDisabled`: A disabled breakpoint * `vimspectorPC` The program counter, i.e. current line. -For example, to use some unicode symbols, you could put this in your `vimrc`: +The default symbols are the equivalent of something like the following: ```viml -sign define vimspectorBP text=🔴 texthl=Normal -sign define vimspectorBPDisabled text=🔵 texthl=Normal -sign define vimspectorPC text=🔶 texthl=SpellBad +sign define vimspectorBP text=\ ● texthl=WarningMsg +sign define vimspectorBPCond text=\ ◆ texthl=WarningMsg +sign define vimspectorBPDisabled text=\ ● texthl=LineNr +sign define vimspectorPC text=\ ▶ texthl=MatchParen ``` +If the signs don't display properly, your font probably doesn't contain these +glyphs. You can easily change them by deifining the sign in your vimrc. For +example, you could put this in your `vimrc` to use some simple ASCII symbols: + +```viml +sign define vimspectorBP text=>> texthl=WarningMsg +sign define vimspectorBPCond text=>> texthl=WarningMsg +sign define vimspectorBPDisabled text=>> texthl=LIneNr +sign define vimspectorPC text=-> texthl=MatchParen +``` + + ## Changing the default window sizes > ***Please Note***: This cusomiation API is ***unstable***, meaning that it may @@ -1463,6 +1477,50 @@ In addition, the following key is added when triggering the * `g:vimspector_session_windows.terminal`: Window ID of the terminal window +## Customising the WinBar + +You can even customise the WinBar buttons by simply running the usual `menu` +(and `unmanu`) commands. + +By default, Vimspector uses something a bit like this: + +```viml +nnoremenu WinBar.■\ Stop :call vimspector#Stop() +nnoremenu WinBar.▶\ Cont :call vimspector#Continue() +nnoremenu WinBar.▷\ Pause :call vimspector#Pause() +nnoremenu WinBar.↷\ Next :call vimspector#StepOver() +nnoremenu WinBar.→\ Step :call vimspector#StepInto() +nnoremenu WinBar.←\ Out :call vimspector#StepOut() +nnoremenu WinBar.⟲: :call vimspector#Restart() +nnoremenu WinBar.✕ :call vimspector#Reset() +``` + +If you prefer a different layout or if the unicode symbols don't render +correctly in your font, you can customise this in the `VimspectorUICreated` +autocommand, for example: + +```viml +func! CustomiseUI() + call win_gotoid( g:vimspector_session_windows.code ) + " Clear the existing WinBar created by Vimspector + nunmenu WinBar + " Cretae our own WinBar + nnoremenu WinBar.Kill :call vimspector#Stop() + nnoremenu WinBar.Continue :call vimspector#Continue() + nnoremenu WinBar.Pause :call vimspector#Pause() + nnoremenu WinBar.Step\ Over :call vimspector#StepOver() + nnoremenu WinBar.Step\ In :call vimspector#StepInto() + nnoremenu WinBar.Step\ Out :call vimspector#StepOut() + nnoremenu WinBar.Restart :call vimspector#Restart() + nnoremenu WinBar.Exit :call vimspector#Reset() +endfunction + +augroup MyVimspectorUICustomistaion + autocmd! + autocmd User VimspectorUICreated call s:CustomiseUI() +augroup END +``` + ## Example There is some example code in `support/custom_ui_vimrc` showing how you can use @@ -1533,6 +1591,8 @@ hi link jsonComment Comment but in theory a single gadget can supply multiple `adapter` configs. Typically this happens when a `gadget` supplies different `adapter` config for, say remote debugging, or debugging in a container, etc. +8. The signs and winbar display funny symbols. How do i fix them? See + [this](#changing-the-default-signs) and [this](#customising-the-winbar) # Motivation diff --git a/python3/vimspector/breakpoints.py b/python3/vimspector/breakpoints.py index 59d1370..917804b 100644 --- a/python3/vimspector/breakpoints.py +++ b/python3/vimspector/breakpoints.py @@ -53,13 +53,19 @@ class ProjectBreakpoints( object ): self._next_sign_id = 1 if not utils.SignDefined( 'vimspectorBP' ): - vim.command( 'sign define vimspectorBP text=\\ ● texthl=WarningMsg' ) + utils.DefineSign( 'vimspectorBP', + text = '●', + texthl = 'WarningMsg' ) if not utils.SignDefined( 'vimspectorBPCond' ): - vim.command( 'sign define vimspectorBPCond text=\\ ◆ texthl=WarningMsg' ) + utils.DefineSign( 'vimspectorBPCond', + text = '◆', + texthl = 'WarningMsg' ) if not utils.SignDefined( 'vimspectorBPDisabled' ): - vim.command( 'sign define vimspectorBPDisabled text=\\ ● texthl=LineNr' ) + utils.DefineSign( 'vimspectorBPDisabled', + text = '●', + texthl = 'LineNr' ) def ConnectionUp( self, connection ): diff --git a/python3/vimspector/code.py b/python3/vimspector/code.py index 8e33ece..d8bd208 100644 --- a/python3/vimspector/code.py +++ b/python3/vimspector/code.py @@ -51,7 +51,9 @@ class CodeView( object ): vim.command( 'nnoremenu WinBar.✕ :call vimspector#Reset()' ) if not utils.SignDefined( 'vimspectorPC' ): - vim.command( 'sign define vimspectorPC text=\\ ▶ texthl=MatchParen' ) + utils.DefineSign( 'vimspectorPC', + text = '▶', + texthl = 'MatchParen' ) def SetCurrentFrame( self, frame ): diff --git a/python3/vimspector/utils.py b/python3/vimspector/utils.py index bc7c168..af76150 100644 --- a/python3/vimspector/utils.py +++ b/python3/vimspector/utils.py @@ -777,3 +777,13 @@ def WindowID( window, tab=None ): if tab is None: tab = window.tabpage return int( Call( 'win_getid', window.number, tab.number ) ) + + +def DefineSign( name, text, texthl, col = 'right' ): + if col == 'right': + if int( Call( 'strdisplaywidth', text ) ) < 2: + text = ' ' + text + + text = text.replace( ' ', r'\ ' ) + + vim.command( f'sign define { name } text={ text } texthl={ texthl }' )