From ed46f1c5e82709417085b1a3b7708b209c5f4bfe Mon Sep 17 00:00:00 2001 From: ottjk Date: Sat, 30 Dec 2023 19:23:04 -0500 Subject: initial commit --- nvim/lua/keymaps.lua | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 nvim/lua/keymaps.lua (limited to 'nvim/lua/keymaps.lua') diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua new file mode 100644 index 0000000..0b72932 --- /dev/null +++ b/nvim/lua/keymaps.lua @@ -0,0 +1,85 @@ +local map = vim.keymap.set; +local builtin = require('telescope.builtin') +local opts = { noremap = true, silent = true} + +map('', '', 'gk', opts) +map('', '', 'gj', opts) +map('n', 'J', 'mzJ`z', opts) + +map('', 'o', 'o', opts) +map('', 'O', 'O', opts) + +map('i', '', '', opts) +map('v', '', '', opts) +map('t', '', '', opts) +map('v', '', ":m '>+1gv=gv", opts) +map('v', '', ":m '<-2gv=gv", opts) + +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. + if pcall(builtin.git_files) then + else + pcall(builtin.find_files) + end +end, {}) +map('n', 'fs', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) +end, {}) +-- + +map("n", "-", "Oil", { desc = "Open parent directory" }) +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', '', ':MarkdownPreview', { silent = true }) + +map('x', 'p', '\"_dP') + +map('n', 'y', '\"+y') +map('v', 'y', '\"+y') +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) + +vim.cmd([[ +" press to expand or jump in a snippet. These can also be mapped separately +" via luasnip-expand-snippet and luasnip-jump-next. +imap luasnip#expand_or_jumpable() ? 'luasnip-expand-or-jump' : '' +]]) + +map('i', '', [[lua require'luasnip'.jump(-1)]], opts) +map('s', '', [[lua require('luasnip').jump(1)]], opts) +map('s', '', [[lua require('luasnip').jump(-1)]], opts) -- cgit v1.3