Skip to content

Commit 42a9aae

Browse files
committed
refactor: big changes for keybinds, disable codeium (enable manual) and indent
1 parent f883825 commit 42a9aae

File tree

8 files changed

+123
-107
lines changed

8 files changed

+123
-107
lines changed

init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ vim.cmd.highlight('IndentLineCurrent guifg=#b8bb26')
77

88
require("zedd.core.options")
99
require("zedd.core.keybinds")
10+
require("zedd.core.keybinds.keydump")
1011
require("zedd.plugins")

lua/zedd/core/keybinds.lua

Lines changed: 0 additions & 99 deletions
This file was deleted.

lua/zedd/core/keybinds/init.lua

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
local map = require("zedd.core.keybinds.keymap")
2+
local nmap = map.nmap
3+
local imap = map.imap
4+
local vmap = map.vmap
5+
6+
-- Buffer
7+
nmap("<S-c>", "<CMD>bd<CR>") -- close
8+
nmap("<S-q>", "<CMD>%bd|e#<CR>") -- close all
9+
10+
-- LSP
11+
nmap("<A-r>", "<CMD>Lspsaga rename<CR>")
12+
nmap("<A-h>", "<CMD>Lspsaga hover_doc<CR>")
13+
nmap("<A-i>", "<CMD>Lspsaga goto_definition<CR>")
14+
nmap("<A-j>", "<CMD>Lspsaga diagnostic_jump_next<CR>")
15+
nmap("<A-k>", "<CMD>Lspsaga diagnostic_jump_prev<CR>")
16+
17+
-- Folding
18+
nmap("ft", "vatzf<CR>")
19+
nmap("ff", "vaBzf")
20+
nmap("fo", "zo")
21+
22+
-- File manager
23+
nmap("<leader>e", "<cmd>NvimTreeFocus<cr>")
24+
25+
-- Telescope
26+
nmap("<Leader>fo", "<CMD>Telescope oldfiles<CR>")
27+
nmap("<Leader>ff", "<CMD>Telescope find_files<CR>")
28+
nmap("<Leader>lg", "<CMD>Telescope live_grep<CR>")
29+
nmap("<Leader>fd", "<CMD>Telescope diagnostics<CR>")
30+
nmap("<Leader><Leader>", "<CMD>Telescope buffers<CR>")
31+
32+
-- Custome
33+
imap("<C-f>", "${}<left>")
34+
imap("<", "<>")
35+
vmap("<S-j>", ":m '>+1<CR>gv=gv")
36+
vmap("<S-k>", ":m '<-2<CR>gv=gv")
37+
nmap("<leader>ww", "<CMD>w<CR>")
38+
nmap("<leader>wa", "<CMD>wa<CR>")
39+
nmap("r", "<C-r>")
40+
nmap("<leader>a", "gg<S-v>G")
41+
nmap("<Esc>", ":noh<CR>")
42+
43+
-- Jump
44+
nmap("m", "]m")
45+
nmap("<S-m>", "[m")
46+
47+
-- Replace
48+
nmap("<leader>n", [[:%s/\d\+/number/g]]) -- 2 -> number
49+
nmap("<leader>s", [[:%s/"[^"]*"/string/g]]) -- "hello" -> string
50+
nmap("<leader>b", [[:%s/\v(true|false)/boolean/g<CR>]]) -- true -> boolean
51+
nmap("<S-s>/", [[:%s//<left>]])
52+
53+
-- Git
54+
nmap("<leader>gd", "<CMD>Gitsign toggle_deleted<CR>")
55+
nmap("<leader>gcl", "<CMD>Gitsign toggle_current_line_blame<CR>")
56+
nmap("<leader>gbl", "<CMD>Gitsign blame_line<CR>")
57+
nmap("<leader>c0", "<CMD>GitConflictChooseNone<CR>")
58+
nmap("<leader>cb", "<CMD>GitConflictChooseBoth<CR>")
59+
nmap("<leader>co", "<CMD>GitConflictChooseOurs<CR>")
60+
nmap("<leader>ct", "<CMD>GitConflictChooseTheirs<CR>")
61+
nmap("<leader>cn", "<CMD>GitConflictNextConflict<CR>")
62+
nmap("<leader>cp", "<CMD>GitConflictPrevConflict<CR>")
63+
64+
-- Disable
65+
nmap("<up>", "<Nop>")
66+
nmap("<left>", "<Nop>")
67+
nmap("<right>", "<Nop>")
68+
nmap("<down>", "<Nop>")
69+
nmap("<C-z>", "<Nop>")

lua/zedd/core/keybinds/keydump.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
local M = {}
2+
3+
function M.dump()
4+
local lines = {}
5+
for _, map in ipairs(_G.my_keymaps) do
6+
table.insert(lines, string.format("[%s] %-15s → %s", map.mode, map.lhs, map.rhs))
7+
end
8+
table.sort(lines)
9+
10+
vim.cmd("new")
11+
local buf = vim.api.nvim_get_current_buf()
12+
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
13+
14+
vim.bo[buf].buftype = "nofile"
15+
vim.bo[buf].bufhidden = "wipe"
16+
vim.bo[buf].swapfile = false
17+
vim.bo[buf].modifiable = false
18+
vim.bo[buf].readonly = true
19+
end
20+
21+
vim.api.nvim_create_user_command("Keybinds", M.dump, {})
22+
23+
return M

lua/zedd/core/keybinds/keymap.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
local M = {}
2+
3+
_G.my_keymaps = {}
4+
5+
function M.map(mode, shortcut, command)
6+
if type(command) == "string" then
7+
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
8+
table.insert(_G.my_keymaps, { mode = mode, lhs = shortcut, rhs = command })
9+
else
10+
print("Error: Command must be a string")
11+
end
12+
end
13+
14+
function M.short(mode, shortcut, command)
15+
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = false })
16+
end
17+
18+
function M.nmap(shortcut, command) M.map("n", shortcut, command) end
19+
function M.imap(shortcut, command) M.map("i", shortcut, command) end
20+
function M.vmap(shortcut, command) M.map("v", shortcut, command) end
21+
22+
return M

lua/zedd/core/options.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ vim.opt.cmdheight = 2 -- height of laststatus at the bottom
1414
vim.opt.laststatus = 1 -- show where are you in at the bottom
1515
vim.opt.statusline = "%{expand('%:~:.')}"
1616
vim.opt.clipboard = "unnamedplus" -- copy from nvim to clipboard
17-
vim.opt.scrolloff = 4
17+
vim.opt.scrolloff = 10
1818
vim.opt.foldlevelstart = 99
1919

2020
vim.opt.mouse = "a"

lua/zedd/plugins/codeium/lazyspec.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
return {
2-
"Exafunction/codeium.vim",
3-
event = "InsertEnter",
4-
version = "1.8.37",
5-
config = function()
6-
require("zedd.plugins.codeium.keymap")
7-
end,
2+
"Exafunction/codeium.vim",
3+
cmd = { "CodeiumEnable", "CodeiumDisable", "CodeiumToggle" },
4+
version = "1.8.37",
5+
config = function()
6+
require("zedd.plugins.codeium.keymap")
7+
end,
88
}

lua/zedd/plugins/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ local plugins = {
1717
require("zedd.plugins.colors.lazyspec"),
1818
require("zedd.plugins.comments.lazyspec"),
1919
require("zedd.plugins.gruvbox.lazyspec"),
20-
require("zedd.plugins.indentmini.lazyspec"),
20+
-- require("zedd.plugins.indentmini.lazyspec"),
2121
require("zedd.plugins.lspconfig.lazyspec"),
2222
require("zedd.plugins.lspkind.lazyspec"),
2323
require("zedd.plugins.nvimtree.lazyspec"),

0 commit comments

Comments
 (0)