.dotfiles/.config/nvim/lua/nvwynd/keymaps.lua

68 lines
2.8 KiB
Lua
Raw Normal View History

2024-05-24 16:07:28 +03:00
local map = vim.keymap.set
-- generic
map("n", "<C-s>", "<cmd>w<CR>", { desc = "File Save" })
map("i", "<C-s>", "<cmd>w<CR>", { desc = "File Save" })
map("n", "<C-X>", "<cmd>bd!<CR>", { desc = "Close Buffer" })
map("v", "J", ":m '>+1<CR>gv=gv")
map("v", "K", ":m '<-2<CR>gv=gv")
-- terminal
map("t", "<ESC>", "<C-\\><C-n>")
-- telescope
map("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "[F]ind [F]iles" })
map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", { desc = "[F]ind [H]elp" })
map("n", "<leader>fr", "<cmd>Telescope oldfiles<CR>", { desc = "[F]ind [R]ecent" })
map(
"n",
"<leader>fsb",
"<cmd>Telescope current_buffer_fuzzy_find<CR>",
{ desc = "[F]ind [S]tring in current [B]uffer" }
)
map("n", "<leader>fsg", "<cmd>Telescope live_grep<CR>", { desc = "[F]ind [S]tring [G]lobal" })
map("n", "<leader>fgg", "<cmd>Telescope git_files<cr>", { desc = "[F]ind [G]it" })
map("n", "<leader>fgs", "<cmd>Telescope git_status<CR>", { desc = "[F]ind [G]it [S]tatus" })
map("n", "<leader>fgc", "<cmd>Telescope git_commits<CR>", { desc = "[F]ind [G]it [C]ommits" })
map(
"n",
"<leader><leader>",
"<cmd>Telescope buffers sort_mru=true sort_lastused=true ignore_current_buffer=true<CR>",
{ desc = "[ ] Find Buffers" }
)
-- lsp
map("n", "gd", "<cmd>Telescope lsp_definitions<cr>", { desc = "[G]oto [D]efinition" })
map("n", "gr", "<cmd>Telescope lsp_references<cr>", { desc = "[G]oto [R]eferences" })
map("n", "gI", "<cmd>Telescope lsp_implementations<cr>", { desc = "[G]oto [I]mplementations" })
map("n", "gD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" })
map("n", "<S-z>", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = 0 }))
2024-05-24 16:07:28 +03:00
end, { desc = "Toggle Inlay Hint" })
map("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "[C]ode [A]ction" })
map("n", "<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, { desc = "[W]orkspace [S]ymbols" })
map("n", "<leader>ds", require("telescope.builtin").lsp_document_symbols, { desc = "[D]ocument [S]ymbols" })
map("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e[n]ame" })
-- nvimtree
map("n", "<leader>n", "<cmd>Neotree toggle<CR>", { desc = "Toggle Filetree Window" })
map("n", "<leader>e", "<cmd>Neotree focus<CR>", { desc = "Focus Filetree Window" })
-- comment
-- _ represents the / key here
local comment_api = require("Comment.api")
map({ "n", "i" }, "<C-_>", function()
comment_api.toggle.linewise.current()
end, { desc = "Toggle Comment" })
map("x", "<C-_>", function()
local esc = vim.api.nvim_replace_termcodes("<ESC>", true, false, true)
vim.api.nvim_feedkeys(esc, "nx", false)
comment_api.toggle.linewise(vim.fn.visualmode())
end, { desc = "Toggle Comment" })
-- trouble
map("n", "<leader>t", "<cmd>TroubleToggle<CR>", { desc = "Trouble Toggle" })
-- whichkey
map("n", "<leader>wK", "<cmd>WhichKey<CR>", { desc = "Whichkey show all keymaps" })