]> src.twobees.de Git - dotfiles.git/blob - stow/nvim/.config/nvim/lua/mappings.lua
0d576c316d08a683818eebc9e94935462f9955ea
[dotfiles.git] / stow / nvim / .config / nvim / lua / mappings.lua
1 function map(mode, shortcut, command)
2     vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
3 end
4
5 function nmap(shortcut, command)
6     map('n', shortcut, command)
7 end
8
9 function imap(shortcut, command)
10     map('i', shortcut, command)
11 end
12
13 function vmap(shortcut, command)
14     map('v', shortcut, command)
15 end
16
17 vim.g.mapleader = " "
18 nmap("<F8>", "]s")
19 nmap("<S-F8>", "[s")
20 nmap("Z", "Y")
21 nmap("<leader>-", "i•")
22 nmap("<C-k>", "<C-W>k")
23 nmap("<C-j>", "<C-W>j")
24 nmap("<C-h>", "<C-W>h")
25 nmap("<C-l>", "<C-W>l")
26 nmap("<Leader>i", "a'\" <<  << \"' <Esc>6hi")
27 nmap("<Leader>a", "a'{}' <Esc>2hi")
28 nmap("<Leader>A", "a'\"+  +\"' <Esc>4hi")
29 nmap("<Leader>fd", "msgg=G`s")
30 imap("kj", "<Esc>")
31 nmap("<leader>j", ":bprev<CR>")
32 nmap("<leader>k", ":bnext<CR>")
33 nmap("<C-l>", "<C-W>l")
34 vmap("<leader>c", "\"*y")
35 nmap("<leader>v", "\"*p")
36 nmap("<S-Up>", ":m .-2<CR>==")
37 vmap("<S-Up>", ":m '<-2<CR>gv=gv")
38 nmap("<S-Down>", ":m .+1<CR>==")
39 vmap("<S-Down>", ":m '>+1<CR>gv=gv")
40 nmap("<S-Right>", ">>")
41 vmap("<S-Right>", ":><CR>gv")
42 vmap("<S-Left>", " :<<CR>gv")
43 nmap("<S-Left>", "<<")
44 nmap("<leader>w", ":w<CR>")
45 nmap("<leader>wj", ":wa<CR>")
46 nmap("<leader>wk", ":xall<CR>")
47 vmap(".", ":normal.<CR>")
48 -- vmap("<leader>tt", ":Tabular /^[^-+=]*\zs\S*=/l1l1<cr>")
49 -- vmap("<leader>t,", ":Tabular /,\zs/l1l1<cr>")
50 -- vmap("<leader>t<space>", " :Tabular /\s\+\zs/l1l0<cr>")
51 -- vmap("<leader>t:", "       :Tabular /:\zs/l1l0<cr>")
52 -- vmap("<leader>t(", " :Tabular /(/l1l0<cr>")
53 nmap("<Leader>s", "yiw/<C-R>/\\|<C-R>\"<cr>")
54 vmap("<Leader>s", "y/<C-R>/\\|<C-R>\"<cr>")
55 nmap("<Leader>ll", "iprint_log(\"\");<Esc>V=0f(la")
56 nmap("<leader><tab>", ":Files<cr>")
57 imap("<F4>", "<Esc>:Explore<CR>")
58 nmap("<F4>", ":Explore<CR>")
59
60 nmap("<Leader>r", ":Reload<CR>:echom 'config relaoded!'<CR>")
61 nmap("<leader>e", ":tabedit $MYVIMRC<CR>:lcd %:p:h<cr>")
62
63 vim.keymap.set('n', "<Leader>r", function ()
64     for k in pairs(package.loaded) do
65         package.loaded[k] = nil
66     end
67     vim.cmd [[ :source $MYVIMRC ]]
68     print ('config reloaded!')
69 end
70 )