From f1155c8e4e87c73724291f3fac71e8dcf39b421f Mon Sep 17 00:00:00 2001 From: Tristan Knight Date: Tue, 12 Dec 2023 19:13:08 +0000 Subject: [PATCH] feat: add highlighting (#3) --- lua/hawtkeys/ui.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lua/hawtkeys/ui.lua b/lua/hawtkeys/ui.lua index d4b4840..62b50eb 100644 --- a/lua/hawtkeys/ui.lua +++ b/lua/hawtkeys/ui.lua @@ -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]