Skip to content

Instantly share code, notes, and snippets.

@ashwin95r
Created July 19, 2016 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashwin95r/c12807427553e72d19c081bd7eabb804 to your computer and use it in GitHub Desktop.
Save ashwin95r/c12807427553e72d19c081bd7eabb804 to your computer and use it in GitHub Desktop.
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'fatih/vim-go'
Plugin 'tpope/vim-fugitive'
Plugin 'fatih/molokai'
" Track Snippet engine.
Plugin 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" Tagbar
Plugin 'majutsushi/tagbar'
" Surround
Plugin 'tpope/vim-surround'
Plugin 'gerw/vim-HiLinkTrace'
" Tabular
Plugin 'godlygeek/tabular'
" Abolish for better abbreviations.
Plugin 'tpope/vim-abolish'
" For Ledger accounting.
Plugin 'ledger/vim-ledger'
" Deal with trailing wihtespace
Plugin 'ntpeters/vim-better-whitespace'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
set tabstop=2
set shiftwidth=2
set autoindent
set ignorecase
set smartcase
set ruler
syntax on
set backspace=indent,eol,start
" set hlsearch
" Set numbering
set numberwidth=4
set relativenumber
set number
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
" Neocomplete =======================
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Avoid preview window for autocomplete
set completeopt-=preview
" Molokai ============================
let g:molokai_original = 1
let g:rehash256 = 1
" UltiSnips ============================
let g:UltiSnipsExpandTrigger="<c-h>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
" ====================================
" Go stuff ===========================
" See all the mappings with :he go-mappings
let mapleader=";"
au FileType go nmap <Leader>r <Plug>(go-run)
au FileType go nmap <Leader>b <Plug>(go-build)
au FileType go nmap <Leader>t <Plug>(go-test)
" au FileType go nmap <Leader>c <Plug>(go-coverage)
au FileType go nmap <Leader>g <Plug>(go-doc-browser)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>e <Plug>(go-rename)
au FileType go nmap <Leader>a <Plug>(go-alternate-edit)
" Toggle spell checker
nmap <silent> <Leader>s :set spell!<CR>
" Set color column
nmap <silent> <Leader>8 :set colorcolumn=80<CR>
nmap <silent> <Leader>0 :set colorcolumn=100<CR>
nmap <silent> <Leader>2 :set colorcolumn=120<CR>
" Show invisible characters
nmap <silent> <Leader>l :set list!<CR>
" Highlighting
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "goimports"
" Go stuff ends
" ============================================
" Open file at a position where it was last left.
au BufWinLeave *.go mkview
au BufWinEnter *.go silent loadview
" Avoid using arrow keys for navigation. Learn the vim way.
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
" For Mutt
" au BufRead /tmp/mutt-* set tw=72
" Not using the above, so we can avoid the whole line break issue.
" Set path to use :find
set path=$GOPATH/src/github.com/dgraph-io
set path+=$PWD/**
" let &colorcolumn="80,".join(range(120,999),",")
highlight colorcolumn ctermbg=Gray ctermfg=0
"match ErrorMsg '\%>100v.\+'
"highlight ErrorMsg ctermfg=DarkGrey ctermbg=LightGrey
set t_Co=256
set laststatus=2
set encoding=utf-8
let g:airline#extensions#tabline#enabled = 1
" Spellings are in after/plugin/abolish.vim
" http://vim.wikia.com/wiki/Review_code_effectively_using_quickfix
function! SavePosition()
let g:dir_name=expand("%:p:h:t")
let g:file_name=expand("%:t")
let g:line_number=line(".")
let g:line=getline(".")
let g:line=substitute(g:line, '^\s\+', '', 'g')
let g:reviewer="mrjn"
endfunction
function! InsertComment()
execute "normal i". "[" . g:reviewer . "] " . g:dir_name . "/" . g:file_name . ":" . g:line_number . ": " . g:line . " → "
startinsert
endfunction
nmap <Leader>o :call SavePosition()<CR>
nmap <Leader>c :call InsertComment()<CR>
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
map <Leader>je :e %%
map <Leader>js :sp %%
map <Leader>jv :vsp %%
" Cycle through buffers.
function! SwitchToNextBuffer(incr)
let help_buffer = (&filetype == 'help')
let current = bufnr("%")
let last = bufnr("$")
let new = current + a:incr
while 1
if new != 0 && bufexists(new) && ((getbufvar(new, "&filetype") == 'help') == help_buffer)
execute ":buffer ".new
break
else
let new = new + a:incr
if new < 1
let new = last
elseif new > last
let new = 1
endif
if new == current
break
endif
endif
endwhile
endfunction
nnoremap <silent> <C-n> :call SwitchToNextBuffer(1)<CR>
nnoremap <silent> <C-p> :call SwitchToNextBuffer(-1)<CR>
nmap <Leader>W :set wrap linebreak nolist<CR>
" Source the vimrc file after saving it
nmap <Leader>v :e $MYVIMRC<CR>
" Toggle paste
set pastetoggle=<Leader>p
" Quickly update file.
noremap <Leader>w :update<CR>
noremap <Leader>q :wq<CR>
" Ledger config
" let g:ledger_extra_options = '--pedantic --explicit --check-payees'
let g:ledger_fold_blanks = 1
let g:ledger_maxwidth = 100
let g:ledger_fillstring = ' -'
au FileType ledger vnoremap <silent><buffer> <Leader>a :LedgerAlign<CR>
au FileType ledger noremap <silent><buffer> e :call ledger#entry()<CR>
au FileType ledger noremap <silent><buffer> t :call ledger#transaction_state_toggle(line('.'), ' *?!')<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment