173 lines
7.8 KiB
Lua
173 lines
7.8 KiB
Lua
-- ################ ################ ################ ################
|
|
-- ################ ################ ################ ################
|
|
-- BASIC KEYBINDS
|
|
-- ################ ################ ################ ################
|
|
-- ################ ################ ################ ################
|
|
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
|
vim.keymap.set('n', '<leader>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 <C-\><C-n> to exit terminal mode
|
|
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
|
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
|
|
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
|
|
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
|
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
|
|
|
-- ################ ################ ################ ################
|
|
-- ################ ################ ################ ################
|
|
-- OIL-KEYMAPS
|
|
-- ################ ################ ################ ################
|
|
-- ################ ################ ################ ################
|
|
require('oil').setup {
|
|
keymaps = {
|
|
['g?'] = { 'actions.show_help', mode = 'n' },
|
|
['<CR>'] = 'actions.select',
|
|
['<C-s>'] = { 'actions.select', opts = { vertical = true } },
|
|
-- ['<C-h>'] = { 'actions.select', opts = { horizontal = true } },
|
|
['<C-t>'] = { 'actions.select', opts = { tab = true } },
|
|
['<C-p>'] = 'actions.preview',
|
|
['<C-c>'] = { 'actions.close', mode = 'n' },
|
|
-- ['<C-l>'] = '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', '<leader>o', '<CMD>Oil<CR>', { 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', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
|
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
|
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
|
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
|
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
|
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
|
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
|
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
|
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
|
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
|
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
|
|
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
|
|
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
|
|
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
|
|
-- Slightly advanced example of overriding default behavior and theme
|
|
vim.keymap.set('n', '<leader>/', 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', '<leader>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', '<leader>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 '<cmd>ObsidianFollowLink<CR>'
|
|
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', '<leader>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
|
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
-- Select the [p]revious item
|
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
|
|
-- Scroll the documentation window [b]ack / [f]orward
|
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-f>'] = 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.
|
|
['<C-y>'] = cmp.mapping.confirm { select = true },
|
|
|
|
-- If you prefer more traditional completion keymaps,
|
|
-- you can uncomment the following lines
|
|
--['<CR>'] = cmp.mapping.confirm { select = true },
|
|
--['<Tab>'] = cmp.mapping.select_next_item(),
|
|
--['<S-Tab>'] = 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.
|
|
['<C-Space>'] = cmp.mapping.complete {},
|
|
|
|
-- Think of <c-l> as moving to the right of your snippet expansion.
|
|
-- So if you have a snippet that's like:
|
|
-- function $name($args)
|
|
-- $body
|
|
-- end
|
|
--
|
|
-- <c-l> will move you to the right of each of the expansion locations.
|
|
-- <c-h> is similar, except moving you backwards.
|
|
['<C-l>'] = cmp.mapping(function()
|
|
if luasnip.expand_or_locally_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
end
|
|
end, { 'i', 's' }),
|
|
['<C-h>'] = cmp.mapping(function()
|
|
if luasnip.locally_jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
end
|
|
end, { 'i', 's' }),
|
|
},
|
|
}
|