- Bash: config file - Zsh: config file - Fish: config file and fish plugins - Nvim: config files - Kitty: config files
213 lines
8.5 KiB
Lua
213 lines
8.5 KiB
Lua
local map = vim.keymap.set
|
|
|
|
map("n", "<Esc>", "<cmd>noh<CR>", { desc = "General Clear highlights" })
|
|
|
|
map("n", "<C-s>", "<cmd>w<CR>", { desc = "File Save" })
|
|
map("n", "<C-c>", "<cmd>%y+<CR>", { desc = "File Copy whole" })
|
|
|
|
map("n", "<leader>n", "<cmd>set nu!<CR>", { desc = "Toggle Line number" })
|
|
map("n", "<leader>rn", "<cmd>set rnu!<CR>", { desc = "Toggle Relative number" })
|
|
map("n", "<leader>ch", "<cmd>NvCheatsheet<CR>", { desc = "Toggle NvCheatsheet" })
|
|
|
|
map("n", "<leader>fm", function()
|
|
require("conform").format { lsp_fallback = true }
|
|
end, { desc = "Format Files" })
|
|
|
|
-- lsp mappings
|
|
map({ "n", "v" }, "<A-CR>", "<cmd>Lspsaga code_action<CR>", { desc = "LSP code action" })
|
|
map({ "n", "v" }, "<A-p>", "<cmd>Lspsaga peek_definition<CR>", { desc = "LSP peek definition" })
|
|
map({ "n", "v" }, "<A-P>", "<cmd>Lspsaga peek_type_definition<CR>", { desc = "LSP peek type definition" })
|
|
map({ "n", "v" }, "<A-g>", "<cmd>Lspsaga goto_definition<CR>", { desc = "LSP goto definition" })
|
|
map({ "n", "v" }, "<A-G>", "<cmd>Lspsaga goto_type_definition<CR>", { desc = "LSP goto type definition" })
|
|
map({ "n", "v" }, "<A-r>", "<cmd>Lspsaga rename ++project<CR>", { desc = "LSP rename" })
|
|
map({ "n", "v" }, "<A-d>", "<cmd>Lspsaga diagnostic_jump_next<CR>", { desc = "LSP diagnostic next" })
|
|
map({ "n", "v" }, "<A-D>", "<cmd>Lspsaga diagnostic_jump_prev<CR>", { desc = "LSP diagnostic previous" })
|
|
|
|
-- tabufline
|
|
map("n", "<leader>b", "<cmd>enew<CR>", { desc = "Buffer New" })
|
|
|
|
map("n", "<tab>", function()
|
|
require("nvchad.tabufline").next()
|
|
end, { desc = "Buffer Goto next" })
|
|
|
|
map("n", "<S-tab>", function()
|
|
require("nvchad.tabufline").prev()
|
|
end, { desc = "Buffer Goto prev" })
|
|
|
|
map("n", "<leader>x", function()
|
|
require("nvchad.tabufline").close_buffer()
|
|
end, { desc = "Buffer Close" })
|
|
|
|
map("n", "<leader>t", "<cmd>tabnew<CR>", { desc = "Tab New" })
|
|
|
|
-- Comment
|
|
map("n", "<leader>/", "gcc", { desc = "Comment toggle", remap = true })
|
|
map("v", "<leader>/", "gc", { desc = "Comment toggle", remap = true })
|
|
|
|
-- Spider nvim movement
|
|
map({ "n", "v" }, "w", "<cmd>lua require('spider').motion('w')<CR>", {desc = "Spider Move to next word"})
|
|
map({ "n", "v" }, "b", "<cmd>lua require('spider').motion('b')<CR>", {desc = "Spider Move to previous word"})
|
|
map({ "n", "v" }, "e", "<cmd>lua require('spider').motion('e')<CR>", {desc = "Spider Move to end of word"})
|
|
|
|
-- nvimtree
|
|
map("n", "<C-n>", "<cmd>NvimTreeToggle<CR>", { desc = "Nvimtree Toggle window" })
|
|
map("n", "<leader>e", "<cmd>NvimTreeFocus<CR>", { desc = "Nvimtree Focus window" })
|
|
|
|
-- telescope
|
|
map("n", "<leader>fw", "<cmd>Telescope live_grep<CR>", { desc = "Telescope Live grep" })
|
|
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { desc = "Telescope Find buffers" })
|
|
map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", { desc = "Telescope Help page" })
|
|
|
|
map("n", "<leader>fo", "<cmd>Telescope oldfiles<CR>", { desc = "Telescope Find oldfiles" })
|
|
map("n", "<leader>fz", "<cmd>Telescope current_buffer_fuzzy_find<CR>", { desc = "Telescope Find in current buffer" })
|
|
map("n", "<leader>cm", "<cmd>Telescope git_commits<CR>", { desc = "Telescope Git commits" })
|
|
map("n", "<leader>gt", "<cmd>Telescope git_status<CR>", { desc = "Telescope Git status" })
|
|
map("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "Telescope Pick hidden term" })
|
|
map("n", "<leader>th", "<cmd>Telescope themes<CR>", { desc = "Telescope Nvchad themes" })
|
|
map("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Telescope Find files" })
|
|
map(
|
|
"n",
|
|
"<leader>fa",
|
|
"<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>",
|
|
{ desc = "Telescope Find all files" }
|
|
)
|
|
|
|
-- terminal
|
|
map("t", "<C-x>", "<C-\\><C-N>", { desc = "Terminal Escape terminal mode" })
|
|
|
|
map("t", "<ESC>", function()
|
|
local win = vim.api.nvim_get_current_win()
|
|
vim.api.nvim_win_close(win, true)
|
|
end, { desc = "Terminal Close term in terminal mode" })
|
|
|
|
-- new terminals
|
|
map("n", "<leader>h", function()
|
|
require("nvchad.term").new { pos = "sp", size = 0.4 }
|
|
end, { desc = "Terminal New horizontal term" })
|
|
|
|
map("n", "<leader>v", function()
|
|
require("nvchad.term").new { pos = "vsp", size = 0.5 }
|
|
end, { desc = "Terminal New vertical window" })
|
|
|
|
-- toggleable
|
|
-- map({ "n", "t" }, "<A-v>", function()
|
|
-- require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 }
|
|
-- end, { desc = "Terminal Toggleable vertical term" })
|
|
--
|
|
-- map({ "n", "t" }, "<A-h>", function()
|
|
-- require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.3 }
|
|
-- end, { desc = "Terminal New horizontal term" })
|
|
--
|
|
-- map({ "n", "t" }, "<A-i>", function()
|
|
-- require("nvchad.term").toggle { pos = "float", id = "floatTerm" }
|
|
-- end, { desc = "Terminal Toggle Floating term" })
|
|
|
|
-- whichkey
|
|
map("n", "<leader>wK", "<cmd>WhichKey <CR>", { desc = "Whichkey all keymaps" })
|
|
|
|
map("n", "<leader>wk", function()
|
|
vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ")
|
|
end, { desc = "Whichkey query lookup" })
|
|
|
|
-- blankline
|
|
map("n", "<leader>cc", function()
|
|
local config = { scope = {} }
|
|
config.scope.exclude = { language = {}, node_type = {} }
|
|
config.scope.include = { node_type = {} }
|
|
local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config)
|
|
|
|
if node then
|
|
local start_row, _, end_row, _ = node:range()
|
|
if start_row ~= end_row then
|
|
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 })
|
|
vim.api.nvim_feedkeys("_", "n", true)
|
|
end
|
|
end
|
|
end, { desc = "Blankline Jump to current context" })
|
|
|
|
-- copilotchat
|
|
map({ "n", "v" }, "<leader>ccp", function()
|
|
local actions = require("CopilotChat.actions")
|
|
require("CopilotChat.integrations.telescope").pick(actions.prompt_actions())
|
|
end, { desc = "CopilotChat - Prompt actions" })
|
|
|
|
map({ "n", "v" }, "<leader>ccq", function()
|
|
local input = vim.fn.input("Quick Chat: ")
|
|
if input ~= "" then
|
|
require("CopilotChat").ask(input, { selection = require("CopilotChat.select").buffer })
|
|
end
|
|
end, { desc = "CopilotChat - Quick chat" })
|
|
|
|
map({ "n", "v" }, "<leader>ccf", function()
|
|
require("CopilotChat").ask("Fix this, using the lsp diagnostics if needed", { selection = require("CopilotChat.select").visual })
|
|
end, { desc = "CopilotChat - Fix this" })
|
|
|
|
-- menu
|
|
-- vim.keymap.set("n", "<C-t>", function()
|
|
-- require("menu").open("default")
|
|
-- end, {})
|
|
--
|
|
-- vim.keymap.set("n", "<RightMouse>", function()
|
|
-- vim.cmd.exec '"normal! \\<RightMouse>"'
|
|
--
|
|
-- local options = vim.bo.ft == "NvimTree" and "nvimtree" or "default"
|
|
-- require("menu").open(options, { mouse = true })
|
|
-- end, {})
|
|
|
|
|
|
-- Custom mappings
|
|
map("n", "<space>", ":", { desc = "Enter command mode" })
|
|
map({ "n", "v" }, "j", "h", { desc = "Move left" })
|
|
map({ "n", "v" }, "k", "j", { desc = "Move down" })
|
|
map({ "n", "v" }, "l", "k", { desc = "Move up" })
|
|
map({ "n", "v" }, "m", "l", { desc = "Move right" })
|
|
map("n", "<C-j>", "<C-w>h", { desc = "Move the cursor to the left window" })
|
|
map("n", "<C-k>", "<C-w>j", { desc = "Move the cursor to the bottom window" })
|
|
map("n", "<C-l>", "<C-w>k", { desc = "Move the cursor to the upper window" })
|
|
map("n", "<C-m>", "<C-w>l", { desc = "Move the cursor to the right window" })
|
|
map("n", "<C-up>", "<C-w>+", { desc = "Enlarge window upwards" })
|
|
map("n", "<C-down>", "<C-w>-", { desc = "Enlarge window downwards" })
|
|
map("n", "<C-left>", "<C-w>>", { desc = "Enlarge window to the left" })
|
|
map("n", "<C-right>", "<C-w><", { desc = "Enlarge window to the rigth" })
|
|
map("n", "o", "o<ESC>")
|
|
map("n", "O", "O<ESC>")
|
|
map("n", "n", "nzz")
|
|
map("n", "N", "Nzz")
|
|
map({ "n", "v" }, "y", "\"+y")
|
|
map("n", "yy", "\"+yy")
|
|
map({ "n", "v" }, "Y", "\"+yg_")
|
|
map({ "n", "v" }, "p", "\"+p")
|
|
map({ "n", "v" }, "P", "\"+P")
|
|
map("n", "<leader>a", function()
|
|
require("treesj").toggle()
|
|
end, { desc = "Extends or retracts an instruction block" })
|
|
map({ "n", "v" }, "<leader>gb", "<cmd>Gitsigns blame<CR>", { desc = "Git blame" })
|
|
map("i", "jj", "<ESC>", { desc = "Enter normal mode" })
|
|
map("i", "<C-d>", "<ESC>ddi", { desc = "Delete a line" })
|
|
map("i", "<C-b>", "<ESC>^i", { desc = "Move Beginning of line" })
|
|
map("i", "<C-e>", "<End>", { desc = "Move End of line" })
|
|
map("i", "<C-j>", "<Left>", { desc = "Move Left" })
|
|
map("i", "<C-m>", "<Right>", { desc = "Move Right" })
|
|
map("i", "<C-k>", "<Down>", { desc = "Move Down" })
|
|
map("i", "<C-l>", "<Up>", { desc = "Move Up" })
|
|
|
|
-- Disable mappings
|
|
-- local nomap = vim.keymap.del
|
|
|
|
-- LSP unmappings are set in configs/lspconfig.lua
|
|
|
|
-- nomap("n", "h")
|
|
-- nomap("n", "j")
|
|
-- nomap("n", "k")
|
|
-- nomap("n", "l")
|
|
-- nomap("n", "<C-h>")
|
|
-- nomap("n", "<C-j>")
|
|
-- nomap("n", "<C-k>")
|
|
-- nomap("n", "<C-l>")
|
|
-- nomap("n", "<leader>")
|
|
|
|
-- nomap("v", "h")
|
|
-- nomap("v", "j")
|
|
-- nomap("v", "k")
|
|
-- nomap("v", "l")
|