--[[ &&& &##& █████╗ ██╗ ███████╗███╗ ███╗██╗ &##& ██╔══██╗██║ ██╔════╝████╗ ████║██║ BB& ███████║██║ █████╗ ██╔████╔██║██║ &GB & ██╔══██║██║ ██╔══╝ ██║╚██╔╝██║██║ &GB &BGBBBBBBBB###& ██║ ██║███████╗███████╗██║ ╚═╝ ██║██║ GG &GGGGGGGGGGGGGB#& ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ #P# &&#BGGGGGGGGGGG# nvim keybinds BP& &GGGGGGGGGB# &#BGPP& &#BGGGGGGGB# * keybinds are scoped in methods and &#BGGGGGPP& &&#BGGGGGGB##& only enabled if the relevant plugin &#GPPPGGGGGBPB &&##BGGGGGBB#&& is loaded #PPPPPPPGGPG BP& &&##BBGGGGGGBB#&& * binds are kinda arbitrary, if you PPPPPPPPPPPPGBPG&&& &&&&&&###BBBGGGGGGGBB##&& have good suggestions tell me &BGPPPPPPPPPPPPPPGGGGGGGGGGGGGGGGGGGBBB##&&& about it &&##BBBBGGGGGGGPGBBBBBB####&&&& &#B#& && ###& &G# &&#&&& &&& ]]-- local function wrap(func, ...) local args = {...} return function() func(unpack(args)) end end local KEYBINDS = { foldcolumn = false, } --|| GLOBAL KEYBINDS function KEYBINDS:set_global_keys(opts) -- Quick settings vim.keymap.set('n', '', ':set hls!', opts) vim.keymap.set('n', '', ':set wrap!', opts) vim.keymap.set('n', '', ':set list!', opts) vim.keymap.set('n', '', ':set spell!', opts) -- Files navigation vim.keymap.set('n', '', ':tabnew', opts) vim.keymap.set('n', '', ':tabnew', opts) -- fallback for windows vim.keymap.set('n', '', ':Neotree toggle', {noremap=true}) vim.keymap.set('n', '', ':Neotree toggle source=symbolmap right', {noremap=true}) vim.keymap.set('n', '', ':Neotree toggle source=diagnostics bottom', opts) vim.keymap.set('n', '', vim.cmd.UndotreeToggle, {noremap=true}) -- Esc goes back to normal mode in terminal vim.keymap.set('t', '', '', opts) vim.keymap.set('n', 'zi', function() if self.foldcolumn then vim.opt.foldcolumn = '0' else vim.opt.foldcolumn = '2' end self.foldcolumn = not self.foldcolumn end) end function KEYBINDS:set_navigation_keys(opts) -- lazy arrow scrolling vim.keymap.set('n', '', '', opts) vim.keymap.set('n', '', '', opts) vim.keymap.set('n', '', '', opts) vim.keymap.set('n', '', '', opts) vim.keymap.set('n', '', ':resize +1', opts) vim.keymap.set('n', '', ':resize -1', opts) vim.keymap.set('n', '', ':vertical resize +1', opts) vim.keymap.set('n', '', ':vertical resize -1', opts) end function KEYBINDS:set_lsp_keys(opts) -- Enable completion triggered by vim.api.nvim_buf_set_option(opts.buffer, 'omnifunc', 'v:lua.vim.lsp.omnifunc') -- Enable Lsp tagfunc vim.api.nvim_buf_set_option(opts.buffer, 'tagfunc', 'v:lua.vim.lsp.tagfunc') -- See `:help vim.lsp.*` for documentation on any of the below functions vim.keymap.set('n', 'D', vim.lsp.buf.declaration, opts) vim.keymap.set('n', 'd', vim.lsp.buf.definition, opts) vim.keymap.set('n', 'y', vim.lsp.buf.type_definition, opts) vim.keymap.set('n', 'i', vim.lsp.buf.implementation, opts) vim.keymap.set('n', 'r', vim.lsp.buf.references, opts) vim.keymap.set('n', 'h', vim.lsp.buf.hover, opts) vim.keymap.set('n', '', vim.lsp.buf.hover, opts) vim.keymap.set('n', '', vim.lsp.buf.hover, opts) vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) -- vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) -- vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) vim.keymap.set('n', '', vim.lsp.buf.rename, opts) vim.keymap.set('n', '', vim.lsp.buf.code_action, opts) vim.keymap.set('n', '', vim.diagnostic.open_float, opts) vim.keymap.set('n', '', vim.diagnostic.open_float, opts) vim.keymap.set('n', '', vim.diagnostic.open_float, opts) -- fallback for windows -- It's not really a keybind but whatever vim.api.nvim_create_user_command( 'Format', function(args) if args.range == 0 then vim.lsp.buf.format({ async = args.bang }) else local range = {} range['start'] = { args.line1, 0 } range['end'] = { args.line2, 0 } vim.lsp.buf.format({async=not args.bang, range=range}) end end, {bang=true, range=2} ) vim.keymap.set('n', '', ':ClangdSwitchSourceHeader', {}) end function KEYBINDS:set_telescope_keys(opts) local telescope = require('telescope.builtin') local theme = require('telescope.themes') -- File navigation vim.keymap.set('n', '', wrap(telescope.oldfiles, {layout_strategy = 'vertical' }), opts) vim.keymap.set('n', '', wrap(telescope.oldfiles, {layout_strategy = 'vertical' }), opts) -- fallback for windows... even is used vim.keymap.set('n', '', telescope.find_files, opts) vim.keymap.set('n', '', telescope.find_files, opts) -- fallback for windows vim.keymap.set('n', '', wrap(telescope.live_grep, {layout_strategy = 'vertical'}), opts) vim.keymap.set('n', '', wrap(telescope.live_grep, {layout_strategy = 'vertical'}), opts) -- fallback for windows vim.keymap.set('n', '', wrap(telescope.lsp_references, theme.get_cursor()), opts) vim.keymap.set('n', '', wrap(telescope.jumplist, theme.get_dropdown()), opts) vim.keymap.set('n', '', telescope.git_bcommits, opts) vim.keymap.set('n', '', telescope.git_bcommits, opts) -- fallback for windows vim.keymap.set('n', '', wrap(telescope.registers, theme.get_dropdown()), opts) -- fallback for windows -- Marks and buffers with telescope vim.keymap.set('n', '', telescope.buffers, opts) vim.keymap.set('n', '', wrap(telescope.marks, theme.get_dropdown()), opts) vim.keymap.set('n', '', wrap(telescope.marks, theme.get_dropdown()), opts) -- fallback for windows vim.keymap.set('n', '', wrap(telescope.current_buffer_fuzzy_find, {layout_strategy = 'vertical'}), opts) vim.keymap.set('n', '', wrap(telescope.current_buffer_fuzzy_find, {layout_strategy = 'vertical'}), opts) -- fallback for windows -- Symbols with telescope vim.keymap.set('n', '', telescope.lsp_document_symbols, opts) vim.keymap.set('n', '', wrap(telescope.lsp_dynamic_workspace_symbols, {layout_strategy = 'vertical'}), opts) vim.keymap.set('n', '', wrap(telescope.lsp_dynamic_workspace_symbols, {layout_strategy = 'vertical'}), opts) -- Resule last vim.keymap.set('n', '', telescope.resume, opts) vim.keymap.set('n', '', telescope.resume, opts) -- Error list with telescope vim.keymap.set('n', '', wrap(telescope.diagnostics, theme.get_ivy({bufnr=0})), opts) end function KEYBINDS:set_dap_keys(opts) -- dapui local dap = require('dap') local dapui = require('dapui') vim.keymap.set('n', '' , function() dapui.toggle({}) end, {}) vim.keymap.set('n', '' , function() dap.toggle_breakpoint() end, {}) vim.keymap.set('n', '' , function() dap.continue() end, {}) vim.keymap.set('n', '', function() dap.step_over() end, {}) vim.keymap.set('n', '', function() dap.step_into() end, {}) vim.keymap.set('n', '', function() dap.step_out() end, {}) end return KEYBINDS