2024-02-25 04:13:48 +01:00
|
|
|
local map = vim.keymap.set
|
|
|
|
|
2024-02-27 15:07:57 +01:00
|
|
|
map("i", "<C-b>", "<ESC>^i", { desc = "Move Beginning of line" })
|
|
|
|
map("i", "<C-e>", "<End>", { desc = "Move End of line" })
|
|
|
|
map("i", "<C-h>", "<Left>", { desc = "Move Left" })
|
|
|
|
map("i", "<C-l>", "<Right>", { desc = "Move Right" })
|
|
|
|
map("i", "<C-j>", "<Down>", { desc = "Move Down" })
|
|
|
|
map("i", "<C-k>", "<Up>", { desc = "Move Up" })
|
|
|
|
|
|
|
|
map("n", "<Esc>", "<cmd>noh<CR>", { desc = "General Clear highlights" })
|
|
|
|
|
|
|
|
map("n", "<C-h>", "<C-w>h", { desc = "Switch Window left" })
|
|
|
|
map("n", "<C-l>", "<C-w>l", { desc = "Switch Window right" })
|
|
|
|
map("n", "<C-j>", "<C-w>j", { desc = "Switch Window down" })
|
|
|
|
map("n", "<C-k>", "<C-w>k", { desc = "Switch Window up" })
|
|
|
|
|
|
|
|
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" })
|
2024-02-25 04:13:48 +01:00
|
|
|
|
2024-02-27 08:01:36 +01:00
|
|
|
-- global lsp mappings
|
2024-02-25 04:13:48 +01:00
|
|
|
map("n", "<leader>fm", function()
|
|
|
|
vim.lsp.buf.format { async = true }
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Lsp formatting" })
|
2024-02-25 04:13:48 +01:00
|
|
|
|
2024-02-27 15:07:57 +01:00
|
|
|
map("n", "<leader>lf", vim.diagnostic.open_float, { desc = "Lsp floating diagnostics" })
|
|
|
|
map("n", "[d", vim.diagnostic.goto_prev, { desc = "Lsp prev diagnostic" })
|
|
|
|
map("n", "]d", vim.diagnostic.goto_next, { desc = "Lsp next diagnostic" })
|
|
|
|
map("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Lsp diagnostic loclist" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
-- tabufline
|
2024-02-27 15:07:57 +01:00
|
|
|
map("n", "<leader>b", "<cmd>enew<CR>", { desc = "Buffer New" })
|
|
|
|
|
2024-02-27 08:01:36 +01:00
|
|
|
map("n", "<tab>", function()
|
|
|
|
require("nvchad.tabufline").tabuflineNext()
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Buffer Goto next" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
map("n", "<S-tab>", function()
|
|
|
|
require("nvchad.tabufline").tabuflinePrev()
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Buffer Goto prev" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
map("n", "<leader>x", function()
|
|
|
|
require("nvchad.tabufline").close_buffer()
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Buffer Close" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
2024-02-27 15:07:57 +01:00
|
|
|
-- Comment
|
2024-02-27 08:01:36 +01:00
|
|
|
map("n", "<leader>/", function()
|
|
|
|
require("Comment.api").toggle.linewise.current()
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Comment Toggle" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
map(
|
|
|
|
"v",
|
|
|
|
"<leader>/",
|
|
|
|
"<ESC>:lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
|
2024-02-27 15:07:57 +01:00
|
|
|
{ desc = "Comment Toggle" }
|
2024-02-27 08:01:36 +01:00
|
|
|
)
|
|
|
|
|
2024-02-27 15:07:57 +01:00
|
|
|
-- 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" })
|
2024-02-25 04:13:48 +01:00
|
|
|
map(
|
2024-02-27 08:01:36 +01:00
|
|
|
"n",
|
|
|
|
"<leader>fa",
|
|
|
|
"<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>",
|
2024-02-27 15:07:57 +01:00
|
|
|
{ desc = "Telescope Find all files" }
|
2024-02-25 04:13:48 +01:00
|
|
|
)
|
|
|
|
|
2024-02-27 08:01:36 +01:00
|
|
|
-- terminal
|
2024-02-27 15:07:57 +01:00
|
|
|
map("t", "<C-x>", "<C-\\><C-N>", { desc = "Terminal Escape terminal mode" })
|
|
|
|
|
2024-02-27 08:01:36 +01:00
|
|
|
map("n", "<leader>h", function()
|
|
|
|
require("nvchad.term").new { pos = "sp", size = 0.3 }
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Terminal New horizontal term" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
map("n", "<leader>v", function()
|
|
|
|
require("nvchad.term").new { pos = "vsp", size = 0.3 }
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Terminal New vertical term" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
map({ "n", "t" }, "<A-v>", function()
|
|
|
|
require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 }
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Terminal Toggleable vertical term" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
map({ "n", "t" }, "<A-h>", function()
|
|
|
|
require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 }
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Terminal New horizontal term" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
map({ "n", "t" }, "<A-i>", function()
|
|
|
|
require("nvchad.term").toggle { pos = "float", id = "floatTerm" }
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Terminal Toggle Floating term" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
map("t", "<ESC>", function()
|
|
|
|
local win = vim.api.nvim_get_current_win()
|
|
|
|
vim.api.nvim_win_close(win, true)
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Terminal Close term in terminal mode" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
|
|
|
-- whichkey
|
2024-02-27 15:07:57 +01:00
|
|
|
map("n", "<leader>wK", "<cmd>WhichKey <CR>", { desc = "Whichkey all keymaps" })
|
|
|
|
|
2024-02-27 08:01:36 +01:00
|
|
|
map("n", "<leader>wk", function()
|
|
|
|
vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ")
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Whichkey query lookup" })
|
2024-02-27 08:01:36 +01:00
|
|
|
|
2024-02-27 15:07:57 +01:00
|
|
|
-- blankline
|
2024-02-27 08:01:36 +01:00
|
|
|
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)
|
2024-02-25 04:13:48 +01:00
|
|
|
end
|
2024-02-27 08:01:36 +01:00
|
|
|
end
|
2024-02-27 15:07:57 +01:00
|
|
|
end, { desc = "Blankline Jump to current context" })
|
2024-02-25 04:13:48 +01:00
|
|
|
|
2024-02-25 15:12:50 +01:00
|
|
|
pcall(require, "custom.mappings")
|