Nvim : Add <C-o> in input mode to switch lines & refactor keys a bit.

This commit is contained in:
Dmitry Voronin 2024-10-08 04:02:46 +03:00
parent c5269f51f3
commit 4ff7248751
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
6 changed files with 60 additions and 46 deletions

View file

@ -68,14 +68,17 @@ in {
./module/plugin/lsp/Nix.nix
./module/key/Autocomplete.nix
./module/key/Buffer.nix
./module/key/Cmd.nix
./module/key/Colorscheme.nix
./module/key/Comment.nix
./module/key/Common.nix
./module/key/Filetree.nix
./module/key/Gitsigns.nix
./module/key/Navigation.nix
./module/key/Newline.nix
./module/key/Ollama.nix
./module/key/Save.nix
./module/key/Sort.nix
./module/key/TabWidth.nix
./module/key/Telescope.nix
./module/key/Terminal.nix
./module/key/Trouble.nix

View file

@ -0,0 +1,11 @@
{ ... }: {
text = ''
-- Remap ; to :.
rekey_normal(";", ":")
rekey_visual(";", ":")
-- Repeat previous command.
rekey_normal("<Leader>.", "@:")
rekey_visual("<Leader>.", "@:")
'';
}

View file

@ -1,45 +0,0 @@
{ ... }: {
text = ''
-- Write all we can and exit. Created this to drop non-writable stuff when piping to nvim.
function bye()
pcall(vim.cmd, "wa")
vim.cmd[[qa!]]
end
function toggle_tab_width()
if vim.bo.shiftwidth == 2 then
vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
vim.bo.softtabstop = 4
elseif vim.bo.shiftwidth == 4 then
vim.bo.shiftwidth = 8
vim.bo.tabstop = 8
vim.bo.softtabstop = 8
elseif vim.bo.shiftwidth == 8 then
vim.bo.shiftwidth = 2
vim.bo.tabstop = 2
vim.bo.softtabstop = 2
end
end
rekey_normal("<Leader><Tab>", "<cmd>lua toggle_tab_width()<cr>")
-- Repeat previous command.
rekey_normal("<Leader>.", "@:")
rekey_visual("<Leader>.", "@:")
-- Save everything.
rekey_normal("<C-s>", "<cmd>wa!<cr>")
rekey_input("<C-s>", "<cmd>wa!<cr>")
-- Save all we can and leave.
rekey_normal("<Leader>z", "<cmd>lua bye()<cr>")
-- Just leave, no saves.
rekey_normal("<Leader>Z", "<cmd>qa!<cr>")
-- Remap ; to :.
rekey_normal(";", ":")
rekey_visual(";", ":")
'';
}

View file

@ -0,0 +1,5 @@
{ ... }: {
text = ''
remap_input("<C-o>", "<Esc>o")
'';
}

View file

@ -0,0 +1,19 @@
{ ... }: {
text = ''
-- Write all we can and exit. Created this to drop non-writable stuff when piping to nvim.
function bye()
pcall(vim.cmd, "wa")
vim.cmd[[qa!]]
end
-- Save everything.
rekey_normal("<C-s>", "<cmd>wa!<cr>")
rekey_input("<C-s>", "<cmd>wa!<cr>")
-- Save all we can and leave.
rekey_normal("<Leader>z", "<cmd>lua bye()<cr>")
-- Just leave, no saves.
rekey_normal("<Leader>Z", "<cmd>qa!<cr>")
'';
}

View file

@ -0,0 +1,21 @@
{ ... }: {
text = ''
function toggle_tab_width()
if vim.bo.shiftwidth == 2 then
vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
vim.bo.softtabstop = 4
elseif vim.bo.shiftwidth == 4 then
vim.bo.shiftwidth = 8
vim.bo.tabstop = 8
vim.bo.softtabstop = 8
elseif vim.bo.shiftwidth == 8 then
vim.bo.shiftwidth = 2
vim.bo.tabstop = 2
vim.bo.softtabstop = 2
end
end
rekey_normal("<Leader><Tab>", "<cmd>lua toggle_tab_width()<cr>")
'';
}