diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..f4d05d0 --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,104 @@ +-- File Explorer +vim.keymap.set('n', 'n', ':Neotree filesystem reveal left toggle') + +-- Telescope +vim.keymap.set('n', 'ff', ':Telescope find_files') +vim.keymap.set('n', 'tc', ':Telescope colorscheme') +vim.keymap.set('n', 'of', ':Telescope oldfiles') +vim.keymap.set('n', 'tl', ':Telescope live_grep') +vim.keymap.set('n', 'km', ':Telescope keymaps') +vim.keymap.set('n', 'tf', function() + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown({ + previewer = false, + })) +end) + +-- formatter +vim.keymap.set('n', 'ft', vim.lsp.buf.format, {}) + +-- buffer +vim.keymap.set('n', '', ':BufferNext') +vim.keymap.set('n', '', ':BufferPrevious') +vim.keymap.set('n', 'q', ':BufferClose') + +-- comment +vim.keymap.set('n', '/', 'gcc', { remap = true }) + +-- terminal +vim.keymap.set('n', 'tr', ':ToggleTerm') + +-- File Explorer +vim.keymap.set('n', 'e', function() + require('oil').toggle_float() +end) + +-- Clear search, diff update and redraw +vim.keymap.set({ 'i', 'n' }, '', 'noh', { desc = 'Escape and clear hlsearch' }) + +-- Move to window using the hjkl keys +vim.keymap.set('n', '', 'h', { desc = 'Go to Left Window', remap = true }) +vim.keymap.set('n', '', 'j', { desc = 'Go to Lower Window', remap = true }) +vim.keymap.set('n', '', 'k', { desc = 'Go to Upper Window', remap = true }) +vim.keymap.set('n', '', 'l', { desc = 'Go to Right Window', remap = true }) + +-- Move with shift-arrows +vim.keymap.set('n', '', '', { + desc = 'Move window to the left', +}) +vim.keymap.set('n', '', '', { + desc = 'Move window down', +}) +vim.keymap.set('n', '', '', { + desc = 'Move window up', +}) +vim.keymap.set('n', '', '', { + desc = 'Move window to the right', +}) + +-- Resize window using arrow keys +vim.keymap.set('n', '', 'resize +2', { desc = 'Increase Window Height' }) +vim.keymap.set('n', '', 'resize -2', { desc = 'Decrease Window Height' }) +vim.keymap.set('n', '', 'vertical resize -2', { desc = 'Decrease Window Width' }) +vim.keymap.set('n', '', 'vertical resize +2', { desc = 'Increase Window Width' }) + +-- clear notification +vim.keymap.set('n', 'mu', function() + require('notify').dismiss({ silent = true, pending = true }) +end, { desc = 'Dismiss All Notifications' }) + +-- Harpoon Keybinds +-- Open harpoon ui +vim.keymap.set('n', 'ho', function() + harpoon_ui.toggle_quick_menu() +end) + +-- Add current file to harpoon +vim.keymap.set('n', 'ha', function() + harpoon.mark.add_file() +end) + +-- Remove current file from harpoon +vim.keymap.set('n', 'hr', function() + harpoon.mark.rm_file() +end) + +-- Quickly jump to harpooned files +vim.keymap.set('n', '1', function() + harpoon.ui.nav_file(1) +end) + +vim.keymap.set('n', '2', function() + harpoon.ui.nav_file(2) +end) + +vim.keymap.set('n', '3', function() + harpoon.ui.nav_file(3) +end) + +vim.keymap.set('n', '4', function() + harpoon.ui.nav_file(4) +end) + +vim.keymap.set('n', '5', function() + harpoon.ui.nav_file(5) +end) diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/lua/remaps.lua b/lua/remaps.lua new file mode 100644 index 0000000..68300da --- /dev/null +++ b/lua/remaps.lua @@ -0,0 +1,278 @@ +local function map(mode, lhs, rhs, opts) + local options = { + noremap = true, + silent = true, + } + if opts then + options = vim.tbl_extend('force', options, opts) + end + vim.keymap.set(mode, lhs, rhs, options) +end + +-- Save File +map( + { + 'i', + 'v', + 'n', + 's', + }, + '', + 'w', + { + desc = 'Save file', + } +) + +map('i', '', '"+pa', { + desc = 'Paste from clipboard', +}) + +map('n', '', 'm`op``', { + desc = 'Paste below', +}) + +map('n', '', 'm`Op``', { + desc = 'Paste above', +}) + +map( + { + 'n', + 'x', + }, + '', + '"+y', + { + desc = 'Copy to clipboard', + } +) + +map( + { + 'n', + 'x', + }, + '', + '"+ydd', + { + desc = 'Cut to clipboard', + } +) + +-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933. +map('n', '', "printf('`[%s`]', getregtype()[0])", { + expr = true, + desc = 'reselect last pasted area', +}) + +map( + { + 'i', + 'v', + 'n', + 's', + }, + '', + 'wq!', + { + desc = 'Force Save file and quit', + } +) + +-- Select all text in the current buffer +map('n', '', ':keepjumps normal! ggyG', { + desc = 'Select all', +}) + +-- quit +map('n', '', 'wqa!', { + desc = 'Quit all', +}) + +-- go to beginning and end in insert mode +map('i', '', '^i', { + desc = 'Go to beginning of line', +}) +map('i', '', '', { + desc = 'Go to end of line', +}) + +-- Go to the beginning and end of current line in insert mode quickly +map('i', '', '') +map('i', '', '') + +-- insert semicolon in the end +map('i', '', 'miA;`ii', { + desc = 'insert semicolon in the end', +}) + +-- Turn the word under cursor to upper case +map('i', '', 'viwUea') +-- Turn the current word into lower case +map('i', '', 'b~lea') + +-- Undo +map('i', '', 'u') + +-- navigate within insert mode +map('i', '', '', { + desc = 'Move Left', +}) +map('i', '', '', { + desc = 'Move Right', +}) +map('i', '', '', { + desc = 'Move Down', +}) +map('i', '', '', { + desc = 'Move Up', +}) + +-- Copy whole buffer +map('n', '', '%y+', { + desc = 'Copy whole buffer', +}) + +-- Go to start or end of line easier +map( + { + 'n', + 'x', + }, + 'H', + '^', + { + desc = 'Go to beginning of line', + } +) +map( + { + 'n', + 'x', + }, + 'L', + 'g_', + { + desc = 'Go to end of line', + } +) + +-- Change text without putting it into the vim register, +map( + { + 'n', + 'x', + }, + 'c', + '"_c', + { + desc = 'Change without yanking', + } +) +map( + { + 'n', + 'x', + }, + 'C', + '"_C', + { + desc = 'Change without yanking', + } +) +map( + { + 'n', + 'x', + }, + 'cc', + '"_cc', + { + desc = 'Change without yanking', + } +) +map( + { + 'n', + 'x', + }, + 'x', + '"_x', + { + desc = 'delete without yanking', + } +) + +-- Better escape using jk in insert and terminal mode +map('i', 'jk', '') +map('i', 'kj', '') +map('i', 'jj', '') + +-- Terminal Mappings +map("t", "jk", "") +map("t", "kj", "") +map("t", "", "") + +-- Move with shift-arrows +map("n", "", "", { + desc = "Move window to the left" +}) +map("n", "", "", { + desc = "Move window down" +}) +map("n", "", "", { + desc = "Move window up" +}) +map("n", "", "", { + desc = "Move window to the right" +}) + +-- Search +map({ + "n", + "x" +}, "gw", "*N", { + desc = "Search word under cursor" +}) + +-- Some cool remaps +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") +map("n", "J", "mzJ`z") +map("n", "}", "}zzzv") +map("n", "{", "{zzzv") +map("n", "g,", "g,zvzz") +map("n", "g;", "g;zvzz") +map("n", "", "zz") +map("n", "", "zz") +map("n", "^", "g^") +map("n", "0", "g0") +-- Do not include white space characters when using $ in visual mode, +map("x", "$", "g_") +-- Always use very magic mode for searching +map("n", "/", [[/\v]]) + +-- Add undo break-points +map("i", "?", "?u") +map("i", "!", "!u") +map("i", ",", ",u") +map("i", ".", ".u") +map("i", ";", ";u") + +-- compromised backward search when comma is being used as localleader +map("n", "", ",") + +-- Better up/down +map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) + +-- Move text up and down +map("n", "", "m .+1==", { desc = "Move Down" }) +map("n", "", "m .-2==", { desc = "Move Up" }) +map("i", "", "m .+1==gi", { desc = "Move Down" }) +map("i", "", "m .-2==gi", { desc = "Move Up" }) +map("v", "", ":m '>+1gv=gv", { desc = "Move Down" }) +map("v", "", ":m '<-4gv=gv", { desc = "Move Up" })