-- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here -- TODO: There are mappings that I did not port yet -- For instance: https://github.com/mjacobus/lvim/tree/main/after/ftplugin -- https://github.com/mjacobus/lvim/tree/main/after/plugin -- https://github.com/mjacobus/lvim/tree/main/autoload -- https://github.com/mjacobus/lvim/blob/main/after/plugin/legacy_setup.vim#L179-L212 -- Maybe some here: https://github.com/mjacobus/lvim/blob/main/lua/config/mappings.lua -- And here vim.keymap.del("n", "ff") -- conflicts with fword local map = LazyVim.safe_keymap_set -- better up/down map("i", "jj", "", { desc = "Go to normal mode" }) map("n", "w", "write", { desc = "Save file" }) local alternative_file = require("mj.alternate_file") map("n", "ak", function() alternative_file.open("next", "--exists") end, { desc = "Open next alternative file" }) map("n", "aj", function() alternative_file.open("prev", "--exists") end, { desc = "Open previous alternative file" }) -- Key mappings map("n", "Q", "q!", { desc = "Quit" }) map("n", "q", "bdelete", { desc = "Close buffer" }) map("n", "bdd", "bdelete!", { desc = "Close buffer!" }) map("n", "bda", "bufdo %bd!", { desc = "Close all buffers!" }) -- Notes map("n", "et", ":e ~/.tmp/notes/", { desc = "Edit notes" }) map("n", "on", ":e ~/.tmp/notes/notes.md", { desc = "Open notes" }) map("n", "con", ":e ~/.tmp/notes/notes.md", { desc = "Open notes" }) map("n", "j", function() require("mj.utils").close_terminal_buffer(true) end, { desc = "Close terminal buffer (true)" }) map("n", "k", function() require("mj.utils").close_terminal_buffer(false) end, { desc = "Close terminal buffer (false)" }) -- Search mappings map("n", "f", "/", { desc = "Search alias" }) map("n", "F", "nohlsearch", { desc = "Remove search highlight" }) -- Alternative file map("n", "af", "", { desc = "Alternative file" }) -- Avoid arrow keys in command mode map("c", "", "", { desc = "Move left" }) map("c", "", "", { desc = "Move down" }) map("c", "", "", { desc = "Move up" }) map("c", "", "", { desc = "Move right" }) map("c", "", "", { desc = "Delete" }) -- Alternative file navigation map("n", "ak", function() alternative_file.open("next", "--exists") end, { desc = "Next alternative file" }) map("n", "aj", function() alternative_file.open("prev", "--exists") end, { desc = "Previous alternative file" }) -- Diagnostic config vim.diagnostic.config({ virtual_text = false }) -- Running tests map("n", "at", function() require("mj.test_runner").run_all_tests() end, { desc = "Run all tests" }) map("n", "t", function() require("mj.test_runner").test_line() end, { desc = "Run test for current line" }) map("n", "t", function() require("mj.test_runner").test_line() end, { desc = "Run test for current line" }) map("n", "T", function() require("mj.test_runner").run_test_file() end, { desc = "Run test file" }) map("n", "st", function() require("mj.test_runner").run_shell_test() end, { desc = "Run ./shell_test" }) -- quick fix map("n", "gn", ":cnext", { desc = "Next quickfix occurrency" }) map("n", "gp", ":cprev", { desc = "Previous quickfix occurrency" }) -- rm file map("n", "rm", ":Delete", { desc = "Delete file" }) -- Last buffer map("n", "o", "", { desc = "Last buffer" }) -- Escape terminal mode with jj map("t", "", "", { desc = "Escape terminal mode" }) map("t", "jj", "", { desc = "Escape terminal mode with jj" }) -- Buffer changing map("n", "bn", ":bn", { desc = "Next buffer" }) map("n", "bp", ":bp", { desc = "Previous buffer" }) -- Find buffer file map("n", "b", ":b", { desc = "Find buffer file" }) -- Search map("n", "*", "*N", { desc = "Search and stay" }) -- Select all map("n", "a", "ggVG", { desc = "Select all" }) -- New tab map("n", "t", ":tabnew", { desc = "New tab" }) -- Jumps to the next position after the closest closing char map("i", ",e", "/[\\]})\"']:nohlsearcha", { desc = "Jump to next closing char" }) -- Adds arrow map("i", "", "=>", { desc = "Insert arrow" }) -- Rails specific map( "v", "h", ':s/\\:\\([a-zA-Z_]\\+\\)\\s\\+=>/\\=printf("%s:", submatch(1))/g:let @/ = ""', { desc = "Convert hash rocket to symbol" } ) map("n", "qq", ":q", { desc = "Quit" }) -- Reload buffer map("n", "rel", ":e", { desc = "Reload buffer" }) -- Find map("n", "f", "/", { desc = "Find" }) map("n", "*", ":find", { desc = "Find file" }) -- Use Q for formatting the current paragraph (or selection) map("v", "Q", "gq", { desc = "Format selection" }) map("n", "Q", "gqap", { desc = "Format paragraph" }) -- Buffer resizing mappings (shift + arrow key) map("n", "", "+", { desc = "Resize buffer up" }) map("n", "", "-", { desc = "Resize buffer down" }) map("n", "", "<", { desc = "Resize buffer left" }) map("n", "", ">", { desc = "Resize buffer right" }) map("n", "xx", ":!chmod +x %", { desc = "Make file executable" })