1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
From 05f688cbab7227ccb5eec1483df90786e69797cb Mon Sep 17 00:00:00 2001
From: Boris Staletic <boris.staletic@protonmail.com>
Date: Sun, 4 Aug 2024 15:27:43 +0200
Subject: [PATCH] Allow soft-wrapping of lines in the signature help window
This looks ugly, but at least no data is lost due to lines going off
screen.
---
python/ycm/signature_help.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/python/ycm/signature_help.py b/python/ycm/signature_help.py
index 22ba1d5c..0793f73d 100644
--- a/python/ycm/signature_help.py
+++ b/python/ycm/signature_help.py
@@ -159,6 +159,15 @@ def UpdateSignatureHelp( state, signature_info ): # noqa
# inserting the char ?
col = int( screen_pos[ 'curscol' ] ) - 2
+ # Vim stops shifting the popup to the left if we turn on soft-wrapping.
+ # Instead, we want to first shift the popup to the left and then
+ # and then turn on wrapping.
+ max_line_length = max( len( item[ 'text' ] ) for item in buf_lines )
+ vim_width = vimsupport.GetIntValue( '&columns' )
+ line_available = vim_width - max( col, 1 )
+ if max_line_length > line_available:
+ col = vim_width - max_line_length
+
if col <= 0:
col = 1
@@ -172,6 +181,7 @@ def UpdateSignatureHelp( state, signature_info ): # noqa
# cursorline. So instead, we manually set 'cursorline' in the popup window
# and enable syntax based on the current file syntax)
"flip": 1,
+ "fixed": 1,
"padding": [ 0, 1, 0, 1 ], # Pad 1 char in X axis to match completion menu
"hidden": int( state.state == SignatureHelpState.ACTIVE_SUPPRESSED )
}
@@ -196,7 +206,7 @@ def UpdateSignatureHelp( state, signature_info ): # noqa
active_signature = int( signature_info.get( 'activeSignature', 0 ) )
vim.eval( f"win_execute( { state.popup_win_id }, "
- f"'set syntax={ syntax } cursorline | "
+ f"'set syntax={ syntax } cursorline wrap | "
f"call cursor( [ { active_signature + 1 }, 1 ] )' )" )
return state
--
2.47.1
|