Skip to content

Commit

Permalink
feat(nvim): Toggle semicolon keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjones2014 committed Jun 14, 2024
1 parent 98b2f29 commit dc2806d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nvim/lua/my/legendary/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@ function M.default_keymaps()
{
'<C-;>',
function()
print('run')
local line = vim.api.nvim_get_current_line()
vim.api.nvim_set_current_line(string.format('%s;', line))
local suffix = string.match(line, '.*(;%s*)')
if suffix then
line = string.sub(line, 1, #line - #suffix)
else
line = string.format('%s;', line)
end
vim.api.nvim_set_current_line(line)
end,
mode = 'i',
description = 'Add semicolon to end of line from insert mode',
mode = { 'n', 'i' },
description = 'Toggle semicolon',
},
}
end
Expand Down

0 comments on commit dc2806d

Please sign in to comment.