Compare commits

..

3 commits

Author SHA1 Message Date
leafee98 e4de3f2670 map lsp, goto {tdDri}, action {Ra}, diag {npq} 2023-12-15 13:19:59 +08:00
leafee98 fdab14f6dc map gitsign next/prev to <l>h{np}, preview as <l>hv 2023-12-15 13:19:23 +08:00
leafee98 7c7e823b54 fix: <leader>nh not work 2023-12-15 12:41:29 +08:00
3 changed files with 17 additions and 14 deletions

View file

@ -18,6 +18,9 @@ vim.o.list = true
vim.o.relativenumber = true vim.o.relativenumber = true
vim.o.number = true vim.o.number = true
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.keymap.set("n", "\\q", "<cmd>wincmd q<cr>", { silent = true }) vim.keymap.set("n", "\\q", "<cmd>wincmd q<cr>", { silent = true })
vim.keymap.set("n", "zh", "<cmd>wincmd h<cr>", { silent = true }) vim.keymap.set("n", "zh", "<cmd>wincmd h<cr>", { silent = true })
vim.keymap.set("n", "zj", "<cmd>wincmd j<cr>", { silent = true }) vim.keymap.set("n", "zj", "<cmd>wincmd j<cr>", { silent = true })
@ -35,9 +38,6 @@ vim.keymap.set("n", "zx", "<cmd>bdelete<cr>", { silent = true })
vim.keymap.set("n", "<leader>nh", "<cmd>nohlsearch<cr>", { silent = true }) vim.keymap.set("n", "<leader>nh", "<cmd>nohlsearch<cr>", { silent = true })
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Load custom config -- Load custom config
custom = { custom = {
full_feature = false, full_feature = false,

View file

@ -12,13 +12,13 @@ return {
vim.keymap.set(mode, l, r, opts) vim.keymap.set(mode, l, r, opts)
end end
m("n", "<leader>hj", function() m("n", "<leader>hn", function()
if vim.wo.diff then return "]c" end if vim.wo.diff then return "]c" end
vim.schedule(function() gs.next_hunk() end) vim.schedule(function() gs.next_hunk() end)
return "<Ignore>" return "<Ignore>"
end, {expr=true}) end, {expr=true})
m("n", "<leader>hk", function() m("n", "<leader>hp", function()
if vim.wo.diff then return "[c" end if vim.wo.diff then return "[c" end
vim.schedule(function() gs.prev_hunk() end) vim.schedule(function() gs.prev_hunk() end)
return "<Ignore>" return "<Ignore>"
@ -31,7 +31,7 @@ return {
m("n", "<leader>hS", gs.stage_buffer) m("n", "<leader>hS", gs.stage_buffer)
m("n", "<leader>hu", gs.undo_stage_hunk) m("n", "<leader>hu", gs.undo_stage_hunk)
m("n", "<leader>hR", gs.reset_buffer) m("n", "<leader>hR", gs.reset_buffer)
m("n", "<leader>hp", gs.preview_hunk) m("n", "<leader>hv", gs.preview_hunk)
m("n", "<leader>hb", function() gs.blame_line{full=true} end) m("n", "<leader>hb", function() gs.blame_line{full=true} end)
m("n", "<leader>htb", gs.toggle_current_line_blame) m("n", "<leader>htb", gs.toggle_current_line_blame)
m("n", "<leader>hd", gs.diffthis) m("n", "<leader>hd", gs.diffthis)

View file

@ -15,6 +15,7 @@ function setup_keymap_lsp()
-- Buffer local mappings. -- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf } local opts = { buffer = ev.buf }
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
@ -26,10 +27,9 @@ function setup_keymap_lsp()
vim.keymap.set("n", "<leader>wl", function() vim.keymap.set("n", "<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts) end, opts)
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts) vim.keymap.set("n", "gR", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) vim.keymap.set({ "n", "v" }, "ga", vim.lsp.buf.code_action, opts)
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) vim.keymap.set("n", "g=", function()
vim.keymap.set("n", "<leader>f", function()
vim.lsp.buf.format { async = true } vim.lsp.buf.format { async = true }
end, opts) end, opts)
end, end,
@ -92,10 +92,13 @@ return {
setup_keymap_lsp() setup_keymap_lsp()
end, end,
keys = { keys = {
{ "<leader>e", vim.diagnostic.open_float, mode = "n" }, { "gs", "<cmd>LspStart<cr>", mode = "n" },
{ "[d", vim.diagnostic.goto_prev, mode = "n" }, { "gS", "<cmd>LspStop<cr>", mode = "n" },
{ "]d", vim.diagnostic.goto_next, mode = "n" }, { "gI", "<cmd>LspInfo<cr>", mode = "n" },
{ "<leader>q", vim.diagnostic.setloclist, mode = "n" } { "ge", vim.diagnostic.open_float, mode = "n" },
{ "gp", vim.diagnostic.goto_prev, mode = "n" },
{ "gn", vim.diagnostic.goto_next, mode = "n" },
{ "gq", vim.diagnostic.setloclist, mode = "n" }
}, },
}, },
} }