From 07b60efd8058bb515998f50048b511d50f9671f8 Mon Sep 17 00:00:00 2001 From: Isak Samsten Date: Mon, 17 Apr 2023 13:53:34 +0200 Subject: feat(diagnostic): specify diagnostic virtual text prefix as a function - vim.diagnostic.config() now accepts a function for the virtual_text.prefix option, which allows for rendering e.g., diagnostic severities differently. --- runtime/doc/diagnostic.txt | 7 +++++-- runtime/doc/news.txt | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 025a7dccfc..bfcc1c9092 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -392,8 +392,11 @@ config({opts}, {namespace}) *vim.diagnostic.config()* always show the diagnostic source. • spacing: (number) Amount of empty spaces inserted at the beginning of the virtual text. - • prefix: (string) Prepend diagnostic message with - prefix. + • prefix: (string or function) prepend diagnostic + message with prefix. If a function, it must have the + signature (diagnostic) -> string, where {diagnostic} + is of type |diagnostic-structure|. This can be used + to render diagnostic symbols or error codes. • suffix: (string or function) Append diagnostic message with suffix. If a function, it must have the signature (diagnostic) -> string, where {diagnostic} diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index f196c3d445..dc541fcf37 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -48,6 +48,9 @@ The following changes to existing APIs or features add new behavior. • |vim.region()| can use a string accepted by |getpos()| as position. +• vim.diagnostic.config() now accepts a function for the virtual_text.prefix + option, which allows for rendering e.g., diagnostic severities differently. + ============================================================================== REMOVED FEATURES *news-removed* -- cgit