Created
May 22, 2022 20:16
-
-
Save kLabz/f3529bb46bfd9e576b127207ed7c28e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mapleader=";" | |
" Disable F1 | |
noremap <F1> <Nop> | |
nnoremap <F1> <Nop> | |
inoremap <F1> <Nop> | |
vnoremap <F1> <Nop> | |
" Neovim configuration | |
" ------------------------------------- | |
" Edit THIS configuration file: (e)dit (c)onfiguration | |
" nnoremap <silent> <leader>ec :e $MYVIMRC<CR> | |
nnoremap <Leader>ec :call fzf#vim#files('', {'source': 'ag -f -g "" ~/.config/nvim/config/', 'down': '40%'})<CR> | |
" Source (reload) THIS configuration file after editing it: (s)ource (c)onfiguraiton | |
nnoremap <silent> <leader>sc :source $MYVIMRC<CR> | |
" Neovim commands | |
" ------------------------------------- | |
" Toggle line numbers | |
nnoremap <silent> <leader>nn :set number! number?<CR> | |
nnoremap <silent> <leader>nr :set relativenumber! number?<CR> | |
" Close quickfix | |
nmap <Leader>x :cclose<CR> | |
" Clear highlight (from search) | |
nmap <silent> <Leader>nh :noh<CR> | |
" nmap <Leader>w :w<CR> | |
" Disable accidental pasting with middle click | |
noremap <MiddleMouse> <LeftMouse> | |
inoremap <MiddleMouse> <LeftMouse> | |
map <2-MiddleMouse> <Nop> | |
imap <2-MiddleMouse> <Nop> | |
map <3-MiddleMouse> <Nop> | |
imap <3-MiddleMouse> <Nop> | |
map <4-MiddleMouse> <Nop> | |
imap <4-MiddleMouse> <Nop> | |
" Disable arrows (move split windows instead) | |
" ------------------------------------- | |
noremap <silent> <up> <C-w>k | |
noremap <silent> <down> <C-w>j | |
noremap <silent> <left> <C-w>h | |
noremap <silent> <right> <C-w>l | |
inoremap <silent> <up> <C-w>k | |
inoremap <silent> <down> <C-w>j | |
inoremap <silent> <left> <C-w>h | |
inoremap <silent> <right> <C-w>l | |
" Use Shift+arrows to resize splits | |
" ------------------------------------- | |
noremap <silent> <S-left> :exe "vertical resize " . (winwidth(0) - 10)<CR> | |
noremap <silent> <S-right> :exe "vertical resize " . (winwidth(0) + 10)<CR> | |
noremap <silent> <S-down> :exe "resize " . (winheight(0) - 10)<CR> | |
noremap <silent> <S-up> :exe "resize " . (winheight(0) + 10)<CR> | |
" noremap <silent> <C-S-left> :exe "vertical resize " . (winwidth(0) * 95/100)<CR> | |
" noremap <silent> <C-S-right> :exe "vertical resize " . (winwidth(0) * 100/95)<CR> | |
" noremap <silent> <C-S-down> :exe "resize " . (winheight(0) * 95/100)<CR> | |
" noremap <silent> <C-S-up> :exe "resize " . (winheight(0) * 100/95)<CR> | |
" Working with buffers | |
" ------------------------------------- | |
" Toggle buffer (switch between current and last buffer) | |
nnoremap <silent> <leader>bb <C-^> | |
" Go to next buffer | |
nnoremap <silent> <leader>bn :bn<CR> | |
nnoremap <C-l> :bn<CR> | |
" Go to previous buffer | |
nnoremap <silent> <leader>bp :bp<CR> | |
" https://github.com/neovim/neovim/issues/2048 | |
nnoremap <C-h> :bp<CR> | |
" Close buffer | |
nnoremap <silent> <leader>bd :bd<CR> | |
" Close buffer and keep window | |
nnoremap <silent> <leader>bw :bn\|:bd#<CR> | |
" Kill buffer | |
nnoremap <silent> <leader>bk :bd!<CR> | |
" Horizontal split with new buffer | |
nnoremap <silent> <leader>bh :new<CR> | |
" Vertical split with new buffer | |
nnoremap <silent> <leader>bv :vnew<CR> | |
" Improved keyboard support for navigation (especially terminal) | |
" https://neovim.io/doc/user/nvim_terminal_emulator.html | |
tnoremap <Esc> <C-\><C-n> | |
tnoremap <A-h> <C-\><C-n><C-w>h | |
tnoremap <A-j> <C-\><C-n><C-w>j | |
tnoremap <A-k> <C-\><C-n><C-w>k | |
tnoremap <A-l> <C-\><C-n><C-w>l | |
tnoremap <A-n> <C-\><C-n>:e#<CR> | |
nnoremap <A-h> <C-w>h | |
nnoremap <A-j> <C-w>j | |
nnoremap <A-k> <C-w>k | |
nnoremap <A-l> <C-w>l | |
nnoremap <A-n> :e#<CR> | |
" Integrated terminal | |
" ------------------------------------- | |
" Start terminal in insert mode | |
" au TermOpen * if &buftype == 'terminal' | :startinsert | endif | |
au BufEnter * if &buftype == 'terminal' | :startinsert | endif | |
" Terminal bindings | |
nnoremap <silent> <leader>tt :terminal<CR> | |
nnoremap <silent> <leader>tv :vnew<CR>:terminal<CR> | |
nnoremap <silent> <leader>th :new<CR>:terminal<CR> | |
" Vimwiki | |
" ------------------------------------- | |
nmap <Leader>ww :call fzf#vim#files('', {'source': 'ag -f -g "" ~/vimwiki/', 'down': '40%'})<CR> | |
nmap <Leader>wI <Plug>VimwikiMakeDiaryGenerateLinks | |
nmap <Leader>wD <Plug>VimwikiMakeDiaryNote | |
nmap <Leader>wY <Plug>VimwikiMakeYesterdayDiaryNote | |
nmap <Leader>wT <Plug>VimwikiMakeTomorrowDiaryNote | |
" FZF bindings (exit with C-c) | |
" ------------------------------------- | |
nmap , :Buffers<CR> | |
nmap <Leader>p :GFiles<CR> | |
" nmap <Leader>t :Files<CR> | |
nmap <Leader>r :Tags<CR> | |
nmap & :call fzf#vim#files('', {'source': 'ag --hidden --ignore node_modules -f -g ""', 'down': '40%'})<CR> | |
" nmap <silent> <Space> :call fzf#vim#files(expand("%:p:h") . '/..', fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}))<CR> | |
" TODO make this context-aware to work on non-haxe workspaces | |
" nmap ² :FZF .fzf<CR> | |
nmap ² :call fzf#vim#files('', fzf#vim#with_preview({'source': 'hxfzf', 'down': '40%'}))<CR> | |
let g:fzf_action = { | |
\ 'ctrl-t': 'tab split', | |
\ 'ctrl-x': 'split', | |
\ 'ctrl-v': 'vsplit' } | |
" Use quickfix for search (current word); use C-o (multiple times if | |
" neeeded) to go back to previous cursor position | |
nmap <Leader>ack :Ack! "\b<cword>\b" <CR> | |
nmap <Leader>acK :Ggrep! "\b<cword>\b" <CR> | |
" Handle git hunks | |
nnoremap <c-N> :GitGutterNextHunk<CR> | |
nnoremap <c-P> :GitGutterPrevHunk<CR> | |
nnoremap <c-U> :GitGutterUndoHunk<CR> | |
" Misc | |
" ------------------------------------- | |
" Pretty print json | |
nmap <Leader>pp :%!python -m json.tool<CR> | |
nmap <Leader>cpp :%!jq -c .<CR> | |
" Save with sudo | |
map <Leader>sudo :w !sudo tee %<CR> | |
nmap <Leader>bb :silent !trigger-build<CR> | |
nmap <Leader>ss :silent !stream-session<CR> | |
" Keep selected text when fixing indentation | |
vnoremap < <gv | |
vnoremap > >gv | |
" Open quickfix | |
nmap <Leader>qf :cope<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment