diff options
| author | Alec Goncharow <algo@cloudflare.com> | 2023-02-24 23:20:34 -0600 |
|---|---|---|
| committer | Alec Goncharow <algo@cloudflare.com> | 2023-02-24 23:20:34 -0600 |
| commit | 0c446121ba1f1653a0d984068209429e8cc453fb (patch) | |
| tree | bc04e8bb2a985e5cb4f7b15c1e4d8962b2c4b000 /.config/nvim/lua/mappings.lua | |
| parent | d3aeb8f7d8d9b4352e7b827a361d1da11cb6cf04 (diff) | |
out of the frying pan
into the fire
Diffstat (limited to '.config/nvim/lua/mappings.lua')
| -rw-r--r-- | .config/nvim/lua/mappings.lua | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..5a0050f --- /dev/null +++ b/.config/nvim/lua/mappings.lua @@ -0,0 +1,60 @@ +-- https://github.com/arnvald/viml-to-lua/blob/main/lua/mappings.lua +vim.cmd('noremap <C-b> :noh<cr>:call clearmatches()<cr>') -- clear matches Ctrl+b + +function map(mode, shortcut, command) + vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true }) +end + +function nmap(shortcut, command) + map('n', shortcut, command) +end + +function imap(shortcut, command) + map('i', shortcut, command) +end + +function vmap(shortcut, command) + map('v', shortcut, command) +end + +function cmap(shortcut, command) + map('c', shortcut, command) +end + +function tmap(shortcut, command) + map('t', shortcut, command) +end + + +-- PLUGINS +-- Keymaps for Luasnip +local ls = require("luasnip") +vim.keymap.set({ "i", "s" }, "<C-k>", function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end +end, { silent = true }) + +vim.keymap.set({ "i", "s" }, "<C-j>", function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end, { silent = true }) + +vim.keymap.set("i", "<C-l>", function() + if ls.choice_active() then + ls.change_choice(1) + end +end) + +-- Find files using Telescope command-line sugar. +nmap("<C-p>", "<cmd>Telescope find_files<cr>") +nmap("<leader>f", "<cmd>Telescope live_grep<cr>") +nmap("<leader>bb", "<cmd>Telescope buffers<cr>") +nmap("<leader>hh", "<cmd>Telescope help_tags<cr>") + +-- LSP +nmap('K', '<cmd>Lspsaga hover_doc<cr>') +imap('<C-k>', '<cmd>Lspsaga hover_doc<cr>') +nmap('gh', '<cmd>Lspsaga lsp_finder<cr>') +nmap('<C-e>', '<cmd>Lspsaga show_line_diagnostics<CR>') |
