diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-05-19 01:04:13 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-05-19 01:04:13 +0200 |
commit | 83ae474da5d424b0f060cabadf49e273e1b42c1f (patch) | |
tree | af8550d68cde0196ad1274314fca69e81733a972 | |
parent | f39dafe6c9cb686265fe8c96ae47067d30f71881 (diff) |
nvim: wip: add highlight
-rw-r--r-- | nvim/nvim/lua/highlight.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/nvim/nvim/lua/highlight.lua b/nvim/nvim/lua/highlight.lua new file mode 100644 index 0000000..2fe26e0 --- /dev/null +++ b/nvim/nvim/lua/highlight.lua @@ -0,0 +1,34 @@ +local ns = vim.api.nvim_create_namespace("highlight") + +-- Highlight when yanking (copying) text +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- TODO: +-- https://medium.com/@ankochem/neovim-highlighting-the-text-programmatically-with-lua-837fecfa36d2 +-- Highlight whatever the user selected +-- function highlight_selection() +-- local start = vim.api.nvim_buf_get_mark(0, '[') +-- local finish = vim.api.nvim_buf_get_mark(0, ']') +-- start[1] = start[1] - 1 +-- if start[1] < 0 then start[1] = 0 end +-- start[2] = start[2] + 1 +-- finish[1] = finish[1] - 1 +-- if finish[1] < 0 then finish[1] = 0 end +-- finish[2] = finish[2] + 1 +-- vim.highlight.range(0, ns, "IncSearch", start, finish) +-- end +-- +-- function clean_highlight() +-- vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) +-- vim.cmd("redraw") +-- end +-- +-- -- TODO +-- vim.keymap.set('n', '<C-h>', highlight_selection) +-- vim.keymap.set('n', '<C-l><C-l>', clean_highlight) |