Last active
October 17, 2019 11:20
-
-
Save netmute/1640807 to your computer and use it in GitHub Desktop.
init.vim
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
" PLEASE NOTE: I'm assuming nvim defaults in this configuration. | |
" Regular vimmers might need to tweak here and there. | |
" Add autogenerated tags file to the lookup path. | |
set tags+=.git/tags | |
" Add fzf plugin. | |
set rtp+=/usr/local/opt/fzf | |
" Use a source for FZF that respects '.gitignore'. | |
let $FZF_DEFAULT_COMMAND = 'rg --files' | |
" Hide the statusline. | |
set laststatus=0 | |
" Ruler format is space(%=), current line(%l), total lines(%L). | |
set rulerformat=%=%l/%L | |
" Keep current file only in RAM, no swap. | |
set noswapfile | |
" Always keep the current line centered on screen. | |
set scrolloff=100 | |
" Disable incremental search. | |
set noincsearch | |
" Case insensitive on lowercase, case sensitive on mixed case. | |
set ignorecase | |
set smartcase | |
" Set width of tabs to 2 spaces. | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
" Always use spaces instead of tabs. | |
set expandtab | |
" Enable mouse control for everything except visual mode. | |
set mouse=nicr | |
" Keep buffers open when leaving them. (Allows changing buffers without saving | |
" first.) | |
set hidden | |
" Change mapleader to space. | |
let mapleader="\<Space>" | |
" Leader-n to disable search match hilighting. | |
nmap <silent> <Leader>n :noh<CR> | |
" Leader-v edits configuration file. | |
nmap <silent> <Leader>v :e $MYVIMRC<CR> | |
" Leader-t starts fzf as fuzzy file selector. | |
nmap <silent> <Leader>t :FZF<CR> | |
" Leader-s searches project wide for word under cursor. | |
nmap <silent> <Leader>s :silent GrepperRg <C-R><C-W><CR> | |
" Define Rg as alias for GrepperRg | |
if !exists(":Rg") | |
command -nargs=+ Rg GrepperRg <args> | |
endif | |
" Leader-c to duplicate current line and keep cursor position. | |
nmap <silent> <Leader>c mmyyP`m | |
" Leader-z to duplicate current line as comment. | |
nmap <silent> <Leader>z mmyyPgcc`m | |
" Only show tabline if there are more than 2 buffers. | |
let g:buftabline_show = 1 | |
" Disable whitespace markers for vlang. | |
let g:v_highlight_trailing_whitespace_error = 0 | |
" Disable highlighting of vlang function calls. | |
let g:v_highlight_function_calls = 0 | |
" Highlight matches in grepper. | |
let g:grepper = {} | |
let g:grepper.highlight = 1 | |
" Auto expand space inside pairs. | |
let delimitMate_expand_space = 1 | |
" Auto expand <CR> inside pairs. | |
let delimitMate_expand_cr = 2 | |
" Try to balance all pairs on the current line. | |
let delimitMate_balance_matchpairs = 1 | |
" Switch to tabs using leader + number. | |
nmap <Leader>1 <Plug>BufTabLine.Go(1) | |
nmap <Leader>2 <Plug>BufTabLine.Go(2) | |
nmap <Leader>3 <Plug>BufTabLine.Go(3) | |
nmap <Leader>4 <Plug>BufTabLine.Go(4) | |
nmap <Leader>5 <Plug>BufTabLine.Go(5) | |
nmap <Leader>6 <Plug>BufTabLine.Go(6) | |
nmap <Leader>7 <Plug>BufTabLine.Go(7) | |
nmap <Leader>8 <Plug>BufTabLine.Go(8) | |
nmap <Leader>9 <Plug>BufTabLine.Go(9) | |
nmap <Leader>0 <Plug>BufTabLine.Go(10) | |
" Workaround for delimitMate and YCM compatiblity. | |
imap <silent> <BS> <C-R>=YcmOnDeleteChar()<CR><Plug>delimitMateBS | |
function! YcmOnDeleteChar() | |
if pumvisible() | |
return "\<C-y>" | |
endif | |
return "" | |
endfunction | |
" Function to load minpac and register the information of plugins. | |
function! PackInit() abort | |
packadd minpac | |
call minpac#init() | |
call minpac#add('k-takata/minpac', {'type': 'opt'}) | |
call minpac#add('zxqfl/tabnine-vim', {'type': 'opt'}) | |
call minpac#add('mhinz/vim-grepper') | |
call minpac#add('tpope/vim-surround') | |
call minpac#add('Raimondi/delimitMate') | |
call minpac#add('tpope/vim-commentary') | |
call minpac#add('ap/vim-buftabline') | |
" call minpac#add('ollykel/v-vim') | |
endfunction | |
" Can be used to update plugins and show the results from a shell script. | |
" Use like this: | |
" vim '+call PackUpdate()' && cat .vim.update | xargs | |
function! PackUpdate() abort | |
call PackInit() | |
call minpac#update('', {'do': 'redir! > $HOME/.vim.update | call minpac#status() | print | redir END | qa'}) | |
endfunction | |
" Install/update plugins. | |
if !exists(":PackInstall") | |
command PackInstall so % | call PackInit() | call minpac#update('') | |
endif | |
" Install/update plugins. | |
if !exists(":PackClean") | |
command PackClean so % | call PackInit() | call minpac#clean('') | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment