-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ac389d
commit bfb7fb7
Showing
8 changed files
with
184 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
local M = {} | ||
|
||
M.report_tab_focused = "ReportTabFocused" | ||
M.report_tab_unfocused = "ReportTabUnfocused" | ||
M.title_highlight = "TitleHighlight" | ||
|
||
local hl_groups = { | ||
report_tab_unfocused = { | ||
name = M.report_tab_unfocused, | ||
bg = "#888888", | ||
fg = "#222222", | ||
default = true, | ||
}, | ||
report_tab_focused = { | ||
name = M.report_tab_focused, | ||
bg = "#ABE9B3", | ||
fg = "#222222", | ||
default = true, | ||
}, | ||
title_highlight = { | ||
name = M.title_highlight, | ||
bg = "#6C8EBF", | ||
fg = "#222222", | ||
default = true, | ||
}, | ||
} | ||
|
||
function M.init() | ||
for _, hl in pairs(hl_groups) do | ||
local command = "highlight " | ||
.. hl.name | ||
.. " guifg=" | ||
.. hl.fg | ||
.. " guibg=" | ||
.. hl.bg | ||
vim.api.nvim_command(command) | ||
end | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
local highlights = require("hardtime.ui.highlights") | ||
|
||
local M = {} | ||
|
||
function M.render_title(title, bufnr) | ||
local buf_width = vim.api.nvim_win_get_width(0) | ||
|
||
local indent_length = math.floor((buf_width - #title) / 2) | ||
|
||
local indent = string.rep(" ", indent_length) | ||
|
||
vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, { indent .. title }) | ||
|
||
vim.api.nvim_buf_add_highlight( | ||
bufnr, | ||
0, | ||
highlights.title_highlight, | ||
0, | ||
indent_length, | ||
indent_length + #title | ||
) | ||
end | ||
|
||
function M.render_report(reports, bufnr) | ||
local hints = {} | ||
|
||
for index, report in ipairs(reports) do | ||
local repetition = " (" .. report[2] .. ")" | ||
local hint = index .. ". " .. report[1] .. repetition | ||
table.insert(hints, hint) | ||
end | ||
|
||
vim.api.nvim_buf_set_lines(bufnr, 6, -1, false, hints) | ||
end | ||
|
||
local function find_highlighted_indexes(tabs) | ||
local result = {} | ||
|
||
local start = 0 | ||
|
||
for i = 1, #tabs do | ||
local ending = start + #tabs[i] | ||
table.insert(result, { start, ending }) | ||
start = ending + 1 | ||
end | ||
|
||
return result | ||
end | ||
|
||
function M.render_tabs(tabs, picked_tab_idx, bufnr) | ||
highlights.init() | ||
|
||
vim.api.nvim_buf_set_lines( | ||
bufnr, | ||
2, | ||
2, | ||
false, | ||
{ table.concat(tabs, " ") } | ||
) | ||
|
||
local indexes = find_highlighted_indexes(tabs) | ||
|
||
for i, indices in ipairs(indexes) do | ||
local start_index = indices[1] | ||
local end_index = indices[2] | ||
|
||
if i == picked_tab_idx then | ||
vim.api.nvim_buf_add_highlight( | ||
bufnr, | ||
2, | ||
highlights.report_tab_focused, | ||
2, | ||
start_index, | ||
end_index | ||
) | ||
else | ||
vim.api.nvim_buf_add_highlight( | ||
bufnr, | ||
2, | ||
highlights.report_tab_unfocused, | ||
2, | ||
start_index, | ||
end_index | ||
) | ||
end | ||
end | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.