From 08297376a85a1719518507e54fca9de954d2376a Mon Sep 17 00:00:00 2001 From: Petri Hienonen Date: Thu, 23 May 2024 13:56:00 +0300 Subject: Agenix configuration --- home/nvim/keymaps.lua | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 home/nvim/keymaps.lua (limited to 'home/nvim/keymaps.lua') diff --git a/home/nvim/keymaps.lua b/home/nvim/keymaps.lua new file mode 100644 index 0000000..d8907bf --- /dev/null +++ b/home/nvim/keymaps.lua @@ -0,0 +1,86 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " +vim.keymap.set("v", "<", "", ">gv", { desc = "Indent right" }) + +vim.keymap.set("n", "", "Pick buffers", { desc = "Search open files" }) +vim.keymap.set("n", "ff", "Pick files", { desc = "Search all files" }) +vim.keymap.set("n", "fh", "Pick help", { desc = "Search help tags" }) + +-- Alternative navigation (more intuitive) +vim.keymap.set("n", "tn", ":tabnew", { desc = "New tab" }) +vim.keymap.set("n", "tx", ":tabclose", { desc = "Close tab" }) + +-- Tab moving +vim.keymap.set("n", "tm", ":tabmove", { desc = "Move tab" }) +vim.keymap.set("n", "t>", ":tabmove +1", { desc = "Move tab right" }) +vim.keymap.set("n", "t<", ":tabmove -1", { desc = "Move tab left" }) + +vim.keymap.set("n", "dq", vim.diagnostic.disable) +vim.keymap.set("n", "ds", vim.diagnostic.enable) + +vim.keymap.set({ "n", "x" }, "gy", '"+y', { desc = "Copy to clipboard" }) +vim.keymap.set({ "n", "x" }, "gp", '"+p', { desc = "Paste clipboard text" }) + +vim.keymap.set("n", "", "nohlsearch") +vim.keymap.set( + "n", + "q", + vim.diagnostic.setloclist, + { desc = "Open diagnostic [Q]uickfix list" } +) +vim.keymap.set("n", "q", ":bpspbnbd", { desc = "Close buffer" }) +vim.keymap.set("n", "Q", ":bd!", { desc = "Force close buffer" }) +vim.keymap.set("t", "", "", { desc = "Exit terminal mode" }) + +vim.keymap.set("n", "", "", { desc = "Move focus to the left window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the right window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the lower window" }) +vim.keymap.set("n", "", "", { desc = "Move focus to the upper window" }) + +vim.keymap.set("n", "e", ":lua MiniFiles.open()", { desc = "Open [E]xplorer" }) + +vim.keymap.set("n", "", "DapContinue", { desc = "DAP: Continue" }) +vim.keymap.set("n", "bp", "DapToggleBreakpoint", { desc = "DAP: Toggle Breakpoint" }) +vim.keymap.set("n", "", "DapStepOver", { desc = "DAP: Step Over" }) +vim.keymap.set("n", "", "DapStepInto", { desc = "DAP: Step Into" }) +vim.keymap.set("n", "", "DapStepOut", { desc = "DAP: Step Out" }) +vim.keymap.set("n", "dt", "DapTerminate", { desc = "DAP: Terminate" }) + +local function tab_complete() + if vim.fn.pumvisible() == 1 then + -- navigate to next item in completion menu + return "" + end + + local c = vim.fn.col(".") - 1 + local is_whitespace = c == 0 or vim.fn.getline("."):sub(c, c):match("%s") + + if is_whitespace then + -- insert tab + return "" + end + + local lsp_completion = vim.bo.omnifunc == "v:lua.vim.lsp.omnifunc" + + if lsp_completion then + -- trigger lsp code completion + return "" + end + + -- suggest words in current buffer + return "" +end + +local function tab_prev() + if vim.fn.pumvisible() == 1 then + -- navigate to previous item in completion menu + return "" + end + + -- insert tab + return "" +end + +vim.keymap.set("i", "", tab_complete, { expr = true }) +vim.keymap.set("i", "", tab_prev, { expr = true }) -- cgit v1.2.3-70-g09d2