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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
local function map(mode, bind, cmd, opts)
opts = opts or {noremap = true, silent = true}
if type(bind) == 'table' then
for i in pairs(bind) do
vim.keymap.set(mode, bind[i], cmd, opts)
end
elseif type(bind) == 'string' then
vim.keymap.set(mode, bind, cmd, opts)
else
vim.notify('-- Invalid bind for keymap:\nvim.keymap.set(\''
.. mode .. '\', ' .. bind .. ', \'' .. cmd .. '\')',
vim.log.levels.WARN, {
title = 'Neovim Config',
on_open = function(win)
local buf = vim.api.nvim_win_get_buf(win)
vim.api.nvim_buf_set_option(buf, "filetype", "lua")
end
}
)
end
end
-- vim binds ------------------------------------------------------------------
g.mapleader = ' ' -- set leader key
-- greatest remap ever
map('x', '<leader>p', [["_dP]])
-- clear search
map('n', '<ESC>', ':nohlsearch<Bar>:echo<CR>')
-- move selected text up/down
map('v', '<S-k>', ":m '<-2<CR>gv=gv")
map('v', '<S-j>', ":m '>+1<CR>gv=gv")
-- the cursor STAYS IN THE MIDDLE
map('n', '<S-j>', 'mzJ`z<cmd>delm z<CR>') -- when combining lines
map('n', 'n', 'nzzzv') -- searching
map('n', 'N', 'Nzzzv')
map('n', '<C-d>', '<C-d>zz') -- half page jumping
map('n', '<C-u>', '<C-u>zz')
-- execute order 111
map('n', '<leader>x', '<cmd>!chmod +x %<CR>')
-- add some keybinds to the file view
a.nvim_create_autocmd('FileType', {
pattern = 'netrw',
callback = function()
local bind = function(lhs, rhs)
vim.keymap.set('n', lhs, rhs, { remap = true, buffer = true })
end
bind('h', '-^') -- Go up a directory
bind('l', '<CR>') -- Go down a directory / open a file
bind('.', 'gh') -- Toggle dotfiles
bind('P', '<C-w>z') -- Close preview window
bind('<ESC>', '<cmd>q<CR>') -- Close netrw
end
})
-- plugin binds ---------------------------------------------------------------
-- treesj
local treesj = require('treesj')
map('n', '<leader>j', treesj.toggle)
-- telescope
local telebuilt = require('telescope.builtin')
map('n', '<leader>sf', telebuilt.find_files)
map('n', '<leader>sg', telebuilt.git_files)
map('n', '<leader>sp', function()
telebuilt.grep_string({ search = vim.fn.input('Find string in project > ') });
end)
map('n', '<leader>so', telebuilt.oldfiles)
-- intellitab
local intellitab = require('intellitab')
map('n', '<Tab>', intellitab.indent)
-- undo tree
map('n', '<leader>u', '<cmd>UndotreeToggle<CR>')
-- sfm
map('n', '<leader>f', '<cmd>SFMToggle<CR>')
-- dap ui
local dapui = require('dapui')
map('n', '<leader>d', dapui.toggle)
-- switch between previous buffers
map('n', '<leader>b', '<cmd>JABSOpen<CR>')
-- resizing buffers (toggleable)
local smartsplits = require('smart-splits')
map('n', '<leader>r', smartsplits.start_resize_mode)
-- trouble (lsp error view)
map('n', '<leader>t', '<cmd>TroubleToggle<CR>')
-- icon picker
map('n', '<C-e>', '<cmd>IconPickerYank<CR>')
-- toggle term
map('t', '<ESC>', '<C-\\><C-n>') -- make <ESC> work in terminals
map({'n', 't'}, '<C-\\>', '<cmd>ToggleTerm size=20<CR>')
map({'n', 't'}, '<leader>gl', '<cmd>lua _glow()<CR>')
|