1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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>')
|