Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: diagnostic virtual text wrapping mode option #449

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ call LspOptionsSet(#{
\ keepFocusInReferences: v:true,
\ completionTextEdit: v:true,
\ diagVirtualTextAlign: 'above',
\ diagVirtualTextWrap: 'default',
\ noNewlineInCompletion: v:false,
\ omniComplete: v:null,
\ outlineOnRight: v:false,
Expand Down
4 changes: 4 additions & 0 deletions autoload/lsp/diag.vim
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ export def DiagsRefresh(bnr: number, all: bool = false)
diag_symbol = 'E>'
endif

if lspOpts.diagVirtualTextWrap != 'default'
diag_wrap = lspOpts.diagVirtualTextWrap
endif

var signs: list<dict<any>> = []
var diags: list<dict<any>> = diagsMap[bnr].sortedDiagnostics
var inlineHLprops: list<list<list<number>>> = [[], [], [], [], []]
Expand Down
4 changes: 4 additions & 0 deletions autoload/lsp/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export var lspOptions: dict<any> = {
# Allowed values: 'above' | 'below' | 'after' (default is 'above')
diagVirtualTextAlign: 'above',

# Wrapping of virtual diagnostic text, when showDiagWithVirtualText is true.
# Allowed valuse: 'default' | 'truncate' | 'wrap' (default is 'default')
diagVirtualTextWrap: 'default',
TheDreadedAndy marked this conversation as resolved.
Show resolved Hide resolved

# Suppress adding a new line on completion selection with <CR>
noNewlineInCompletion: false,

Expand Down
18 changes: 17 additions & 1 deletion doc/lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
For Vim version 9.0 and above
Last change: Dec 2, 2023
Last change: Feb 7, 2024

==============================================================================
CONTENTS *lsp-contents*
Expand Down Expand Up @@ -516,6 +516,12 @@ diagVirtualTextAlign |String| option. Alignment of diagnostics messages
Allowed values are 'above', 'below' or 'after'
By default this is set to 'above',

*lsp-opt-diagVirtualTextWrap*
diagVirtualTextWrap |String| option. Wrapping of diagnostics messages
if |lsp-opt-showDiagWithVirtualText| is set to true.
Allowed values are 'default', 'wrap' or 'truncate'
By default this is set to 'default',

*lsp-opt-echoSignature*
echoSignature |Boolean| option. In insert mode, echo the current
symbol signature instead of showing it in a popup.
Expand Down Expand Up @@ -1413,6 +1419,16 @@ values for "diagVirtualTextAlign" are 'below', which positions the virtual
text below the affected line, and 'after', which displays the virtual text
immediately after the text on the affected line.

The wrapping of the virtual text can be controlled using the
"diagVirtualTextWrap" option. By default, this option is set to 'default',
which will 'truncate' virtual text placed 'above' or 'below' the affected
line, and 'wrap' text placed 'after' the affected line. Setting the value to
'wrap' or 'truncate' will force the specified behavior for the current
value of "diagVirtualTextAlign". If 'truncate' is used while
"diagVirtualTextAlign" is set to 'after', and a diagnostic message has already
been truncated for the affected line, then further diagnostics will be placed
below the affected line.

The LSP plugin offers convenient ways to highlight diagnostic messages, making
it easier to spot errors, warnings, hints, or informational notices within
your code. By default, the plugin automatically highlights the range of text
Expand Down