local Remap = require("halfdan.keymap") local nnoremap = Remap.nnoremap local vnoremap = Remap.vnoremap local inoremap = Remap.inoremap local tnoremap = Remap.tnoremap local xnoremap = Remap.xnoremap local nmap = Remap.nmap -- Yank until end of line nnoremap('Y', 'yg$') -- Next item, but center line nnoremap('n', 'nzzzv') nnoremap('N', 'Nzzzv') -- Join line but keep cursor intact nnoremap('J', 'mzJ`z') -- Move selected line / block of text in visual mode xnoremap('J', ':move \'>+1gv-gv') xnoremap('K', ':move \'<-2gv-gv') nnoremap('Q', '') -- better indenting vnoremap('<', '', '>gv') -- improved keyboard support for navigation (especially terminal) nnoremap('h', 'h') nnoremap('j', 'j') nnoremap('k', 'k') nnoremap('l', 'l') nnoremap('', 'h') nnoremap('', 'j') nnoremap('', 'k') nnoremap('', 'l') -- Change 2 split windows from vert to horiz or horiz to vert nnoremap('th', 'tH') nnoremap('tk', 'tK') nnoremap("\\", ":vsplit") nnoremap("/", ":split") -- Keybindings below this are neovim cli only if vim.g.vscode then -- Toggle Comment vim.keymap.set('x', 'gc', 'VSCodeCommentary', {}) vim.keymap.set('n', 'gc', 'VSCodeCommentary', {}) vim.keymap.set('o', 'gc', 'VSCodeCommentary', {}) vim.keymap.set('n', 'gcc', 'VSCodeCommentaryLine', {}) return end tnoremap('', '') nnoremap('', ':Neotree right toggle') -- resize with arrows nnoremap('', ':resize -2') nnoremap('', ':resize +2') nnoremap('', ':vertical resize -2') nnoremap('', ':vertical resize +2') -- Make adjusting split sizes a bit more friendly vim.cmd([[ noremap :vertical resize +3 noremap :vertical resize -3 noremap :resize +3 noremap :resize -3 ]]) -- Tab switch buffer nnoremap('', ':bnext') nnoremap('', ':bprevious') -- Quickfix list nnoremap('[q', ':cprev') nnoremap(']q', ':cnext') -- no arrow keys nnoremap("", "") nnoremap("", "") nnoremap("", "") nnoremap("", "") inoremap("", "") inoremap("", "") inoremap("", "") inoremap("", "") -- Tagbar nnoremap('hl', ':nohl') -- Vim Test nnoremap('tt', ':TestNearest') nnoremap('tT', ':TestFile') nnoremap('ta', ':TestSuite') nnoremap('tl', ':TestLast') nnoremap('tg', ':TestVisit') -- Vim Projectionist nnoremap('a', ':A') -- Reload init.lua nnoremap('sv', ':source $MYVIMRC') local builtin = require("telescope.builtin") nnoremap("gg", function() -- builtin.live_grep() require "telescope".extensions.egrepify.egrepify { sorting_strategy = 'ascending' } end) nnoremap("", function() builtin.find_files() end) nnoremap("ff", function() require('telescope').extensions.smart_open.smart_open({cwd_only = true}) end) nnoremap("fh", function() builtin.find_files{cwd=vim.fn.expand('%:p:h')} end) nnoremap("gw", function() builtin.grep_string { search = vim.fn.expand("") } end) nnoremap("fb", function() builtin.buffers() end) nnoremap("gc", function() builtin.git_branches() end)