mirror of https://github.com/zpl-zak/nvimrc
91 lines
3.4 KiB
Lua
91 lines
3.4 KiB
Lua
-- [[ Basic Keymaps ]]
|
|
|
|
-- Keymaps for better default experience
|
|
-- See `:help vim.keymap.set()`
|
|
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
|
|
|
-- Remap for dealing with word wrap
|
|
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
|
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
|
|
|
-- [[ Highlight on yank ]]
|
|
-- See `:help vim.highlight.on_yank()`
|
|
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
callback = function()
|
|
vim.highlight.on_yank()
|
|
end,
|
|
group = highlight_group,
|
|
pattern = '*',
|
|
})
|
|
|
|
-- [[ Configure Telescope ]]
|
|
-- See `:help telescope` and `:help telescope.setup()`
|
|
require('telescope').setup {
|
|
defaults = {
|
|
file_ignore_patterns = {
|
|
"node_modules",
|
|
"tags",
|
|
"art",
|
|
"bin",
|
|
"dlls",
|
|
"__pycache__"
|
|
},
|
|
mappings = {
|
|
i = {
|
|
['<C-u>'] = false,
|
|
['<C-d>'] = false,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
-- Enable telescope fzf native, if installed
|
|
pcall(require('telescope').load_extension, 'fzf')
|
|
|
|
-- other maps
|
|
vim.keymap.set('n', '<leader>mm', vim.cmd.Ex)
|
|
|
|
-- ctags keymap
|
|
vim.keymap.set('n', '<C-\\>', ':tab split<CR>:exec("tag ".expand("<cword>"))<CR>')
|
|
vim.keymap.set('n', '<A-]>', ':vsp <CR>:exec("tag ".expand("<cword>"))<CR>')
|
|
|
|
-- build keymap
|
|
vim.keymap.set('n', '<C-b>', ':!./build.sh<CR><CR>')
|
|
vim.keymap.set('n', '<A-b>', ':!./build.sh<CR>')
|
|
|
|
-- scroll keymap
|
|
vim.keymap.set('n', '<c-up>', '<c-u>')
|
|
vim.keymap.set('n', '<c-down>', '<c-d>')
|
|
|
|
-- See `:help telescope.builtin`
|
|
local builtin = require('telescope.builtin')
|
|
vim.keymap.set('n', '<leader>?', builtin.oldfiles, { desc = '[?] Find recently opened files' })
|
|
vim.keymap.set('n', '<leader><space>', builtin.find_files, { desc = '[S]earch [F]iles' })
|
|
vim.keymap.set('n', '<leader>/', function()
|
|
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
|
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
|
winblend = 10,
|
|
previewer = false,
|
|
})
|
|
end, { desc = '[/] Fuzzily search in current buffer' })
|
|
|
|
vim.keymap.set('n', '<C-p>', builtin.git_files, { desc = 'Search [G]it [F]iles' })
|
|
vim.keymap.set('n', '<leader>gf', builtin.git_files, { desc = 'Search [G]it [F]iles' })
|
|
vim.keymap.set('n', '<leader>ff', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
|
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
|
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
|
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
|
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
|
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>ps', function ()
|
|
builtin.grep_string({ search = vim.fn.input("Grep > ") })
|
|
end)
|
|
|
|
-- Diagnostic keymaps
|
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" })
|
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" })
|
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
|
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" })
|