Skip to content

Commit 71807fd

Browse files
fix: move highlight documents to luaCAT comments
1 parent e8b268f commit 71807fd

File tree

5 files changed

+45
-24
lines changed

5 files changed

+45
-24
lines changed

doc/rest-nvim.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rest.nvim *rest-nvim*
66

77

88
==============================================================================
9-
Table of Contents *rocks-contents*
9+
Table of Contents *rest-contents*
1010

1111
rest.nvim ·························································· |rest-nvim|
1212
rest.nvim user commands ··································· |rest-nvim.commands|
@@ -252,10 +252,12 @@ rest.Opts.Highlight *rest.Opts.Highlight*
252252
rest.nvim highlight groups *rest-nvim.highlight-groups*
253253

254254

255-
Highlight Group Default Description
256-
-------------------- -------------------------------- --------------------
257-
RestText Comment winbar text
258-
RestPaneTitleNC Statement winbar text in non-current pane
259-
RestPaneTitle Statement + bold + underline winbar Text in current pane
255+
rest.nvim result UI implementation
256+
Highlight Group Default Description
257+
-------------------- -------------------------------- --------------------
258+
RestText Comment winbar text
259+
RestPaneTitleNC Statement winbar text in non-current pane
260+
RestPaneTitle Statement + bold + underline winbar Text in current pane
261+
260262

261263
vim:tw=78:ts=8:noet:ft=help:norl:

lua/rest-nvim/ui/highlights.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---@mod rest-nvim.highlight-groups rest.nvim highlight groups
2+
---
3+
---@brief [[
4+
---
5+
--- rest.nvim result UI implementation
6+
--- Highlight Group Default Description
7+
--- -------------------- -------------------------------- --------------------
8+
--- RestText Comment winbar text
9+
--- RestPaneTitleNC Statement winbar text in non-current pane
10+
--- RestPaneTitle Statement + bold + underline winbar Text in current pane
11+
---
12+
---@brief ]]
13+
14+
---Get the foreground value of a highlighting group
15+
---@param name string Highlighting group name
16+
---@return string
17+
local function get_hl_group_fg(name)
18+
-- This will still error out if the highlight doesn't exist
19+
return string.format("#%06X", vim.api.nvim_get_hl(0, { name = name, link = false }).fg)
20+
end
21+
22+
vim.api.nvim_set_hl(0, "RestText", { fg = get_hl_group_fg("Comment"), default = true })
23+
vim.api.nvim_set_hl(0, "RestPaneTitleNC", { fg = get_hl_group_fg("Statement"), default = true })
24+
vim.api.nvim_set_hl(0, "RestPaneTitle", {
25+
fg = get_hl_group_fg("Statement"),
26+
bold = true,
27+
underline = true,
28+
default = true,
29+
})
30+
31+
---@comment HACK: to generate documnet with vimcats
32+
local M = {}
33+
return M

lua/rest-nvim/ui/result.lua

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -225,23 +225,6 @@ local group = paneui.create_pane_group("rest_nvim_result", panes, {
225225
end,
226226
})
227227

228-
---Get the foreground value of a highlighting group
229-
---@param name string Highlighting group name
230-
---@return string
231-
local function get_hl_group_fg(name)
232-
-- This will still error out if the highlight doesn't exist
233-
return string.format("#%06X", vim.api.nvim_get_hl(0, { name = name, link = false }).fg)
234-
end
235-
236-
vim.api.nvim_set_hl(0, "RestText", { fg = get_hl_group_fg("Comment"), default = true })
237-
vim.api.nvim_set_hl(0, "RestPaneTitleNC", { fg = get_hl_group_fg("Statement"), default = true })
238-
vim.api.nvim_set_hl(0, "RestPaneTitle", {
239-
fg = get_hl_group_fg("Statement"),
240-
bold = true,
241-
underline = true,
242-
default = true,
243-
})
244-
245228
---Check if UI window is shown in current tabpage
246229
---@return boolean
247230
function ui.is_open()

nix/test-overlay.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ in {
3535
];
3636
text = /* bash */ ''
3737
mkdir -p doc
38-
vimcats lua/rest-nvim/{init,commands,autocmds,config/init}.lua > doc/rest-nvim.txt
38+
vimcats lua/rest-nvim/{init,commands,autocmds,config/init,ui/highlights}.lua > doc/rest-nvim.txt
3939
vimcats lua/rest-nvim/{api,client/init,parser/init,script/init,cookie_jar,utils,logger}.lua > doc/rest-nvim-api.txt
4040
vimcats lua/rest-nvim/client/curl/{cli,utils}.lua > doc/rest-nvim-client-curl.txt
4141
'';

plugin/rest-nvim.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,7 @@ require("rest-nvim.autocmds").setup()
7474
require("rest-nvim.commands").setup()
7575
vim.treesitter.language.register("http", "rest_nvim_result")
7676

77+
-- setup highlight groups
78+
require("rest-nvim.ui.highlights")
79+
7780
vim.g.loaded_rest_nvim = true

0 commit comments

Comments
 (0)