From abd69f6af67ab55bee2a2fe02c75efc3b956c224 Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 22 Jul 2025 13:17:53 -0400 Subject: reworked nvim keymaps and options --- nvim/lua/keymaps.lua | 114 +++++++++++++++++++++++++++------------------------ nvim/lua/options.lua | 47 ++++++++++++--------- 2 files changed, 88 insertions(+), 73 deletions(-) (limited to 'nvim/lua') diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index 1bef617..81674c3 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -1,25 +1,20 @@ -local map = vim.keymap.set; +local function map(m, k, v) + vim.keymap.set(m, k, v, { noremap = true, silent = true }) +end local builtin = require('telescope.builtin') -local opts = { noremap = true, silent = true} -map('', '', 'gk', opts) -map('', '', 'gj', opts) -map('n', 'J', 'mzJ`z', opts) +map('', '', 'gk') +map('', '', 'gj') +map('n', 'J', 'mzJ`z') -map('', 'o', 'o', opts) -map('', 'O', 'O', opts) +map('', 'o', 'o') +map('', 'O', 'O') -map('i', '', '', opts) -map('v', '', '', opts) -map('t', '', '', opts) -map('v', '', ":m '>+1gv=gv", opts) -map('v', '', ":m '<-2gv=gv", opts) +map('t', '', '') +map('v', '', "m '>+1gv=gv") +map('v', '', "m '<-2gv=gv") -map('n', 'Q', '') - --- -- telescope --- map('n', 'pf', builtin.find_files, {}) map('n', 'pg', function() -- If the directory is not a git repository, fallback to regular find_files. @@ -31,24 +26,55 @@ end, {}) map('n', 'fs', function() builtin.grep_string({ search = vim.fn.input("Grep > ") }) end, {}) --- -map("n", "-", "Oil", { desc = "Open parent directory" }) +-- mini +map('n', '-', 'lua MiniFiles.open()') +map('n', 'wt', 'lua MiniTrailspace.trim()') + +-- toggleterm +map('n', 'g', 'lua _lazygit_toggle()') + +-- misc plugin keymaps map('n', 'u', vim.cmd.UndotreeToggle) -map('n', '', vim.cmd.BufferLineCycleNext) -map('n', '', vim.cmd.BufferLineCyclePrev) -map('n', 'br', vim.cmd.BufDel) --- --- window resizing --- --- map('n', '', ':vertical resize -2', { silent = true }) --- map('n', '', ':vertical resize +2', { silent = true }) --- map('n', '', ':resize +2', { silent = true }) --- map('n', '', ':resize -2', { silent = true }) +map('n', '', vim.cmd.HopWord) + +map('n', 'vv', vim.cmd.VimtexCompile) +map('n', 'vc', 'VimtexClean!') + +map('n', 'tw', 'Twilight') + +-- buffers +map('n', '', 'bnext') +map('n', '', 'bprevious') +map('n', 'br', 'BufferClose') +map('n', 'Q', 'BufferClose!') +map('n', 'bn', 'BufferOrderByBufferNumber') +map('n', 'U', 'bufdo bd') --close all +map('n', 'vs', 'vsplitbnext') --ver split + open next buffer + +-- buffer position nav + reorder +map('n', '', 'BufferMovePrevious') +map('n', '', 'BufferMoveNext') +map('n', '', 'BufferGoto 1') +map('n', '', 'BufferGoto 2') +map('n', '', 'BufferGoto 3') +map('n', '', 'BufferGoto 4') +map('n', '', 'BufferGoto 5') +map('n', '', 'BufferGoto 6') +map('n', '', 'BufferGoto 7') +map('n', '', 'BufferGoto 8') +map('n', '', 'BufferGoto 9') +map('n', '', 'BufferLast') +map('n', '', 'BufferPin') -map('n', '', ':MarkdownPreview', { silent = true }) +-- window resizing +map('n', '', ':vertical resize -2') +map('n', '', ':vertical resize +2') +map('n', '', ':resize +2') +map('n', '', ':resize -2') +-- clipboard management map('x', 'p', '\"_dP') map('n', 'y', '\"+y') @@ -58,31 +84,11 @@ map('n', 'Y', '\"+Y') map('n', 'd', '\"+d') map('v', 'd', '\"+d') -map('n', 'js', ':vertical botright Repl julia') -map('n', 'jr', function() - vim.cmd.ReplSend(string.format('include("%s")', vim.fn.expand('%:p'))) -end) -map('n', 'j;', function() - vim.cmd.ReplSend(string.format('include("%s");', vim.fn.expand('%:p'))) -end) - -map('n', '', vim.cmd.HopWord) - -map('n', 'vv', vim.cmd.VimtexCompile) -map('n', 'vc', ':VimtexClean!') - -map('i', '', [[: silent exec '.!inkscape-figures create "'.getline('.').'" "'.b:vimtex.root.'/figures/"':w]], opts) -map('n', '', [[: silent exec '!inkscape-figures edit "'.b:vimtex.root.'/figures/" > /dev/null 2>&1 &':redraw!]], opts) - -map('i', '', [[: silent exec '.!xoppdog shake "'.getline('.').'" "'.b:vimtex.root.'/figures/"':w]], opts) -map('n', '', [[: silent exec '!xoppdog fetch "'.b:vimtex.root.'/figures/" > /dev/null 2>&1 &':redraw!]], opts) - +-- luasnip vim.cmd([[ -imap luasnip#expand_or_jumpable() ? 'luasnip-expand-or-jump' : '' -inoremap lua require'luasnip'.jump(-1) +imap luasnip#expand_or_jumpable() ? 'luasnip-expand-or-jump' : '' +inoremap lua require'luasnip'.jump(-1) -snoremap lua require('luasnip').jump(1) -snoremap lua require('luasnip').jump(-1) +snoremap lua require('luasnip').jump(1) +snoremap lua require('luasnip').jump(-1) ]]) - -map('n', 'xx', function() require('trouble').toggle() end) diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua index 2a81dc2..5974579 100644 --- a/nvim/lua/options.lua +++ b/nvim/lua/options.lua @@ -1,27 +1,36 @@ -vim.opt.nu = true -vim.opt.relativenumber = true +vim.cmd "set undofile" +-- vim.opt.isfname:append("@-@") +vim.g.mapleader = ' ' -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 -vim.opt.shiftwidth = 4 -vim.opt.expandtab = true +local options = { + nu = true, + relativenumber = true, -vim.opt.smartindent = false -vim.opt.autoindent = true + tabstop = 4, + softtabstop = 4, + shiftwidth = 4, + expandtab = true, -vim.opt.wrap = false + smartindent = false, + autoindent = true, -vim.opt.hlsearch = false -vim.opt.incsearch = true + wrap = false, -vim.opt.scrolloff = 8 -vim.opt.signcolumn = "no" -vim.opt.cursorline = true -vim.opt.cursorlineopt = "number" -vim.opt.isfname:append("@-@") + hlsearch = false, + incsearch = true, -vim.cmd "set undofile" + scrolloff = 8, + signcolumn = "no", + cursorline = true, + cursorlineopt = "number", -vim.g.mapleader = ' ' + ignorecase = true, + smartcase = true, + + guifont = "FiraCode:h10", + showmode = false, +} -vim.opt.guifont = "FiraCode:h10" +for k, v in pairs(options) do + vim.opt[k] = v +end -- cgit v1.3