2021-11-06 21:04:47 +01:00
|
|
|
local M = {}
|
2021-11-24 19:42:33 +01:00
|
|
|
local wk = require('which-key')
|
|
|
|
local api, notify = vim.api, vim.notify
|
|
|
|
local opts = {noremap = true, silent = true}
|
2021-11-05 20:50:48 +01:00
|
|
|
|
2021-11-24 19:42:33 +01:00
|
|
|
-------------------------------
|
|
|
|
-- Globally defined mappings --
|
|
|
|
-------------------------------
|
2021-11-06 21:04:47 +01:00
|
|
|
local normal_mappings = {
|
2021-11-05 20:50:48 +01:00
|
|
|
-- Better Y
|
|
|
|
Y = {'y$', 'Yank to eol'},
|
|
|
|
-- Easier start and end of line
|
|
|
|
H = {'^', 'Start of the line'},
|
|
|
|
L = {'$', 'End of the line'},
|
|
|
|
-- Close a window
|
|
|
|
['<C-q>'] = {'<C-w>q', 'Quit current window'},
|
|
|
|
-- Close current buffer
|
|
|
|
['<A-q>'] = {':bdelete<CR>', 'Close current buffer'},
|
|
|
|
-- Copy the whole buffer
|
|
|
|
['<A-a>'] = {':%y+<CR>', 'Copy whole buffer'},
|
|
|
|
-- Remove trailing whitespace
|
|
|
|
['<A-w>'] = {':%s/\\s\\+$//e<CR>', 'Remove trailing'},
|
|
|
|
-- Resize buffer
|
|
|
|
['<A-j>'] = {':resize -2<CR>', 'Resize vertical -2'},
|
|
|
|
['<A-k>'] = {':resize +2<CR>', 'Resize vertical +2'},
|
|
|
|
['<A-h>'] = {':vertical resize -2<CR>', 'Resize horizontal -2'},
|
|
|
|
['<A-l>'] = {':vertical resize +2<CR>', 'Resize horizontal +2'},
|
|
|
|
-- Switch between tabs and spaces
|
|
|
|
['<A-t>'] = {
|
|
|
|
function()
|
|
|
|
if vim.opt.expandtab:get() then
|
|
|
|
vim.opt.expandtab = false
|
|
|
|
vim.opt.smarttab = false
|
|
|
|
vim.opt.softtabstop = 0 -- reset to default
|
2021-11-24 19:42:33 +01:00
|
|
|
notify('Indent with Tabs.', vim.log.levels.INFO)
|
2021-11-05 20:50:48 +01:00
|
|
|
else
|
|
|
|
vim.opt.expandtab = true
|
|
|
|
vim.opt.smarttab = true
|
|
|
|
vim.opt.softtabstop = -1 -- fallback to shiftwidth
|
2021-11-24 19:42:33 +01:00
|
|
|
notify('Indent with Spaces.', vim.log.levels.INFO)
|
2021-11-05 20:50:48 +01:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
'Switch indent style'
|
|
|
|
},
|
|
|
|
-- Naming common keys
|
|
|
|
['['] = {
|
|
|
|
name = 'Block motions (previous)',
|
2021-11-06 21:04:47 +01:00
|
|
|
g = 'Previous git hunk'
|
2021-11-05 20:50:48 +01:00
|
|
|
},
|
|
|
|
[']'] = {
|
|
|
|
name = 'Block motions (next)',
|
2021-11-06 21:04:47 +01:00
|
|
|
g = 'Next git hunk'
|
2021-11-05 20:50:48 +01:00
|
|
|
},
|
|
|
|
g = {
|
|
|
|
name = 'Goto motions',
|
|
|
|
t = {':TodoTrouble<CR>', 'Todo list'}
|
|
|
|
},
|
|
|
|
z = {name = 'Misc utils'},
|
|
|
|
-- Move between tabs
|
|
|
|
['<TAB>'] = {':BufferLineCycleNext<CR>', 'Next buffer'},
|
|
|
|
['<S-TAB>'] = {':BufferLineCyclePrev<CR>', 'Previous buffer'},
|
|
|
|
-- ToggleTerm
|
|
|
|
['<C-\\>'] = {':ToggleTerm<CR>', 'Toggle terminal'},
|
|
|
|
['<A-\\>'] = {':ToggleTerm direction=float<CR>', 'Toggle float terminal'},
|
|
|
|
-- hop.nvim
|
|
|
|
S = {':HopWord<CR>', 'Hop to word'},
|
|
|
|
['<C-s>'] = {':HopChar1<CR>', 'Hop to character'},
|
|
|
|
['<A-s>'] = {':HopPattern<CR>', 'Hop to pattern'}
|
2021-11-06 21:04:47 +01:00
|
|
|
}
|
2021-11-05 20:50:48 +01:00
|
|
|
|
2021-11-06 21:04:47 +01:00
|
|
|
local normal_leader_mappings = {
|
2021-11-05 20:50:48 +01:00
|
|
|
d = {
|
|
|
|
name = 'DAP',
|
|
|
|
b = 'Toggle breakpoint',
|
|
|
|
B = 'Set breakpoint with condition',
|
|
|
|
c = 'Run to cursor',
|
|
|
|
d = 'Disconnect adapter',
|
|
|
|
e = 'Hover under cursor (UI)',
|
|
|
|
f = 'Open float window (UI)',
|
|
|
|
i = 'Step into function/method',
|
|
|
|
l = 'List breakpoints',
|
|
|
|
n = 'Resume the execution',
|
|
|
|
o = 'Step out of function/method',
|
|
|
|
r = 'Inspect in REPL',
|
|
|
|
t = 'Toggle UI',
|
|
|
|
v = 'Run again 1 step',
|
|
|
|
z = 'Re-run the last adapter'
|
|
|
|
},
|
|
|
|
e = {
|
|
|
|
name = 'Editor',
|
|
|
|
a = {':EasyAlign<CR>', 'Align elements'},
|
|
|
|
g = 'Generate annotations',
|
|
|
|
h = {':TSHighlightCapturesUnderCursor<CR>', 'Syntax under cursor'},
|
|
|
|
s = {':ISwapWith<CR>', 'Swap elements'},
|
2021-11-09 09:03:10 +01:00
|
|
|
t = {':TableModeToggle<CR>', 'Toggle table mode'},
|
2021-11-05 20:50:48 +01:00
|
|
|
v = {
|
|
|
|
function()
|
|
|
|
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
|
|
|
if venn_enabled == 'nil' then
|
|
|
|
vim.b.venn_enabled = true
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_command('setlocal virtualedit=all')
|
2021-11-06 21:04:47 +01:00
|
|
|
-- Draw lines with WASD keystroke
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_buf_set_keymap(0, 'n', 'A', '<C-v>h:VBox<CR>', opts)
|
|
|
|
api.nvim_buf_set_keymap(0, 'n', 'S', '<C-v>j:VBox<CR>', opts)
|
|
|
|
api.nvim_buf_set_keymap(0, 'n', 'W', '<C-v>k:VBox<CR>', opts)
|
|
|
|
api.nvim_buf_set_keymap(0, 'n', 'D', '<C-v>l:VBox<CR>', opts)
|
2021-11-05 20:50:48 +01:00
|
|
|
-- Draw boxes by pressing 'f' with visual selection
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox<CR>', opts)
|
|
|
|
notify('Virtual box edit enabled.', vim.log.levels.INFO)
|
2021-11-05 20:50:48 +01:00
|
|
|
else
|
|
|
|
vim.b.venn_enabled = nil
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_command('setlocal virtualedit=block')
|
|
|
|
api.nvim_buf_del_keymap(0, 'v', 'f')
|
|
|
|
api.nvim_buf_del_keymap(0, 'n', 'A')
|
|
|
|
api.nvim_buf_del_keymap(0, 'n', 'S')
|
|
|
|
api.nvim_buf_del_keymap(0, 'n', 'W')
|
|
|
|
api.nvim_buf_del_keymap(0, 'n', 'D')
|
|
|
|
notify('Virtual box edit disabled.', vim.log.levels.INFO)
|
2021-11-05 20:50:48 +01:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
'Toggle virtual box edit'
|
|
|
|
},
|
2021-11-09 09:03:10 +01:00
|
|
|
z = {':ZenMode<CR>', 'Zen mode'},
|
|
|
|
Z = {':Twilight<CR>', 'Twilight mode'}
|
2021-11-05 20:50:48 +01:00
|
|
|
},
|
|
|
|
f = {
|
|
|
|
name = 'Telescope',
|
|
|
|
a = {':Telescope autocommands<CR>', 'Autocommands'},
|
|
|
|
b = {':Telescope buffers<CR>', 'Buffers'},
|
|
|
|
c = {':Telescope commands<CR>', 'Commands'},
|
|
|
|
d = {':Telescope projects<CR>', 'Recent directories'},
|
|
|
|
e = {':Telescope file_browser<CR>', 'File browser'},
|
|
|
|
f = {':Telescope find_files<CR>', 'Find files'},
|
|
|
|
g = {':Telescope live_grep<CR>', 'Live grep'},
|
|
|
|
h = {':Telescope help_tags<CR>', 'Help tags'},
|
|
|
|
i = {':Telescope highlights<CR>', 'Highlight groups'},
|
2021-11-17 16:39:12 +01:00
|
|
|
j = {
|
|
|
|
name = 'Symbols',
|
|
|
|
g = 'Gitmoji',
|
|
|
|
h = {':Telescope symbols<CR>', 'All symbols'},
|
|
|
|
j = 'Emoji',
|
|
|
|
k = 'Kaomoji',
|
|
|
|
l = 'Julia',
|
|
|
|
m = 'Math symbols',
|
|
|
|
n = 'Nerd-fonts symbols',
|
|
|
|
t = 'Latex symbols'
|
|
|
|
},
|
2021-11-05 20:50:48 +01:00
|
|
|
k = {':Telescope keymaps<CR>', 'Normal keymaps'},
|
2021-11-19 17:54:05 +01:00
|
|
|
l = {':Telescope notify<CR>', 'Notification history'},
|
2021-11-05 20:50:48 +01:00
|
|
|
m = {':Telescope marks<CR>', 'Bookmarks'},
|
|
|
|
n = {':Telescope man_pages<CR>', 'Man pages'},
|
|
|
|
o = {':Telescope oldfiles<CR>', 'Recent files'},
|
|
|
|
p = {':Telescope project display_type=full<CR>', 'Projects'},
|
|
|
|
r = {':Telescope reloader<CR>', 'Reload lua modules'},
|
|
|
|
s = {':Telescope treesitter<CR>', 'Treesitter'},
|
|
|
|
t = {':TodoTelescope<CR>', 'Todo list'},
|
|
|
|
u = {':Telescope current_buffer_fuzzy_find<CR>', 'Search current buffer'},
|
|
|
|
v = {':Telescope vim_options<CR>', 'Vim options'},
|
2021-11-19 17:54:05 +01:00
|
|
|
x = {
|
|
|
|
name = 'Tasks',
|
|
|
|
a = {':Telescope yabs tasks<CR>', 'All tasks'},
|
|
|
|
g = {':Telescope yabs global_tasks<CR>', 'Global tasks'},
|
|
|
|
l = {':Telescope yabs current_language_tasks<CR>', 'Tasks for current filetype'},
|
|
|
|
t = {':YabsDefaultTask<CR>', 'Run default task'}
|
|
|
|
},
|
2021-11-05 20:50:48 +01:00
|
|
|
y = {':Telescope filetypes<CR>', 'Filetypes'},
|
|
|
|
z = {':Telescope registers<CR>', 'Vim registers'}
|
|
|
|
},
|
|
|
|
g = {
|
|
|
|
name = 'Git',
|
|
|
|
a = {':Telescope git_stash<CR>', 'Stash'},
|
|
|
|
b = 'Blame current line',
|
|
|
|
c = {':Telescope git_bcommits<CR>', 'Buffer commits'},
|
|
|
|
C = {':Telescope git_commits<CR>', 'Commits'},
|
|
|
|
m = {':Telescope git_branches<CR>', 'Branches'},
|
|
|
|
n = {':Neogit<CR>', 'Neogit'},
|
|
|
|
p = 'Preview hunk',
|
|
|
|
r = 'Reset hunk',
|
|
|
|
R = 'Reset all hunks in buffer',
|
|
|
|
s = 'Stage hunk',
|
|
|
|
S = 'Stage buffer',
|
|
|
|
t = {':Telescope git_status<CR>', 'Status'},
|
|
|
|
u = 'Undo hunk',
|
|
|
|
U = 'Reset buffer index',
|
|
|
|
y = 'Get remote url for cursorline',
|
|
|
|
Y = 'Get remote url'
|
|
|
|
},
|
|
|
|
j = {
|
|
|
|
name = 'Translate',
|
|
|
|
t = {':Trans<CR>', 'Translate'},
|
|
|
|
d = {':TransSelectDirection<CR>', 'Translate with direction'},
|
|
|
|
r = {'cw<C-R>=system(\'trans -brief -no-ansi\', getreg(""))[:-2]<CR>', 'Translate and replace'},
|
|
|
|
c = {'cw<C-R>=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]<S-Left><S-Left><Right>', 'Translate and replace with direction'}
|
|
|
|
},
|
2021-11-19 17:54:05 +01:00
|
|
|
n = {':NvimTreeToggle<CR>', 'NvimTree'},
|
2021-11-05 20:50:48 +01:00
|
|
|
p = {
|
|
|
|
name = 'Find/Replace',
|
|
|
|
o = 'Open spectre',
|
|
|
|
p = 'Search in current file',
|
2021-11-06 21:04:47 +01:00
|
|
|
w = 'Find/Replace cursorword'
|
2021-11-05 20:50:48 +01:00
|
|
|
},
|
|
|
|
r = {
|
|
|
|
name = 'REST',
|
|
|
|
c = {'<Plug>RestNvim', 'Run request under cursor'},
|
|
|
|
p = {'<Plug>RestNvimPreview', 'Preview request cURL command'},
|
|
|
|
l = {'<Plug>RestNvimLast', 'Re-run last request'}
|
|
|
|
},
|
|
|
|
s = {
|
|
|
|
name = 'Session',
|
|
|
|
s = 'Save session for current directory',
|
|
|
|
d = 'Stop automatically saving',
|
|
|
|
l = 'Load last session',
|
|
|
|
r = 'Load session for current directory'
|
|
|
|
},
|
|
|
|
w = {':WindowPick<CR>', 'Pick window'}
|
2021-11-06 21:04:47 +01:00
|
|
|
}
|
2021-11-05 20:50:48 +01:00
|
|
|
|
2021-11-06 21:04:47 +01:00
|
|
|
local visual_leader_mappings = {
|
|
|
|
e = {
|
|
|
|
name = 'Editor',
|
2021-11-05 20:50:48 +01:00
|
|
|
a = {':EasyAlign<CR>', 'Range align'}
|
|
|
|
},
|
|
|
|
d = {
|
|
|
|
name = 'DAP',
|
|
|
|
e = 'Hover on range (UI)'
|
|
|
|
},
|
|
|
|
g = {
|
|
|
|
name = 'Git',
|
|
|
|
r = 'Reset hunk',
|
|
|
|
s = 'Stage hunk',
|
|
|
|
y = 'Get remote url for range'
|
|
|
|
},
|
|
|
|
j = {
|
|
|
|
name = 'Translate',
|
|
|
|
t = {':Trans<CR>', 'Translate'},
|
|
|
|
d = {':TransSelectDirection<CR>', 'Translate with direction'},
|
|
|
|
r = {'c<C-R>=system(\'trans -brief -no-ansi\', getreg(""))[:-2]<CR>', 'Translate and replace'},
|
|
|
|
c = {'c<C-R>=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]<S-Left><S-Left><Right>', 'Translate and replace with direction'}
|
|
|
|
},
|
|
|
|
p = 'Find/Replace'
|
2021-11-06 21:04:47 +01:00
|
|
|
}
|
|
|
|
|
2021-11-24 19:42:33 +01:00
|
|
|
local function localleader_mappings()
|
|
|
|
api.nvim_command('autocmd BufEnter * lua WhichkeyLocal()')
|
2021-11-06 21:04:47 +01:00
|
|
|
function WhichkeyLocal()
|
2021-11-24 19:42:33 +01:00
|
|
|
local bufnr = api.nvim_get_current_buf()
|
2021-11-06 21:04:47 +01:00
|
|
|
wk.register({
|
|
|
|
c = {':ColorizerToggle<CR>', 'Colorizer'},
|
|
|
|
d = {
|
|
|
|
name = 'Delete',
|
|
|
|
a = {':BDelete all<CR>', 'All buffers'},
|
|
|
|
d = {':BDelete this<CR>', 'Current buffer'},
|
|
|
|
h = {':BDelete hidden<CR>', 'Hidden buffers'},
|
|
|
|
n = {':BDelete nameless<CR>', 'Buffers without name'},
|
|
|
|
o = {':BDelete other<CR>', 'Other buffers'}
|
2021-11-05 20:50:48 +01:00
|
|
|
},
|
2021-11-06 21:04:47 +01:00
|
|
|
j = {':BufferLineCyclePrev<CR>', 'Previous buffer'},
|
|
|
|
k = {':BufferLineCycleNext<CR>', 'Next buffer'},
|
|
|
|
n = {':enew<CR>', 'New buffer'},
|
|
|
|
u = {':UndotreeToggle<CR>', 'Undotree'}
|
|
|
|
}, {buffer = bufnr, prefix = '<localleader>'})
|
|
|
|
end
|
|
|
|
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_command('autocmd FileType markdown lua WhichkeyMarkdown()')
|
2021-11-06 21:04:47 +01:00
|
|
|
function WhichkeyMarkdown()
|
|
|
|
wk.register({
|
|
|
|
p = {':MarkdownPreviewToggle<CR>', 'Preview markdown'}
|
2021-11-24 19:42:33 +01:00
|
|
|
}, {buffer = api.nvim_get_current_buf(), prefix = '<localleader>'})
|
2021-11-06 21:04:47 +01:00
|
|
|
end
|
|
|
|
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_command('autocmd FileType html lua WhichkeyHtml()')
|
2021-11-06 21:04:47 +01:00
|
|
|
function WhichkeyHtml()
|
|
|
|
wk.register({
|
|
|
|
p = {':Bracey<CR>', 'Preview html'}
|
2021-11-24 19:42:33 +01:00
|
|
|
}, {buffer = api.nvim_get_current_buf(), prefix = '<localleader>'})
|
2021-11-06 21:04:47 +01:00
|
|
|
end
|
2021-11-05 20:50:48 +01:00
|
|
|
end
|
|
|
|
|
2021-11-24 19:42:33 +01:00
|
|
|
local function undefined_mappings()
|
2021-11-06 21:04:47 +01:00
|
|
|
-- Escape to normal mode in terminal buffer
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', opts)
|
2021-11-06 21:04:47 +01:00
|
|
|
-- Continuous indent
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_set_keymap('v', '<', '<gv', opts)
|
|
|
|
api.nvim_set_keymap('v', '>', '>gv', opts)
|
2021-11-21 06:14:46 +01:00
|
|
|
-- Also move up/down virtual lines (:set wrap)
|
2021-11-25 16:21:18 +01:00
|
|
|
api.nvim_set_keymap('n', 'j', 'v:count == 0 ? "gj" : "j"', {noremap = true, expr = true, silent = true})
|
|
|
|
api.nvim_set_keymap('n', 'k', 'v:count == 0 ? "gk" : "k"', {noremap = true, expr = true, silent = true})
|
2021-11-06 21:04:47 +01:00
|
|
|
-- winshift.nvim
|
2021-11-24 19:42:33 +01:00
|
|
|
api.nvim_set_keymap('n', '<C-w><C-m>', ':WinShift<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<C-w>m', ':WinShift<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<C-A-h>', ':WinShift left<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<C-A-j>', ':WinShift down<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<C-A-k>', ':WinShift up<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<C-A-l>', ':WinShift right<CR>', opts)
|
2021-11-05 20:50:48 +01:00
|
|
|
end
|
|
|
|
|
2021-11-06 21:04:47 +01:00
|
|
|
function M.setup()
|
|
|
|
undefined_mappings()
|
|
|
|
localleader_mappings()
|
|
|
|
wk.register(normal_mappings)
|
|
|
|
wk.register(normal_leader_mappings, {prefix = '<leader>'})
|
|
|
|
wk.register(visual_leader_mappings, {mode = 'v', prefix = '<leader>'})
|
2021-11-05 20:50:48 +01:00
|
|
|
end
|
2021-11-06 21:04:47 +01:00
|
|
|
|
2021-11-24 19:42:33 +01:00
|
|
|
-----------------------
|
|
|
|
-- Plugins' mappings --
|
|
|
|
-----------------------
|
|
|
|
function M.orgmode()
|
|
|
|
api.nvim_command('autocmd FileType org lua WhichkeyOrg()')
|
|
|
|
function WhichkeyOrg()
|
|
|
|
wk.register({
|
|
|
|
['<leader>o'] = {
|
|
|
|
name = 'Org',
|
|
|
|
a = 'Agenda',
|
|
|
|
A = 'Toggle ARCHIVE',
|
|
|
|
c = 'Capture',
|
|
|
|
e = 'Export',
|
|
|
|
i = {
|
|
|
|
name = 'Insert',
|
|
|
|
h = 'Add headline',
|
|
|
|
t = 'Add TODO heading and content',
|
|
|
|
T = 'Add TODO heading'
|
|
|
|
},
|
|
|
|
J = 'Move subtree down',
|
|
|
|
K = 'Move subtree up',
|
|
|
|
o = 'Open at point',
|
|
|
|
r = 'Refile',
|
|
|
|
t = 'Set tags',
|
|
|
|
['$'] = 'Archive current headline'
|
|
|
|
},
|
|
|
|
['<leader><CR>'] = 'Org meta return',
|
|
|
|
['<C-a>'] = 'Org increase date',
|
|
|
|
['<C-x>'] = 'Org decrease date',
|
|
|
|
['cid'] = 'Org change date',
|
|
|
|
['cit'] = 'Org TODO',
|
|
|
|
['ciT'] = 'Org TODO prev',
|
|
|
|
['<C-Space>'] = 'Org toggle checkbox',
|
|
|
|
['<TAB>'] = 'Org cycle folding',
|
|
|
|
['<S-TAB>'] = 'Org cycle global folding',
|
|
|
|
['<<'] = 'Org promote headline',
|
|
|
|
['>>'] = 'Org demote headline',
|
|
|
|
['<s'] = 'Org prmote subtree',
|
|
|
|
['>s'] = 'Org demote subtree',
|
|
|
|
['}'] = 'Org next visible heading',
|
|
|
|
['{'] = 'Org previous visible heading',
|
|
|
|
[']]'] = 'Org forward heading',
|
|
|
|
['[['] = 'Org backward heading',
|
|
|
|
['g{'] = 'Org parent heading',
|
|
|
|
['?'] = 'Org help'
|
|
|
|
}, {buffer = api.nvim_get_current_buf()})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.treesitter()
|
|
|
|
local mappings = {
|
|
|
|
['['] = {
|
|
|
|
m = 'Previous start of outer class',
|
|
|
|
M = 'Previous end of outer class',
|
|
|
|
['['] = 'Previous start of outer function',
|
|
|
|
[']'] = 'Previous end of outer function'
|
|
|
|
},
|
|
|
|
[']'] = {
|
|
|
|
m = 'Next start of outer class',
|
|
|
|
M = 'Next end of outer class',
|
|
|
|
['['] = 'Next start of outer function',
|
|
|
|
[']'] = 'Next end of outer function'
|
|
|
|
},
|
|
|
|
g = {
|
|
|
|
n = {
|
|
|
|
name = 'Treesitter',
|
|
|
|
d = 'Goto definition',
|
|
|
|
D = 'List definitions',
|
|
|
|
i = 'Initialize selection',
|
|
|
|
j = 'Goto previous usage',
|
|
|
|
k = 'Goto next usage',
|
|
|
|
o = 'List definitions TOC',
|
|
|
|
r = 'Rename within scope'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local visual_mappings = {
|
|
|
|
a = {
|
|
|
|
c = 'Outer class',
|
|
|
|
f = 'Outer function'
|
|
|
|
},
|
|
|
|
i = {
|
|
|
|
c = 'Inner class',
|
|
|
|
f = 'Inner function'
|
|
|
|
},
|
|
|
|
g = {
|
|
|
|
n = {
|
|
|
|
name = 'Treesitter',
|
|
|
|
n = 'Increment node',
|
|
|
|
s = 'Increment scope',
|
|
|
|
m = 'Decrement node'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wk.register(mappings)
|
|
|
|
wk.register(visual_mappings, {mode = 'v'})
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.eft()
|
|
|
|
api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {silent = true})
|
|
|
|
api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {silent = true})
|
|
|
|
api.nvim_set_keymap('n', 'F', '<Plug>(eft-F)', {silent = true})
|
|
|
|
api.nvim_set_keymap('x', 'F', '<Plug>(eft-F)', {silent = true})
|
|
|
|
api.nvim_set_keymap('n', 't', '<Plug>(eft-t)', {silent = true})
|
|
|
|
api.nvim_set_keymap('x', 't', '<Plug>(eft-t)', {silent = true})
|
|
|
|
api.nvim_set_keymap('n', 'T', '<Plug>(eft-T)', {silent = true})
|
|
|
|
api.nvim_set_keymap('x', 'T', '<Plug>(eft-T)', {silent = true})
|
|
|
|
api.nvim_set_keymap('n', ';', '<Plug>(eft-repeat)', {silent = true})
|
|
|
|
api.nvim_set_keymap('x', ';', '<Plug>(eft-repeat)', {silent = true})
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.dial()
|
|
|
|
api.nvim_set_keymap('n', '<C-a>', '<Plug>(dial-increment)', {silent = true})
|
|
|
|
api.nvim_set_keymap('v', '<C-a>', '<Plug>(dial-increment)', {silent = true})
|
|
|
|
api.nvim_set_keymap('n', '<C-x>', '<Plug>(dial-decrement)', {silent = true})
|
|
|
|
api.nvim_set_keymap('v', '<C-x>', '<Plug>(dial-decrement)', {silent = true})
|
|
|
|
api.nvim_set_keymap('v', 'g<C-a>', '<Plug>(dial-increment-additional)', {silent = true})
|
|
|
|
api.nvim_set_keymap('v', 'g<C-x>', '<Plug>(dial-decrement-additional)', {silent = true})
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.neogen()
|
|
|
|
api.nvim_set_keymap('n', '<leader>eg', ':lua require("neogen").generate()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<C-e>', ':lua require("neogen").jump_next()<CR>', opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.gitlinker()
|
|
|
|
api.nvim_set_keymap('n', '<leader>gY', ':lua require("gitlinker").get_repo_url()<CR>', opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.dap()
|
|
|
|
api.nvim_set_keymap('n', '<leader>dn', ':lua require("dap").continue()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>dd', ':lua require("dap").disconnect()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>db', ':lua require("dap").toggle_breakpoint()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>dB', ':lua require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>dl', ':lua require("dap").list_breakpoints()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>dc', ':lua require("dap").run_to_cursor()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>dz', ':lua require("dap").run_last()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<F9>', ':lua require("dap").step_over()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>dv', ':lua require("dap").step_over()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<F10>', ':lua require("dap").step_into()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>di', ':lua require("dap").step_into()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<F11>', ':lua require("dap").step_out()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>do', ':lua require("dap").step_out()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>dr', ':lua require("dap").repl.open()<CR>', opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.dapui()
|
|
|
|
api.nvim_set_keymap('n', '<leader>de', ':lua require("dapui").eval()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('v', '<leader>de', ':lua require("dapui").eval()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>df', ':lua require("dapui").float_element()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>dt', ':lua require("dapui").toggle()<CR>', opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.telescope_symbols()
|
|
|
|
api.nvim_set_keymap('n', '<leader>fjg', ':lua require("telescope.builtin").symbols{sources = {"gitmoji"}, prompt_title = "Gitmoji"}<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>fjj', ':lua require("telescope.builtin").symbols{sources = {"emoji"}, prompt_title = "Emoji"}<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>fjk', ':lua require("telescope.builtin").symbols{sources = {"kaomoji"}, prompt_title = "Kaomoji"}<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>fjl', ':lua require("telescope.builtin").symbols{sources = {"julia"}, prompt_title = "Julia symbols"}<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>fjm', ':lua require("telescope.builtin").symbols{sources = {"math"}, prompt_title = "Math symbols"}<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>fjn', ':lua require("telescope.builtin").symbols{sources = {"nerd"}, prompt_title = "Nerd-fonts symbols"}<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>fjt', ':lua require("telescope.builtin").symbols{sources = {"latex"}, prompt_title = "Latex symbols"}<CR>', opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.spectre()
|
|
|
|
api.nvim_set_keymap('n', '<leader>po', ':lua require("spectre").open()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>pp', 'viw:lua require("spectre").open_file_search()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>pw', ':lua require("spectre").open_visual({select_word = true})<CR>', opts)
|
|
|
|
api.nvim_set_keymap('v', '<leader>p', ':lua require("spectre").open_visual()<CR>', opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.persistence()
|
|
|
|
api.nvim_set_keymap('n', '<leader>ss', ':lua require("persistence").save()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>sd', ':lua require("persistence").stop()<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>sl', ':lua require("persistence").load({last = true})<CR>', opts)
|
|
|
|
api.nvim_set_keymap('n', '<leader>sr', ':lua require("persistence").load()<CR>', opts)
|
|
|
|
end
|
|
|
|
|
2021-11-06 21:04:47 +01:00
|
|
|
return M
|