Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
haininhhoang94 committed Mar 12, 2021
1 parent 4149ea2 commit 013a46d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ else
" Themes
source $HOME/.config/nvim/themes/syntax.vim
source $HOME/.config/nvim/themes/nvcode.vim
source $HOME/.config/nvim/plug-config/hardtime.vim

" Plugin configuration
source $HOME/.config/nvim/keys/which-key.vim
Expand Down Expand Up @@ -73,6 +72,7 @@ else
" source $HOME/.config/nvim/plug-config/illuminate.vim
" source $HOME/.config/nvim/plug-config/sneak.vim
" source $HOME/.config/nvim/plug-config/markdown-img-paste.vim
" source $HOME/.config/nvim/plug-config/hardtime.vim
endif
source $HOME/.config/nvim/plug-config/quickscope.vim

Expand Down
49 changes: 48 additions & 1 deletion keys/mappings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,56 @@ else
nnoremap <C-Left> :vertical resize -2<CR>
nnoremap <C-Right> :vertical resize +2<CR>
endif

endif

" Better nav for omnicomplete
inoremap <expr> <c-j> ("\<C-n>")
inoremap <expr> <c-k> ("\<C-p>")
"TODO
" 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 && indent(line) == indent ||
\ a:lowerlevel && indent(line) < indent)
if (! a:skipblanks || strlen(getline(line)) > 0)
if (a:exclusive)
let line = line - stepvalue
endif
exe line
exe "normal " column . "|"
return
endif
endif
endwhile
endfunction

" Moving back and forth between lines of same or lower indentation.
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>
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>
2 changes: 1 addition & 1 deletion plug-config/hardtime.vim
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let g:hardtime_default_on = 1
" let g:hardtime_default_on = 1

0 comments on commit 013a46d

Please sign in to comment.