-- ################ ################ ################ ################ -- ################ ################ ################ ################ -- BASIC KEYBINDS -- ################ ################ ################ ################ -- ################ ################ ################ ################ vim.keymap.set('n', '', 'nohlsearch') vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping -- or just use to exit terminal mode vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) -- ################ ################ ################ ################ -- ################ ################ ################ ################ -- OIL-KEYMAPS -- ################ ################ ################ ################ -- ################ ################ ################ ################ require('oil').setup { keymaps = { ['g?'] = { 'actions.show_help', mode = 'n' }, [''] = 'actions.select', [''] = { 'actions.select', opts = { vertical = true } }, -- [''] = { 'actions.select', opts = { horizontal = true } }, [''] = { 'actions.select', opts = { tab = true } }, [''] = 'actions.preview', [''] = { 'actions.close', mode = 'n' }, -- [''] = 'actions.refresh', ['-'] = { 'actions.parent', mode = 'n' }, ['_'] = { 'actions.open_cwd', mode = 'n' }, ['`'] = { 'actions.cd', mode = 'n' }, ['~'] = { 'actions.cd', opts = { scope = 'tab' }, mode = 'n' }, ['gs'] = { 'actions.change_sort', mode = 'n' }, ['gx'] = 'actions.open_external', ['g.'] = { 'actions.toggle_hidden', mode = 'n' }, ['g\\'] = { 'actions.toggle_trash', mode = 'n' }, }, vim.keymap.set('n', 'o', 'Oil', { desc = 'Open parent directory' }), -- Set to false to disable all of the above keymaps use_default_keymaps = true, } -- ################ ################ ################ ################ -- ################ ################ ################ ################ -- TELESCOPE-KEYMAPS -- ################ ################ ################ ################ -- ################ ################ ################ ################ local builtin = require 'telescope.builtin' vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false, }) end, { desc = '[/] Fuzzily search in current buffer' }) -- It's also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys vim.keymap.set('n', 's/', function() builtin.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files', } end, { desc = '[S]earch [/] in Open Files' }) -- Shortcut for searching your Neovim configuration files vim.keymap.set('n', 'sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' }) -- ################ ################ ################ ################ -- ################ ################ ################ ################ -- OBSIDIAN-KEYMAPS -- ################ ################ ################ ################ -- ################ ################ ################ ################ vim.keymap.set('n', 'gf', function() if require('obsidian').util.cursor_on_markdown_link() then return 'ObsidianFollowLink' else return 'gf' end end, { noremap = false, expr = true }) vim.keymap.set('n', 'gd', function() require('obsidian').util.gf_passthrough() end, { noremap = false, expr = true, buffer = true }) vim.keymap.set('n', 'ch', function() return require('obsidian').util.toggle_checkbox() end, { buffer = true }) vim.keymap.set('n', 'cr', function() return require('obsidian').util.smart_action() end, { buffer = true, expr = true }) -- ################ ################ ################ ################ -- ################ ################ ################ ################ -- CMP-KEYMAPS -- ################ ################ ################ ################ -- ################ ################ ################ ################ local cmp = require 'cmp' local luasnip = require 'luasnip' luasnip.config.setup {} cmp.setup { -- For an understanding of why these mappings were -- chosen, you will need to read `:help ins-completion` -- -- No, but seriously. Please read `:help ins-completion`, it is really good! mapping = cmp.mapping.preset.insert { -- Select the [n]ext item [''] = cmp.mapping.select_next_item(), -- Select the [p]revious item [''] = cmp.mapping.select_prev_item(), -- Scroll the documentation window [b]ack / [f]orward [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. [''] = cmp.mapping.confirm { select = true }, -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines --[''] = cmp.mapping.confirm { select = true }, --[''] = cmp.mapping.select_next_item(), --[''] = cmp.mapping.select_prev_item(), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display -- completions whenever it has completion options available. [''] = cmp.mapping.complete {}, -- Think of as moving to the right of your snippet expansion. -- So if you have a snippet that's like: -- function $name($args) -- $body -- end -- -- will move you to the right of each of the expansion locations. -- is similar, except moving you backwards. [''] = cmp.mapping(function() if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() end end, { 'i', 's' }), [''] = cmp.mapping(function() if luasnip.locally_jumpable(-1) then luasnip.jump(-1) end end, { 'i', 's' }), }, }