70 lines
2.3 KiB
Lua
70 lines
2.3 KiB
Lua
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
|
|
nnoremap("<C-h>", ":wincmd h<CR>")
|
|
nnoremap("<C-j>", ":wincmd j<CR>")
|
|
nnoremap("<C-k>", ":wincmd k<CR>")
|
|
nnoremap("<C-l>", ":wincmd l<CR>")
|
|
|
|
-- Switch buffers
|
|
nnoremap("<C-PageDown>", ":TablineBufferNext<CR>")
|
|
nnoremap("<C-PageUp>", ":TablineBufferPrevious<CR>")
|
|
|
|
-- fugitive
|
|
nnoremap("<leader>g", ":0Git<CR>")
|
|
|
|
-- vim-flog
|
|
nnoremap("<leader>G", ":Flog -all -date=relative -open-cmd=new<CR>")
|
|
|
|
-- telescope
|
|
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)
|
|
map_telescope("<leader>fb", telescope.buffers)
|
|
map_telescope("<leader>fg", telescope.git_files)
|
|
map_telescope("<leader>fp", telescope_projects.projects)
|
|
map_telescope("<leader>fs", telescope.lsp_document_symbols)
|
|
map_telescope("<leader>fS", telescope.lsp_dynamic_workspace_symbols)
|
|
map_telescope("<C-f>", telescope.grep_string)
|
|
map_telescope("<C-g>", telescope.live_grep)
|
|
|
|
-- 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
|
|
nnoremap("gq", ":Bdelete<CR>")
|
|
|
|
-- toggle search highlighting
|
|
vim.cmd('nnoremap <expr> * v:hlsearch ? ":nohlsearch<cr>" : "*"')
|
|
|
|
-- insert-map jj/jk to escape
|
|
require("better_escape").setup()
|