diff options
| author | ottjk <joshott16@gmail.com> | 2023-12-30 19:23:04 -0500 |
|---|---|---|
| committer | ottjk <joshott16@gmail.com> | 2023-12-30 19:23:04 -0500 |
| commit | ed46f1c5e82709417085b1a3b7708b209c5f4bfe (patch) | |
| tree | d7eb3f2b4b00e75e5f10199e1cbff959c355b312 /nvim/lua/keymaps.lua | |
| download | dotfiles-ed46f1c5e82709417085b1a3b7708b209c5f4bfe.tar.gz dotfiles-ed46f1c5e82709417085b1a3b7708b209c5f4bfe.zip | |
initial commit
Diffstat (limited to 'nvim/lua/keymaps.lua')
| -rw-r--r-- | nvim/lua/keymaps.lua | 85 |
1 files changed, 85 insertions, 0 deletions
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('', '<Up>', 'gk', opts) +map('', '<Down>', 'gj', opts) +map('n', 'J', 'mzJ`z', opts) + +map('', 'o', 'o<Esc>', opts) +map('', 'O', 'O<Esc>', opts) + +map('i', '<C-Space>', '<Esc>', opts) +map('v', '<C-Space>', '<Esc>', opts) +map('t', '<C-Space>', '<C-\\><C-n>', opts) +map('v', '<PageDown>', ":m '>+1<CR>gv=gv", opts) +map('v', '<PageUp>', ":m '<-2<CR>gv=gv", opts) + +map('n', 'Q', '<nop>') + +-- +-- telescope +-- +map('n', '<leader>pf', builtin.find_files, {}) +map('n', '<leader>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', '<leader>fs', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) +end, {}) +-- + +map("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" }) +map('n', '<leader>u', vim.cmd.UndotreeToggle) +map('n', '<PageUp>', vim.cmd.BufferLineCycleNext) +map('n', '<PageDown>', vim.cmd.BufferLineCyclePrev) +map('n', '<leader>br', vim.cmd.BufDel) + +-- +-- window resizing +-- +-- map('n', '<S-Left>', ':vertical resize -2<CR>', { silent = true }) +-- map('n', '<S-Right>', ':vertical resize +2<CR>', { silent = true }) +-- map('n', '<S-Up>', ':resize +2<CR>', { silent = true }) +-- map('n', '<S-Down>', ':resize -2<CR>', { silent = true }) + +map('n', '<C-p>', ':MarkdownPreview<CR>', { silent = true }) + +map('x', 'p', '\"_dP') + +map('n', '<leader>y', '\"+y') +map('v', '<leader>y', '\"+y') +map('n', '<leader>Y', '\"+Y') + +map('n', '<leader>d', '\"+d') +map('v', '<leader>d', '\"+d') + +map('n', '<leader>js', ':vertical botright Repl julia<CR>') +map('n', '<leader>jr', function() + vim.cmd.ReplSend(string.format('include("%s")', vim.fn.expand('%:p'))) +end) +map('n', '<leader>j;', function() + vim.cmd.ReplSend(string.format('include("%s");', vim.fn.expand('%:p'))) +end) + +map('n', '<C-h>', vim.cmd.HopWord) + +map('n', '<leader>vv', vim.cmd.VimtexCompile) +map('n', '<leader>vc', ':VimtexClean!<CR>') + +map('i', '<C-f>', [[<Esc>: silent exec '.!inkscape-figures create "'.getline('.').'" "'.b:vimtex.root.'/figures/"'<CR><CR>:w<CR>]], opts) +map('n', '<C-f>', [[: silent exec '!inkscape-figures edit "'.b:vimtex.root.'/figures/" > /dev/null 2>&1 &'<CR><CR>:redraw!<CR>]], opts) + +vim.cmd([[ +" press <Tab> to expand or jump in a snippet. These can also be mapped separately +" via <Plug>luasnip-expand-snippet and <Plug>luasnip-jump-next. +imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>' +]]) + +map('i', '<S-Tab>', [[<cmd>lua require'luasnip'.jump(-1)<Cr>]], opts) +map('s', '<Tab>', [[<cmd>lua require('luasnip').jump(1)<Cr>]], opts) +map('s', '<Tab>', [[<cmd>lua require('luasnip').jump(-1)<Cr>]], opts) |