aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-09-06 18:17:24 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-09-06 09:17:24 -0700
commit1dab52f87897d73c6a922be9b253de22b361cfb3 (patch)
tree639905f32e8d81bbc2beb244793f51b3ca9cc31b /src
parent64caeb13e68c9858ae41ce04131a6f623be5b54d (diff)
downloadrneovim-1dab52f87897d73c6a922be9b253de22b361cfb3.tar.gz
rneovim-1dab52f87897d73c6a922be9b253de22b361cfb3.tar.bz2
rneovim-1dab52f87897d73c6a922be9b253de22b361cfb3.zip
vim-patch:8.0.1332: enhance quickfix highlighting #10259
Problem: Highlighting in quickfix window could be better. (Axel Bender) Solution: Use the qfSeparator highlight item. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/93a32e2ec4b5a391c5006ca09f196e6510c8c2e9 This adds `syn_name2attr` already (from previous patch 8.0.1123, vim/vim@1b9645de3).
Diffstat (limited to 'src')
-rw-r--r--src/nvim/quickfix.c40
-rw-r--r--src/nvim/syntax.c12
2 files changed, 44 insertions, 8 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 26687f14f0..e24ccc38b0 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -40,6 +40,7 @@
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/strings.h"
+#include "nvim/syntax.h"
#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
@@ -2481,8 +2482,11 @@ void qf_list(exarg_T *eap)
int idx1 = 1;
int idx2 = -1;
char_u *arg = eap->arg;
- int all = eap->forceit; /* if not :cl!, only show
- recognised errors */
+ int qfFileAttr;
+ int qfSepAttr;
+ int qfLineAttr;
+ int all = eap->forceit; // if not :cl!, only show
+ // recognised errors
qf_info_T *qi = &ql_info;
if (eap->cmdidx == CMD_llist) {
@@ -2525,6 +2529,21 @@ void qf_list(exarg_T *eap)
// Shorten all the file names, so that it is easy to read.
shorten_fnames(false);
+ // Get the attributes for the different quickfix highlight items. Note
+ // that this depends on syntax items defined in the qf.vim syntax file
+ qfFileAttr = syn_name2attr((char_u *)"qfFileName");
+ if (qfFileAttr == 0) {
+ qfFileAttr = HL_ATTR(HLF_D);
+ }
+ qfSepAttr = syn_name2attr((char_u *)"qfSeparator");
+ if (qfSepAttr == 0) {
+ qfSepAttr = HL_ATTR(HLF_D);
+ }
+ qfLineAttr = syn_name2attr((char_u *)"qfLineNr");
+ if (qfLineAttr == 0) {
+ qfLineAttr = HL_ATTR(HLF_N);
+ }
+
if (qi->qf_lists[qi->qf_curlist].qf_nonevalid) {
all = true;
}
@@ -2574,22 +2593,27 @@ void qf_list(exarg_T *eap)
}
msg_putchar('\n');
msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
- ? HL_ATTR(HLF_QFL) : HL_ATTR(HLF_D));
+ ? HL_ATTR(HLF_QFL) : qfFileAttr);
+
+ if (qfp->qf_lnum != 0) {
+ msg_puts_attr(":", qfSepAttr);
+ }
if (qfp->qf_lnum == 0) {
IObuff[0] = NUL;
} else if (qfp->qf_col == 0) {
- vim_snprintf((char *)IObuff, IOSIZE, ":%" PRIdLINENR, qfp->qf_lnum);
+ vim_snprintf((char *)IObuff, IOSIZE, "%" PRIdLINENR, qfp->qf_lnum);
} else {
- vim_snprintf((char *)IObuff, IOSIZE, ":%" PRIdLINENR " col %d",
+ vim_snprintf((char *)IObuff, IOSIZE, "%" PRIdLINENR " col %d",
qfp->qf_lnum, qfp->qf_col);
}
- vim_snprintf((char *)IObuff + STRLEN(IObuff), IOSIZE, "%s:",
+ vim_snprintf((char *)IObuff + STRLEN(IObuff), IOSIZE, "%s",
(char *)qf_types(qfp->qf_type, qfp->qf_nr));
- msg_puts_attr((const char *)IObuff, HL_ATTR(HLF_N));
+ msg_puts_attr((const char *)IObuff, qfLineAttr);
+ msg_puts_attr(":", qfSepAttr);
if (qfp->qf_pattern != NULL) {
qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);
- xstrlcat((char *)IObuff, ":", IOSIZE);
msg_puts((const char *)IObuff);
+ msg_puts_attr(":", qfSepAttr);
}
msg_puts(" ");
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index f7de5f00d0..281ea7c4a3 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -7341,6 +7341,18 @@ int syn_name2id(const char_u *name)
return i + 1;
}
+/// Lookup a highlight group name and return its attributes.
+/// Return zero if not found.
+int syn_name2attr(char_u *name)
+{
+ int id = syn_name2id(name);
+
+ if (id != 0) {
+ return syn_id2attr(syn_get_final_id(id));
+ }
+ return 0;
+}
+
/*
* Return TRUE if highlight group "name" exists.
*/