Skip to content

Commit

Permalink
Introduce GrepperQuery highlight group (#252)
Browse files Browse the repository at this point in the history
The behavior changed in this commit: `8b78347`. The decision was to
unconditionally highlight the query like the user's colorscheme
highlights string literals.

I'd like to be able to customize this without changing how all string
literals look, so I've introduced a new `GrepperQuery` highlight group
that links to `String` by default. This means that there should be no
change by default.

I have not written tests for this but I have tested it in my own
configuration files by adding this line:

```vim
hi link GrepperQuery Normal
```

As seen in the diff, there is prior art for introducing new highlighting
groups in grepper already--`GrepperPrompt` is a highlight group that
controls the color of everything before the `>` (which displays the
search program and flags). There do not appear to be any tests for that
feature either, otherwise I would have cargo culted some to test this
feature.
  • Loading branch information
jez committed Aug 30, 2021
1 parent 1c3c4c6 commit 2b93535
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions doc/grepper.txt
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,19 @@ COLORS *grepper-colors*

Prompt:~

Default highlight group: GrepperPrompt linked to |hl-Question|.
Default highlight group: GrepperPrompt linked to |hl-Question|. To change:
>
highlight GrepperPrompt ctermfg=160 guifg=#ff0000 cterm=NONE
>
Query:~

Default highlight group: GrepperQuery linked to |hl-String|. To change:
>
highlight link GrepperQuery Normal
>
Error messages:~

Default highlight group: |hl-ErrorMsg|
Default highlight group: |hl-ErrorMsg|. To change:
>
highlight ErrorMsg ctermfg=160 ctermbg=NONE cterm=NONE
<
Expand Down
3 changes: 2 additions & 1 deletion plugin/grepper.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let g:loaded_grepper = 1
" ..ad\\f40+$':-# @=,!;%^&&*()_{}/ /4304\'""?`9$343%$ ^adfadf[ad)[(

highlight default link GrepperPrompt Question
highlight default link GrepperQuery String

"
" Default values that get used for missing values in g:grepper.
Expand Down Expand Up @@ -804,7 +805,7 @@ function! s:prompt(flags)
\ 'prompt': prompt_text,
\ 'default': a:flags.query,
\ 'completion': 'customlist,grepper#complete_files',
\ 'highlight': { cmdline -> [[0, len(cmdline), 'String']] },
\ 'highlight': { cmdline -> [[0, len(cmdline), 'GrepperQuery']] },
\ })
else
let a:flags.query = input(prompt_text, a:flags.query,
Expand Down

0 comments on commit 2b93535

Please sign in to comment.