mirror of https://github.com/zpl-zak/nvimrc
86 lines
3.4 KiB
Lua
86 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`
|
|
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
|
|
vim.keymap.set('n', '<leader><space>', require('telescope.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.
|
|
require('telescope.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', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
|
|
vim.keymap.set('n', '<leader>ff', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
|
|
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
|
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
|
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
|
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
|
|
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
|
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
|
|
|
-- 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" })
|