Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local M = {} -- M stands for module (I think)
- -- https://vi.stackexchange.com/questions/31206
- -- https://vi.stackexchange.com/a/36950/7339
- M.flash_cursorline = function()
- local cursorline_state = lua print(vim.opt.cursorline:get())
- vim.opt.cursorline = true
- vim.cmd([[hi CursorLine guifg=#FFFFFF guibg=#FF9509]])
- vim.fn.timer_start(200, function()
- vim.cmd([[hi CursorLine guifg=NONE guibg=NONE]])
- if cursorline_state == false then
- vim.opt.cursorline = false
- end
- end)
- end
- -- Below we can see the mappings using map helper
- -- map helper
- -- Reference: https://oroques.dev/notes/neovim-init/
- local function map(mode, lhs, rhs, opts)
- local options = { noremap = true }
- if opts then
- options = vim.tbl_extend("force", options, opts)
- end
- vim.api.nvim_set_keymap(mode, lhs, rhs, options)
- end
- map('n', 'n', 'nzz:lua require("user.utils").flash_cursorline()<CR>Nn')
- map('n', 'N', 'Nzz:lua require("user.utils").flash_cursorline()<CR>nN')
- map("n", "<c-o>", '<c-o>zv:lua require("user.utils").flash_cursorline()<cr>', { silent = true })
- map("n", "<c-i>", '<c-i>zv:lua require("user.utils").flash_cursorline()<cr>', { silent = true })
- -- Aditional ideas:
- -- 1 - each WinEnter event flashes the cursorline
- return M
Add Comment
Please, Sign In to add comment