This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/apps/neovim/bindings.vim
Daniel Flanagan 2dda9880d5
Squashed commit of the following:
commit 74cc8fa92e
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Fri Jan 24 12:45:49 2020 -0600

    MIC SCRIPT

commit dbd88dde4b
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Thu Jan 23 12:38:19 2020 -0600

    Mic script, amd stuff, more fish fixes

commit dadb7da642
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Thu Jan 23 09:51:03 2020 -0600

    Remove more generated fish stuff, more fixes

commit b09a25cc17
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Wed Jan 22 17:25:47 2020 -0600

    More fixes to various things

commit 58f6626280
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Wed Jan 22 08:34:12 2020 -0600

    Updates

commit 00e919f7f5
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 14:28:45 2020 -0600

    Fix notes and add vim pager

commit 5100983350
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 14:01:06 2020 -0600

    More fixes and cleanup

commit 85eab2155c
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 13:09:31 2020 -0600

    More notes

commit da496b7f0c
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 12:43:55 2020 -0600

    Maybe actually fix colors?

commit 3c11353256
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 12:32:23 2020 -0600

    Colors fixed?

commit f2a5060e7d
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 11:40:26 2020 -0600

    Things

commit f44d0d5479
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 10:54:09 2020 -0600

    Kitty colors

commit 5f0fa76a67
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 10:49:06 2020 -0600

    More updates for fish migration

commit 5b05be9fe7
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 09:14:08 2020 -0600

    Nah

commit fe0f1d8e32
Merge: 52fe38f 205c12a
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 09:13:09 2020 -0600

    Merge branch 'dev' of ssh://git.lyte.dev:2222/lytedev/dotfiles into dev

commit 52fe38f42a
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 20 09:12:52 2020 -0600

    More fish fixes

commit 205c12a051
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Sat Jan 18 23:15:13 2020 -0600

    WIP

commit b73c4b26a4
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Fri Jan 17 10:36:20 2020 -0600

    Remove debug code, fix asdf references for fish

commit d6ecaf88be
Merge: 2e6b90b 46793bb
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Fri Jan 17 10:34:01 2020 -0600

    Merge remote-tracking branch 'origin/lappy' into dev

commit 2e6b90bed3
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Fri Jan 17 10:26:00 2020 -0600

    Pulsemixer > pavucontrol and some sway fixes

commit 46793bb735
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Fri Jan 17 03:02:53 2020 -0600

    Whew

commit 26f32a0c6b
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Thu Jan 16 17:01:59 2020 -0600

    WIP fish configuration

commit fb0389eea4
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Thu Jan 16 13:30:35 2020 -0600

    Fiiiish

commit 2f1af8411a
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Thu Jan 16 13:28:23 2020 -0600

    Stuff

commit ba8ec1f524
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Thu Jan 9 19:02:31 2020 -0600

    Fix some dock stuff, erlang with wx

commit d80a823ce2
Merge: 36d58e0 5195a85
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Wed Jan 8 13:32:56 2020 -0600

    Merge remote-tracking branch 'origin/lappy' into wip-refactor

commit 36d58e037f
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Wed Jan 8 10:59:45 2020 -0600

    Testing signed commits

commit 5195a855a6
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Tue Jan 7 19:38:43 2020 -0600

    Bars

commit 1acb330746
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Tue Jan 7 11:36:12 2020 -0600

    SWAAAAAY

commit f547e5ec28
Merge: aa29acb b1709d1
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Tue Jan 7 10:59:24 2020 -0600

    Merge remote-tracking branch 'origin/wip-refactor' into lappy

commit b1709d1e94
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Tue Jan 7 10:59:22 2020 -0600

    Stuff

commit aa29acb364
Merge: 66cc873 2456dad
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Tue Jan 7 10:58:29 2020 -0600

    Merge remote-tracking branch 'origin/wip-refactor' into lappy

commit 2456dad7de
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Jan 6 11:15:30 2020 -0600

    Zstd

commit 66cc8734a8
Author: Daniel Flanagan <daniel@lyte.dev>
Date:   Tue Dec 31 21:48:49 2019 -0600

    Fix sudo setup and use fancy email for git

commit a05c02e1fb
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Tue Dec 31 17:03:22 2019 -0600

    Fancy colors

commit 026220fe26
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Tue Dec 31 16:55:45 2019 -0600

    SMTP tools

commit e2a854df65
Merge: 0d0e131 825d91b
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Tue Dec 31 15:07:09 2019 -0600

    Merge branch 'wip-refactor' into lappy

commit 0d0e131714
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Tue Dec 31 14:26:44 2019 -0600

    Stuff

commit 825d91b462
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Tue Dec 31 10:15:01 2019 -0600

    Utility updates

commit ae350894af
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Dec 30 10:02:14 2019 -0600

    Lul.

commit ea5debe38c
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Dec 16 17:21:44 2019 -0600

    WIP chat system

commit c40fe94b70
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Dec 16 09:57:21 2019 -0600

    Add weechat config

commit 76e8a68c34
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Dec 16 09:51:21 2019 -0600

    Preparing for weechat stuf

commit 25aecdc139
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Fri Dec 13 11:32:15 2019 -0600

    Goodies?

commit 8d1e86feb4
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Thu Dec 12 13:31:18 2019 -0600

    Logging for pipelines?

commit b81bdf6abd
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Thu Dec 12 13:17:20 2019 -0600

    errors break things?

commit 6f7d80d761
Merge: 7659442 bc5ce9e
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Thu Dec 12 13:04:52 2019 -0600

    Merge branch 'master' of ssh://git.lyte.dev:2222/lytedev/dotfiles

commit 76594427ff
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Thu Dec 12 13:00:03 2019 -0600

    Pipelines!

commit 972508e74d
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Thu Dec 12 11:02:24 2019 -0600

    WIP pipeline

commit 898848669c
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Fri Dec 6 10:08:42 2019 -0600

    Archive

commit 16895af798
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Thu Dec 5 16:09:52 2019 -0600

    Helpful bins

commit 3a8eb5d475
Author: Daniel Flanagan <daniel@lytedev.io>
Date:   Mon Dec 2 09:31:28 2019 -0600

    Move a lot of stuff around
2020-01-24 12:46:51 -06:00

250 lines
6.7 KiB
VimL

" common typo fixes
command! WQ wq
command! Wq wq
command! Wqa wqa
command! W w
command! Q q
" best leader
let mapleader = "\<Space>"
" enter insert mode when entering a terminal buffer
augroup InsertModeOnBlankTerminal
autocmd BufWinEnter,WinEnter term://* startinsert
augroup END
" terminal mappings
nnoremap <leader>t :split term://$SHELL<CR><C-\><C-n>:resize 24<CR>i
nnoremap <C-t> :split term://$SHELL<CR><C-\><C-n>:resize 24<CR>i
nnoremap <leader><leader>t :vsplit term://$SHELL<CR><C-\><C-n>:vertical resize 120<CR>i
" nnoremap <C-S-T> :vsplit term://$SHELL<CR><C-\><C-n>:vertical resize 120<CR>i
nnoremap <C-y> :vsplit term://$SHELL<CR><C-\><C-n>:vertical resize 120<CR>i
" close the terminal
tnoremap <C-w> <C-\><C-n>:q!<CR>
tnoremap <leader>w <C-\><C-n>:q!<CR>
tnoremap <C-n> <C-\><C-n>
tnoremap <C-[> <C-\><C-n>
" moving between terminal splits
tnoremap <C-h> <C-\><C-n>:TmuxNavigateLeft<CR>
tnoremap <C-j> <C-\><C-n>:TmuxNavigateDown<CR>
tnoremap <C-k> <C-\><C-n>:TmuxNavigateUp<CR>
tnoremap <C-l> <C-\><C-n>:TmuxNavigateRight<CR>
" Jump to the next or previous line that has the same level or a lower
" level of indentation than the current line.
"
" exclusive (bool): true: Motion is exclusive
" false: Motion is inclusive
" fwd (bool): true: Go to next line
" false: Go to previous line
" lowerlevel (bool): true: Go to line with lower indentation level
" false: Go to line with the same indentation level
" skipblanks (bool): true: Skip blank lines
" false: Don't skip blank lines
function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
let line = line('.')
let column = col('.')
let lastline = line('$')
let indent = indent(line)
let stepvalue = a:fwd ? 1 : -1
while (line > 0 && line <= lastline)
let line = line + stepvalue
if ( a:lowerlevel == 0 && indent(line) == indent ||
\ a:lowerlevel == 1 && indent(line) < indent ||
\ a:lowerlevel == -1 && indent(line) > indent)
if (! a:skipblanks || strlen(getline(line)) > 0)
if (a:exclusive)
let line = line - stepvalue
endif
exe line
exe 'normal ' (column+1) . '|'
return
endif
endif
endwhile
endfunction
" moving back and forth between lines of same or lower indentation should be sane
nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
nnoremap <silent> [<C-l> :call NextIndent(0, 0, -1, 1)<CR>
nnoremap <silent> ]<C-l> :call NextIndent(0, 1, -1, 1)<CR>
vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>
" run make with leader,m
nnoremap <leader>m :call RunMake()<CR>
" NERDTree bindings
" show file manager in current directory
nnoremap <C-n> :NERDTreeToggle<CR>
" show file manager in git repo root
nnoremap <leader>n :call NERDProjectViewer()<CR>
" focus the current file in NERDTree
nnoremap <leader>gn :NERDTreeFind<CR>
" don't kill vim
" REBIND
nnoremap <leader>K <Nop>
nnoremap <S-K> <NOP>
" quick paragraph formatting
vmap Q gq
nmap Q gqap
" launch fzf for the current git repo
nnoremap <C-p> :GitFiles<CR>
" launch fzf for files in the current directory
nnoremap <C-o> :Files<CR>
" launch fzf for files modified or not in git
nnoremap <C-u> :GFiles?<CR>
" launch fzf for open buffers (files)
nnoremap <C-b> :Buffers<CR>
" launch fzf for open buffers (files)
nnoremap <leader>l :Buffers<CR>
" switch to previous buffer
nnoremap <leader>h :b#<CR>
" use leader j and k to switch buffers as well
nnoremap <leader>k :bnext<CR>
nnoremap <leader>j :bprevious<CR>
" window/pane navigation
nnoremap <C-h> :TmuxNavigateLeft<CR>
nnoremap <C-j> :TmuxNavigateDown<CR>
nnoremap <C-k> :TmuxNavigateUp<CR>
nnoremap <C-l> :TmuxNavigateRight<CR>
if has('nvim')
nnoremap <leader>r :source $vimdir/init.vim<CR>
else
nnoremap <leader>r :source $HOME/.vimrc<CR>
endif
" change buffers with leader,tab
nnoremap <leader><Tab> :bnext<CR>
nnoremap <leader><S-Tab> :bprevious<CR>
" fast word change
nnoremap <leader>c ciw
nnoremap <leader>C ciW
" fast splits
nnoremap <silent> <leader>s :split<CR>
nnoremap <silent> <leader>v :vsplit<CR>
" fast split closing
nnoremap <silent> <leader>q <C-w>q
" clear search higlight
nnoremap <silent> <leader>/ :let @/ = ""<CR>:<BACKSPACE>
" remap jk/jj and its variants to escape
inoremap jj <Esc>
inoremap Jj <Esc>
inoremap Jj <Esc>
inoremap JJ <Esc>
inoremap jk <Esc>
inoremap Jk <Esc>
inoremap jK <Esc>
inoremap JK <Esc>
" use hjkl-movement between rows when soft wrapping:
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
" camel case motions
map <silent> ,w <Plug>CamelCaseMotion_w
map <silent> ,b <Plug>CamelCaseMotion_b
map <silent> ,e <Plug>CamelCaseMotion_e
map <silent> ,ge <Plug>CamelCaseMotion_ge
" inner _ objects
omap <silent> ib <Plug>CamelCaseMotion_ib
xmap <silent> ib <Plug>CamelCaseMotion_ib
omap <silent> ie <Plug>CamelCaseMotion_ie
xmap <silent> ie <Plug>CamelCaseMotion_ie
" remove trailing whitespace
map <F3> mw:%s/\s\+$//<CR>:let @/ = ""<CR>'w
" close buffer with leader-w
nnoremap <silent> <leader>w :bd<CR>
" toggle spell checking:
map <F4> :setlocal spell!<CR>
" open urls, files, etc. example: http://google.com:
noremap <leader>o :!xdg-open <cfile><CR><CR>
" insert newline
" NOTE: doesn't work in terminals?
" noremap <S-Enter> i<Enter><Esc>
" noremap <C-o> i<Enter><Esc>
" prevent wildmenu
map q: :q
noremap qqq: q:
" sane n/N behavior
nnoremap <expr> n 'Nn'[v:searchforward]
nnoremap <expr> N 'nN'[v:searchforward]
" better command history navigation
cnoremap <c-n> <down>
cnoremap <c-p> <up>
" keep selection after indenting visual selection
xnoremap < <gv
xnoremap > >gv
" distraction-free mode
nnoremap <silent> <leader>df :DistractionFreeMode<CR>
" recalc syntax highlighting
nnoremap <leader>gs :syntax sync fromstart<CR>
" lsp bindings
" coc
" open coc config
nnoremap <leader><space>c :CocConfig<CR>
" smart jumps
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap <silent> g[ <Plug>(coc-diagnostic-prev)
nmap <silent> g] <Plug>(coc-diagnostic-next)
nmap <leader>ac <Plug>(coc-codeaction)
nmap <leader>qf <Plug>(coc-fix-current)
" ale
" go to definitions
" nnoremap <leader>gd :ALEGoToDefinition<CR>
" nnoremap <leader>gh :ALEGoToDefinitionInSplit<CR>
" nnoremap <leader>gv :ALEGoToDefinitionInVSplit<CR>