From 0c446121ba1f1653a0d984068209429e8cc453fb Mon Sep 17 00:00:00 2001 From: Alec Goncharow Date: Fri, 24 Feb 2023 23:20:34 -0600 Subject: out of the frying pan into the fire --- .config/nvim/lua/mappings.lua | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .config/nvim/lua/mappings.lua (limited to '.config/nvim/lua/mappings.lua') 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 :noh:call clearmatches()') -- 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" }, "", function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end +end, { silent = true }) + +vim.keymap.set({ "i", "s" }, "", function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end, { silent = true }) + +vim.keymap.set("i", "", function() + if ls.choice_active() then + ls.change_choice(1) + end +end) + +-- Find files using Telescope command-line sugar. +nmap("", "Telescope find_files") +nmap("f", "Telescope live_grep") +nmap("bb", "Telescope buffers") +nmap("hh", "Telescope help_tags") + +-- LSP +nmap('K', 'Lspsaga hover_doc') +imap('', 'Lspsaga hover_doc') +nmap('gh', 'Lspsaga lsp_finder') +nmap('', 'Lspsaga show_line_diagnostics') -- cgit v1.2.3-70-g09d2