--[[ &&& &##& █████╗ ██╗ ███████╗███╗ ███╗██╗ &##& ██╔══██╗██║ ██╔════╝████╗ ████║██║ 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 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', '', ':NvimTreeToggle', {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', 'gD', vim.lsp.buf.declaration, opts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) vim.keymap.set('n', 'gy', vim.lsp.buf.type_definition, opts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, 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.lsp.buf.formatting, 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', ':lua vim.lsp.buf.formatting()', {}) -- TODO if function is passed directly, it doesn't work! end function KEYBINDS:set_telescope_keys(opts) -- File navigation vim.keymap.set('n', '', ':Telescope oldfiles', opts) vim.keymap.set('n', '', ':Telescope find_files', opts) vim.keymap.set('n', 'F', ':Telescope find_files', opts) -- fallback for windows vim.keymap.set('n', '', ':Telescope live_grep', opts) vim.keymap.set('n', '', ':Telescope live_grep', opts) -- fallback for windows vim.keymap.set('n', '', ':Telescope lsp_references', opts) vim.keymap.set('n', '', ':Telescope git_bcommits', opts) vim.keymap.set('n', '', ':Telescope git_bcommits', opts) -- fallback for windows -- Marks and buffers with telescope vim.keymap.set('n', '', ':Telescope buffers', opts) vim.keymap.set('n', '', ':Telescope marks', opts) vim.keymap.set('n', '', ':Telescope marks', opts) -- fallback for windows vim.keymap.set('n', '', ':Telescope current_buffer_fuzzy_find', opts) vim.keymap.set('n', '', ':Telescope current_buffer_fuzzy_find', opts) -- fallback for windows -- Symbols with telescope vim.keymap.set('n', '', ':Telescope lsp_document_symbols', opts) vim.keymap.set('n', '', ':Telescope lsp_workspace_symbols', opts) vim.keymap.set('n', '', ':Telescope lsp_workspace_symbols', opts) -- fallback for windows -- Error list with telescope vim.keymap.set('n', '', ':Telescope diagnostics', opts) vim.keymap.set('n', '', ':Telescope diagnostics 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