2022-06-20 13:49:53 +00:00
|
|
|
local function nnoremap(key, command)
|
|
|
|
vim.api.nvim_set_keymap("n", key, command, { noremap = true })
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.g.mapleader = " "
|
|
|
|
vim.g.maplocalleader = " "
|
|
|
|
|
|
|
|
-- Move around windows
|
2022-12-06 07:39:34 +00:00
|
|
|
nnoremap("<C-h>", ":wincmd h<CR>")
|
|
|
|
nnoremap("<C-j>", ":wincmd j<CR>")
|
|
|
|
nnoremap("<C-k>", ":wincmd k<CR>")
|
|
|
|
nnoremap("<C-l>", ":wincmd l<CR>")
|
2022-06-20 13:49:53 +00:00
|
|
|
|
|
|
|
-- Switch buffers
|
|
|
|
nnoremap("<C-PageDown>", ":TablineBufferNext<CR>")
|
|
|
|
nnoremap("<C-PageUp>", ":TablineBufferPrevious<CR>")
|
|
|
|
|
|
|
|
-- fugitive
|
|
|
|
nnoremap("<leader>g", ":0Git<CR>")
|
2023-01-25 09:43:54 +00:00
|
|
|
|
|
|
|
-- vim-flog
|
|
|
|
nnoremap("<leader>G", ":Flog -all -date=relative -open-cmd=new<CR>")
|
2022-06-20 13:49:53 +00:00
|
|
|
|
|
|
|
-- telescope
|
2022-11-23 14:20:09 +00:00
|
|
|
local telescope = require("telescope.builtin")
|
|
|
|
local telescope_themes = require("telescope.themes")
|
|
|
|
local telescope_projects = require("telescope").extensions.projects
|
|
|
|
|
|
|
|
local function map_telescope(key, telescope_function)
|
|
|
|
vim.api.nvim_set_keymap("n", key, "", {
|
|
|
|
noremap = true,
|
|
|
|
callback = function()
|
|
|
|
local theme = telescope_themes.get_dropdown({ layout_config = { width = 0.9 } })
|
|
|
|
telescope_function(theme)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
map_telescope("<leader>ff", telescope.find_files)
|
2023-07-26 11:31:37 +00:00
|
|
|
map_telescope("<leader>fb", telescope.buffers)
|
2022-11-23 14:20:09 +00:00
|
|
|
map_telescope("<leader>fg", telescope.git_files)
|
|
|
|
map_telescope("<leader>fp", telescope_projects.projects)
|
2023-06-27 07:43:30 +00:00
|
|
|
map_telescope("<leader>fs", telescope.lsp_document_symbols)
|
|
|
|
map_telescope("<leader>fS", telescope.lsp_dynamic_workspace_symbols)
|
2022-11-23 14:20:09 +00:00
|
|
|
map_telescope("<C-f>", telescope.grep_string)
|
|
|
|
map_telescope("<C-g>", telescope.live_grep)
|
2022-06-20 13:49:53 +00:00
|
|
|
|
|
|
|
-- terminal
|
|
|
|
vim.api.nvim_create_autocmd("TermOpen", {
|
|
|
|
pattern = "term://*",
|
|
|
|
callback = function()
|
|
|
|
local opts = { noremap = true }
|
|
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
|
|
|
|
end,
|
|
|
|
desc = "Map terminal esc and window switch keys",
|
|
|
|
})
|
|
|
|
|
|
|
|
-- buffer closing
|
2023-01-30 18:15:51 +00:00
|
|
|
nnoremap("gq", ":Bdelete<CR>")
|
2022-06-20 13:49:53 +00:00
|
|
|
|
|
|
|
-- toggle search highlighting
|
|
|
|
vim.cmd('nnoremap <expr> * v:hlsearch ? ":nohlsearch<cr>" : "*"')
|
2024-01-11 15:50:16 +00:00
|
|
|
|
|
|
|
-- insert-map jj/jk to escape
|
|
|
|
require("better_escape").setup()
|