Skip to content

Commit

Permalink
refactor: modify the highlight groups
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Jul 31, 2024
1 parent 27e9175 commit 5e5cdf4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,15 @@ require("quicker").setup({

## Highlights

These are the highlight groups that are used to style the quickfix buffer. The easiest way to change the styling is to use `:help winhighlight` in the setup `opts` option.
These are the highlight groups that are used to style the quickfix buffer. You can set these
highlight groups yourself or use `:help winhighlight` in the setup `opts` option to override them
for just the quickfix window.

- `QuickFixHeaderHard` - Used for the header that divides results from different files
- `QuickFixHeaderSoft` - Used for the header that divides results within the same file
- `Delimiter` - Used for the divider between filename, line number, and text
- `LineNr` - Used for the line number
- `Directory` - Used for the filename
- `QuickFixLineNr` - Used for the line number
- `QuickFixFilename` - Used for the filename
- `DiagnosticSign*` - Used for the signs that display the quickfix error type

## API
Expand Down
6 changes: 6 additions & 0 deletions lua/quicker/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ function M.set_highlight_groups()
if vim.tbl_isempty(vim.api.nvim_get_hl(0, { name = "QuickFixHeaderSoft" })) then
vim.api.nvim_set_hl(0, "QuickFixHeaderSoft", { link = "Comment", default = true })
end
if vim.tbl_isempty(vim.api.nvim_get_hl(0, { name = "QuickFixFilename" })) then
vim.api.nvim_set_hl(0, "QuickFixFilename", { link = "Directory", default = true })
end
if vim.tbl_isempty(vim.api.nvim_get_hl(0, { name = "QuickFixLineNr" })) then
vim.api.nvim_set_hl(0, "QuickFixLineNr", { link = "LineNr", default = true })
end
end

return M
8 changes: 3 additions & 5 deletions lua/quicker/syntax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ function M.set_syntax()
local v = config.borders.vert
local cmd = string.format(
[[
syn match qfFileName /^[^%s]*/ nextgroup=qfSeparatorLeft
syn match qfSeparatorLeft /%s/ contained nextgroup=qfLineNr
syn match qfLineNr /[^%s]*/ contained nextgroup=qfSeparatorRight
syn match QuickFixFilename /^[^%s]*/ nextgroup=qfSeparatorLeft
syn match qfSeparatorLeft /%s/ contained nextgroup=QuickFixLineNr
syn match QuickFixLineNr /[^%s]*/ contained nextgroup=qfSeparatorRight
syn match qfSeparatorRight '%s' contained
hi def link qfFileName Directory
hi def link qfSeparatorLeft Delimiter
hi def link qfSeparatorRight Delimiter
hi def link qfLineNr LineNr
]],
v,
v,
Expand Down

0 comments on commit 5e5cdf4

Please sign in to comment.