Skip to content

Commit

Permalink
feat: add highlighting (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed Dec 12, 2023
1 parent dcb4f35 commit f1155c8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lua/hawtkeys/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ M = {}
Hawtkeys = require('hawtkeys.score')
ShowAll = require('hawtkeys.show_all')
M.search = function(text)
vim.api.nvim_buf_set_lines(ResultBuf, 0, -1, false, Hawtkeys.ScoreTable(text))
end
local returnText = Hawtkeys.ScoreTable(text)
vim.api.nvim_buf_set_lines(ResultBuf, 0, -1, false, returnText)

--loop lines and hilight if already mapped:
for i, line in ipairs(returnText) do
if string.match(line, "^Already mapped:.*") then
vim.api.nvim_buf_add_highlight(ResultBuf, -1, "ErrorMsg", i - 1, 0, -1)
vim.api.nvim_buf_add_highlight(ResultBuf, -1, "ErrorMsg", i, 0, -1)
vim.api.nvim_buf_add_highlight(ResultBuf, -1, "ErrorMsg", i - 2, 0, -1)
end
end
end
M.show = function()
ResultBuf = vim.api.nvim_create_buf(false, true)
local ui = vim.api.nvim_list_uis()[1]
Expand Down

0 comments on commit f1155c8

Please sign in to comment.