Merge pull request #235 from puremourning/double-width

Fix signs when ambiwidth=double
This commit is contained in:
mergify[bot] 2020-08-23 12:51:26 +00:00 • committed by GitHub
commit 3b03cedc2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 8 deletions

View file

@ -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()<CR>
nnoremenu WinBar.▶\ Cont :call vimspector#Continue()<CR>
nnoremenu WinBar.▷\ Pause :call vimspector#Pause()<CR>
nnoremenu WinBar.↷\ Next :call vimspector#StepOver()<CR>
nnoremenu WinBar.→\ Step :call vimspector#StepInto()<CR>
nnoremenu WinBar.←\ Out :call vimspector#StepOut()<CR>
nnoremenu WinBar.⟲: :call vimspector#Restart()<CR>
nnoremenu WinBar.✕ :call vimspector#Reset()<CR>
```
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()<CR>
nnoremenu WinBar.Continue :call vimspector#Continue()<CR>
nnoremenu WinBar.Pause :call vimspector#Pause()<CR>
nnoremenu WinBar.Step\ Over :call vimspector#StepOver()<CR>
nnoremenu WinBar.Step\ In :call vimspector#StepInto()<CR>
nnoremenu WinBar.Step\ Out :call vimspector#StepOut()<CR>
nnoremenu WinBar.Restart :call vimspector#Restart()<CR>
nnoremenu WinBar.Exit :call vimspector#Reset()<CR>
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

View file

@ -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 ):

View file

@ -51,7 +51,9 @@ class CodeView( object ):
vim.command( 'nnoremenu WinBar.✕ :call vimspector#Reset()<CR>' )
if not utils.SignDefined( 'vimspectorPC' ):
vim.command( 'sign define vimspectorPC text=\\ ▶ texthl=MatchParen' )
utils.DefineSign( 'vimspectorPC',
text = '▶',
texthl = 'MatchParen' )
def SetCurrentFrame( self, frame ):

View file

@ -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 }' )