Last active
July 6, 2020 00:50
-
-
Save theol0403/9506a1a8fcd90ee3b2a63374c21a6edd to your computer and use it in GitHub Desktop.
My vimrc
This file contains hidden or 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
"plugins | |
function! Cond(Cond, ...) | |
let opts = get(a:000, 0, {}) | |
return a:Cond ? opts : extend(opts, { 'on': [], 'for': [] }) | |
endfunction | |
call plug#begin('~/.vim/plugged') | |
" essentials | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-surround' "ys{motion}{type} ds{type} cs{type} v_S{type} | |
Plug 'tpope/vim-commentary' "gc{motion} gcc gcgc | |
Plug 'tpope/vim-unimpaired' "[space [exchange | |
Plug 'tpope/vim-abolish' "abbreviations | |
Plug 'AndrewRadev/switch.vim' "gs switches value | |
Plug 'inkarkat/vim-ReplaceWithRegister' "gr | |
Plug 'tommcdo/vim-exchange' "cx v_X cxc | |
Plug 'PeterRincker/vim-argumentative' "<, shift argument, [, move argument, , - argument | |
Plug 'wellle/targets.vim' "I - inner inner, A - around space, n l - next & seek multi line, inside separators, a - argument | |
Plug 'kana/vim-smartinput', Cond(!exists('g:vscode')) | |
Plug 'haya14busa/vim-asterisk' | |
" syntax and language | |
Plug 'neoclide/coc.nvim', Cond(!exists('g:vscode'), {'branch': 'release'}) | |
Plug 'sheerun/vim-polyglot', Cond(!exists('g:vscode')) | |
Plug 'vim-syntastic/syntastic', Cond(!exists('g:vscode')) | |
Plug 'phanviet/vim-monokai-pro', Cond(!exists('g:vscode')) | |
Plug 'jackguo380/vim-lsp-cxx-highlight', Cond(!exists('g:vscode')) | |
Plug 'jeetsukumaran/vim-pythonsense', { 'for': 'python', 'branch': 'develop' } | |
" visual improvements | |
Plug 'mhinz/vim-startify', Cond(!exists('g:vscode')) | |
Plug 'psliwka/vim-smoothie', Cond(!exists('g:vscode')) | |
Plug 'machakann/vim-highlightedyank' | |
Plug 'danilamihailov/beacon.nvim', Cond(!exists('g:vscode')) | |
Plug 'myusuf3/numbers.vim', Cond(!exists('g:vscode')) | |
Plug 'dominikduda/vim_current_word' | |
Plug 'markonm/traces.vim', Cond(!exists('g:vscode')) | |
Plug 'unblevable/quick-scope' | |
" fancy text objects | |
Plug 'kana/vim-textobj-user' | |
Plug 'kana/vim-textobj-entire' "e - entire | |
Plug 'adolenc/vim-textobj-toplevel' "T - toplevel paragraph that follows until original indentation | |
Plug 'kana/vim-textobj-indent' "i - indent block, I - same indent (wont select sub indent) | |
Plug 'pianohacker/vim-textobj-indented-paragraph' "r - paragraph that won't go less indent | |
Plug 'glts/vim-textobj-comment' "/ - comment | |
Plug 'kana/vim-textobj-line' "l - line | |
Plug 'Julian/vim-textobj-variable-segment' "v - segment | |
Plug 'haya14busa/vim-textobj-number' "n - number (do you want gn - jump to number) | |
Plug 'kana/vim-textobj-function' "f - function | |
Plug 'haya14busa/vim-textobj-function-syntax' | |
Plug 'landock/vim-expand-region' "+ - expand, _ - shrink | |
" easy motion | |
Plug 'easymotion/vim-easymotion', Cond(!exists('g:vscode')) | |
Plug 'asvetliakov/vim-easymotion', Cond(exists('g:vscode'), { 'as': 'vsc-easymotion' }) | |
Plug 'haya14busa/vim-easyoperator-line' "operator on range of lines {op}<space>l{start}{end} | |
Plug 'justinmk/vim-sneak' "<space>s <space>S {operator}z v_s v_Z | |
" latex | |
" plug 'vim-latex/vim-latex' | |
" Plug 'lervag/vimtex' | |
" Plug 'xuhdev/vim-latex-live-preview' | |
Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'} | |
call plug#end() | |
packadd vimball | |
packadd! matchit | |
set nocompatible | |
set confirm | |
set history=1000 | |
set undolevels=1000 | |
set undoreload=10000 | |
set timeoutlen=3000 | |
set autoread | |
set undofile | |
set expandtab | |
set backspace=indent,eol,start | |
set whichwrap+=<,>,h,l | |
set sw=2 | |
set textwidth=80 | |
set autoindent | |
set smartindent | |
set hlsearch | |
set incsearch | |
set ignorecase | |
set smartcase | |
set showcmd | |
set clipboard=unnamedplus,unnamed | |
let g:targets_gracious = 1 | |
let g:vimtex_mappings_override_existing = 1 | |
let g:Tex_AdvancedMath = 1 | |
let g:livepreview_previewer = 'okular' | |
let g:vim_be_good_floating = 0 | |
let g:vim_current_word#highlight_only_in_focused_window = 1 | |
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] | |
" excape | |
imap jk <esc> | |
imap kj <esc> | |
imap <C-@> <C-[> | |
vmap <C-@> <C-[> | |
" Make Y behave like D, A, I, etc. | |
map Y y$ | |
" Make Q repeat the last recorded macro | |
map Q @@ | |
" clear hl | |
nnoremap <silent> <leader>n :nohl<CR><C-l> | |
" break line | |
nnoremap <C-J> i<CR><Esc>k$ | |
" swap line | |
nnoremap <A-j> :m .+1<CR>== | |
nnoremap <A-k> :m .-2<CR>== | |
inoremap <A-j> <Esc>:m .+1<CR>==gi | |
inoremap <A-k> <Esc>:m .-2<CR>==gi | |
vnoremap <A-j> :m '>+1<CR>gv=gv | |
vnoremap <A-k> :m '<-2<CR>gv=gv | |
" save | |
map <C-S> :wall<CR> | |
imap <C-S> <ESC>:wall<CR> | |
" sudo save | |
command! W w !sudo tee % > /dev/null | |
" move without exit visual | |
vnoremap < <gv | |
vnoremap > >gv | |
" move in insert | |
imap <C-j> <c-o>j | |
imap <C-k> <c-o>k | |
imap <C-h> <c-o>h | |
imap <C-l> <c-o>l | |
imap <C-A-H> <home> | |
imap <C-A-L> <end> | |
cmap <C-h> <c-o>h | |
cmap <C-l> <c-o>l | |
" move around line | |
nnoremap <C-H> ^ | |
nnoremap <C-L> $ | |
noremap 0 ^ | |
noremap ^ 0 | |
" redo | |
nnoremap U <C-r> | |
" command | |
nnoremap <Leader><Leader> : | |
map <Leader>s :w<CR> | |
map <Leader>q :q<CR> | |
map <Leader>h <C-W>h | |
map <Leader>j <C-W>j | |
map <Leader>k <C-W>k | |
map <Leader>l <C-W>l | |
map <Leader>v :so ~/.config/nvim/init.vim<CR> | |
" window movements | |
nmap <Leader>ww <C-W>w | |
nmap <Leader>wc <C-W>c | |
nmap <Leader>wq <C-W>q | |
" nmap <Leader>wj <C-W>j | |
" nmap <Leader>wk <C-W>k | |
" nmap <Leader>wh <C-W>h | |
" nmap <Leader>wl <C-W>l | |
nmap <Leader>wv :vsplit<CR> | |
nmap <Leader>ws :split<CR> | |
" easymotion | |
" map <space><leader> "leader is space | |
map <space> <Plug>(easymotion-prefix) | |
nmap <space>s <Plug>(easymotion-s) | |
nmap <space><space> <Plug>(easymotion-s2) | |
map <space>/ <Plug>(easymotion-sn) | |
omap <space>/ <Plug>(easymotion-tn) | |
nmap <space><space><space> <Plug>(easymotion-jumptoanywhere) | |
let g:EasyMotion_smartcase = 1 | |
let g:EasyMotion_re_anywhere = '\v' . | |
\ '(<.|^$)' . '|' . | |
\ '(\l)\zs(\u)' . '|' . | |
\ '(_\zs.)' | |
nmap <space>s <Plug>Sneak_s | |
nmap <space>S <Plug>Sneak_S | |
"vscode mapping to reset selection to last commit | |
function! s:gitUndoRangeVisual() | |
normal! gv | |
call VSCodeNotifyRange("git.revertSelectedRanges", line("v"), line("."), 0) | |
endfunction | |
function! s:gitUndoRange() | |
call VSCodeNotifyRange("git.revertSelectedRanges", line("."), line("."), 0) | |
endfunction | |
if exists('g:vscode') | |
" VSCode extension | |
xnoremap <silent> gz :<C-u>call <SID>gitUndoRangeVisual()<CR> | |
nnoremap <silent> gz :<C-u>call <SID>gitUndoRange()<CR> | |
nmap <silent> gl gt | |
nmap <silent> gh gT | |
else | |
" ordinary neovim | |
set hidden | |
set ruler | |
set smarttab | |
set number | |
set visualbell | |
set wildmenu | |
set wildmode=list:longest,full | |
set relativenumber | |
set showmode | |
set laststatus=1 | |
set showmatch | |
set title | |
set mousehide | |
set mouse=vn | |
set scrolloff=3 | |
" set cursorline | |
"colour scheme | |
set termguicolors | |
set background=dark | |
colorscheme monokai_pro | |
" fix c++ number hl | |
hi link LspCxxHlGroupEnumConstant Number | |
hi link LspCxxHlGroupNamespace Function | |
runtime ./coc-config.vim | |
endif | |
" a comment is / not c | |
let g:textobj_comment_no_default_key_mappings = 1 | |
xmap a/ <Plug>(textobj-comment-a) | |
omap a/ <Plug>(textobj-comment-a) | |
xmap i/ <Plug>(textobj-comment-i) | |
omap i/ <Plug>(textobj-comment-i) | |
" asterisk config | |
" star does not move, zstar moves | |
" star a word, use an operator on gn, repeat with dot | |
map * <Plug>(asterisk-z*) | |
map # <Plug>(asterisk-z#) | |
map g* <Plug>(asterisk-gz*) | |
map g# <Plug>(asterisk-gz#) | |
map z* <Plug>(asterisk-*) | |
map gz* <Plug>(asterisk-g*) | |
map z# <Plug>(asterisk-#) | |
map gz# <Plug>(asterisk-g#) | |
" Automatically restore cursor position when possible | |
autocmd BufReadPost * | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment