Skip to content

Commit e0c7118

Browse files
committed
refactor(#2826): move all winhl to appearance constants
1 parent 8438a74 commit e0c7118

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

lua/nvim-tree/appearance/init.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,29 @@ M.HIGHLIGHT_GROUPS = {
134134
{ group = "NvimTreeDiagnosticHintFolderHL", link = "NvimTreeDiagnosticHintFileHL" },
135135
}
136136

137+
-- winhighlight for most cases
138+
M.WIN_HL = table.concat({
139+
"EndOfBuffer:NvimTreeEndOfBuffer",
140+
"CursorLine:NvimTreeCursorLine",
141+
"CursorLineNr:NvimTreeCursorLineNr",
142+
"LineNr:NvimTreeLineNr",
143+
"WinSeparator:NvimTreeWinSeparator",
144+
"StatusLine:NvimTreeStatusLine",
145+
"StatusLineNC:NvimTreeStatuslineNC",
146+
"SignColumn:NvimTreeSignColumn",
147+
"Normal:NvimTreeNormal",
148+
"NormalNC:NvimTreeNormalNC",
149+
"NormalFloat:NvimTreeNormalFloat",
150+
"FloatBorder:NvimTreeNormalFloatBorder",
151+
}, ",")
152+
153+
-- winhighlight for help
154+
M.WIN_HL_HELP = table.concat({
155+
"NormalFloat:NvimTreeNormalFloat",
156+
"WinSeparator:NvimTreeWinSeparator",
157+
"CursorLine:NvimTreeCursorLine",
158+
}, ",")
159+
137160
-- nvim-tree highlight groups to legacy
138161
M.LEGACY_LINKS = {
139162
NvimTreeModifiedIcon = "NvimTreeModifiedFile",

lua/nvim-tree/explorer/view.lua

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
local appearance = require("nvim-tree.appearance")
12
local events = require("nvim-tree.events")
23
local utils = require("nvim-tree.utils")
34
local log = require("nvim-tree.log")
@@ -78,20 +79,7 @@ function View:new(args)
7879
cursorlineopt = "both",
7980
colorcolumn = "0",
8081
wrap = false,
81-
winhl = table.concat({
82-
"EndOfBuffer:NvimTreeEndOfBuffer",
83-
"CursorLine:NvimTreeCursorLine",
84-
"CursorLineNr:NvimTreeCursorLineNr",
85-
"LineNr:NvimTreeLineNr",
86-
"WinSeparator:NvimTreeWinSeparator",
87-
"StatusLine:NvimTreeStatusLine",
88-
"StatusLineNC:NvimTreeStatuslineNC",
89-
"SignColumn:NvimTreeSignColumn",
90-
"Normal:NvimTreeNormal",
91-
"NormalNC:NvimTreeNormalNC",
92-
"NormalFloat:NvimTreeNormalFloat",
93-
"FloatBorder:NvimTreeNormalFloatBorder",
94-
}, ","),
82+
winhl = appearance.WIN_HL,
9583
}
9684

9785
self:configure_width(self.explorer.opts.view.width)
@@ -640,7 +628,7 @@ end
640628
function View:reset_winhl()
641629
local winnr = self:get_winnr()
642630
if winnr and vim.api.nvim_win_is_valid(winnr) then
643-
vim.wo[self:get_winnr()].winhl = self.winopts.winhl
631+
vim.wo[self:get_winnr()].winhl = appearance.WIN_HL
644632
end
645633
end
646634

lua/nvim-tree/help.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1+
local appearance = require("nvim-tree.appearance")
12
local keymap = require("nvim-tree.keymap")
23
local api = {} -- circular dependency
34

45
local PAT_MOUSE = "^<.*Mouse"
56
local PAT_CTRL = "^<C%-"
67
local PAT_SPECIAL = "^<.+"
78

8-
local WIN_HL = table.concat({
9-
"NormalFloat:NvimTreeNormalFloat",
10-
"WinSeparator:NvimTreeWinSeparator",
11-
"CursorLine:NvimTreeCursorLine",
12-
}, ",")
13-
149
local namespace_help_id = vim.api.nvim_create_namespace("NvimTreeHelp")
1510

1611
local M = {
@@ -210,7 +205,7 @@ local function open()
210205
})
211206

212207
-- style it a bit like the tree
213-
vim.wo[M.winnr].winhl = WIN_HL
208+
vim.wo[M.winnr].winhl = appearance.WIN_HL_HELP
214209
vim.wo[M.winnr].cursorline = M.config.cursorline
215210

216211
local function toggle_sort()

lua/nvim-tree/renderer/components/full-name.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
local M = {}
2-
1+
local appearance = require("nvim-tree.appearance")
32
local utils = require("nvim-tree.utils")
4-
local view = require("nvim-tree.view")
3+
4+
local M = {}
55

66
local function hide(win)
77
if win then
@@ -72,7 +72,7 @@ local function show(opts)
7272
style = "minimal",
7373
border = "none"
7474
})
75-
vim.wo[M.popup_win].winhl = view.View.winopts.winhl
75+
vim.wo[M.popup_win].winhl = appearance.WIN_HL
7676

7777
local ns_id = vim.api.nvim_get_namespaces()["NvimTreeHighlights"]
7878
local extmarks = vim.api.nvim_buf_get_extmarks(0, ns_id, { line_nr - 1, 0 }, { line_nr - 1, -1 }, { details = true })

0 commit comments

Comments
 (0)