dotfiles/.config/nvim/config/mappings.vim

120 lines
3.6 KiB
VimL

"###################################################################################
" __ ___ _
" / |/ /____ _ ____ ____ (_)____ ____ _ _____
" / /|_/ // __ `// __ \ / __ \ / // __ \ / __ `// ___/
" / / / // /_/ // /_/ // /_/ // // / / // /_/ /(__ )
" /_/ /_/ \__,_// .___// .___//_//_/ /_/ \__, //____/
" /_/ /_/ /____/
"
"###################################################################################
"***********************************************************************************
" Main Vim Keybinds
"***********************************************************************************
" Set leader to space bar
let mapleader = " "
let maplocalleader = " "
" Window Navigation
" Navigate to left window.
nnoremap <C-h> <C-w>h
" Navigate to down window.
nnoremap <C-j> <C-w>j
" Navigate to top window.
nnoremap <C-k> <C-w>k
" Navigate to right window.
nnoremap <C-l> <C-w>l
" Horizontal split then move to bottom window.
nnoremap <Leader>- <C-w>s
" Vertical split then move to right window.
nnoremap <Leader>\| <C-w>v<C-w>l
" Cycle tabs with Tab and Shift+Tab
nnoremap<silent> <Tab> :bnext<CR>
nnoremap<silent> <S-Tab> :bprevious<CR>
" Kill buffer with Space+bk
nnoremap<silent> <Space>bk :bdelete<CR>
"Faster ESC.
inoremap jk <ESC>
inoremap kj <ESC>
" Indent controls
" Reselect text ater indent/unindent.
vnoremap < <gv
vnoremap > >gv
" Tab to indent in visual mode.
vnoremap <Tab> >gv
" Shift+Tab to unindent in visual mode.
vnoremap <S-Tab> <gv
" Text alignment
nnoremap <Leader>Al :left<CR>
nnoremap <Leader>Ac :center<CR>
nnoremap <Leader>Ar :right<CR>
vnoremap <Leader>Al :left<CR>
vnoremap <Leader>Ac :center<CR>
vnoremap <Leader>Ar :right<CR>
"***********************************************************************************
" Plugin specific keybinds
"***********************************************************************************
" Git status
nnoremap <Leader>gs :Gstatus<cr>
" Git diff in split window
nnoremap <Leader>gd :Gdiffsplit<cr>
" Git commit
nnoremap <Leader>gc :Gcommit<cr>
" Git push
nnoremap <Leader>gP :Gpush<cr>
" Git pull
nnoremap <Leader>gp :Gpull<cr>
" Git move
nnoremap <Leader>gm :Gmove<cr>
" Git merge
nnoremap <Leader>gM :Gmerge<cr>
" browse current file on web
nnoremap <Leader>gb :Gbrowse<cr>
" browse current line on web
nnoremap <Leader>gbl :CocCommand git.browserOpen<cr>
" View chunk information in preview window.
nnoremap <Leader>gh :CocCommand git.chunkInfo<cr>
" View commit information in preview window.
nnoremap <Leader>gsc :CocCommand git.showCommit<cr>
" Toggle git gutter sign columns
nnoremap <Leader>gg :CocCommand git.toggleGutters<cr>
" NERD Commenter
" Toggle comments in visual or normal mode
nnoremap <leader>n :call NERDComment(0,"toggle")<cr>
vnoremap <leader>n :call NERDComment(1,"toggle")<cr>
" Toggle a sexy comment
nnoremap <leader>ns :call NERDComment(0,"sexy")<cr>
vnoremap <leader>ns :call NERDComment(1,"sexy")<cr>
" append a comment
nnoremap <leader>na :call NERDComment(0,"append")<cr>
vnoremap <leader>na :call NERDComment(1,"append")<cr>
" uncomment section
nnoremap <leader>nu :call NERDComment(0,"uncomment")<cr>
vnoremap <leader>nu :call NERDComment(1,"uncomment")<cr>
" invert comments
nnoremap <leader>ni :call NERDComment(0,"invert")<cr>
vnoremap <leader>ni :call NERDComment(1,"invert")<cr>
" comment section
nnoremap <leader>nc :call NERDComment(0,"comment")<cr>
vnoremap <leader>nc :call NERDComment(1,"comment")<cr>
"
" Fuzzy Finding
" fuzzy find files
nnoremap <silent> <Leader>ff :Files<CR>
" fuzzy find tags
nnoremap <silent> <Leader>ft :Vista finder ctags<CR>