nvim: make <Home> toggler work in insert and visual mode, too

This commit is contained in:
tastytea 2022-08-10 00:00:12 +02:00
parent 0c2b77555d
commit bdd03d2329
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM

View File

@ -33,12 +33,13 @@ map('n', '<M-Down>', '<C-e>')
map('v', '<Leader>y', '"+y')
map('n', '<Leader>p', '"+p')
map('n', '<Home>', -- toggle between beginning of line and beginning of text
-- toggle between beginning of line and beginning of text
map({ 'n', 'i', 'v' }, '<Home>',
function()
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
if (col == 0) then
-- TODO: figure out which function that calls
vim.api.nvim_feedkeys('^', 'n', false)
local col_new = vim.api.nvim_get_current_line():match('^%s*'):len()
vim.api.nvim_win_set_cursor(0, { row, col_new })
else
vim.api.nvim_win_set_cursor(0, { row, 0 })
end