Nvim : Add <C-o> in input mode to switch lines & refactor keys a bit.
This commit is contained in:
parent
c5269f51f3
commit
4ff7248751
|
@ -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
|
||||
|
|
11
home/config/nvim/module/key/Cmd.nix
Normal file
11
home/config/nvim/module/key/Cmd.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ ... }: {
|
||||
text = ''
|
||||
-- Remap ; to :.
|
||||
rekey_normal(";", ":")
|
||||
rekey_visual(";", ":")
|
||||
|
||||
-- Repeat previous command.
|
||||
rekey_normal("<Leader>.", "@:")
|
||||
rekey_visual("<Leader>.", "@:")
|
||||
'';
|
||||
}
|
|
@ -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(";", ":")
|
||||
'';
|
||||
}
|
5
home/config/nvim/module/key/Newline.nix
Normal file
5
home/config/nvim/module/key/Newline.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{ ... }: {
|
||||
text = ''
|
||||
remap_input("<C-o>", "<Esc>o")
|
||||
'';
|
||||
}
|
19
home/config/nvim/module/key/Save.nix
Normal file
19
home/config/nvim/module/key/Save.nix
Normal 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>")
|
||||
'';
|
||||
}
|
21
home/config/nvim/module/key/TabWidth.nix
Normal file
21
home/config/nvim/module/key/TabWidth.nix
Normal 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>")
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue