Skip to content

Instantly share code, notes, and snippets.

@dariodip
Last active September 12, 2019 12:18
Show Gist options
  • Save dariodip/dfe0a6a17dcd899448ba8a4782957f53 to your computer and use it in GitHub Desktop.
Save dariodip/dfe0a6a17dcd899448ba8a4782957f53 to your computer and use it in GitHub Desktop.
My simple vimrc
""""""""""""""""
" Vundle plugins
""""""""""""""""
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' "Let's Vundle manage Vundle
Plugin 'wakatime/vim-wakatime' "Wakatime for time tracking
Plugin 'fatih/vim-go'
Plugin 'ryanoasis/vim-devicons'
Plugin 'tiagofumo/vim-nerdtree-syntax-highlight'
Plugin 'itchyny/lightline.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/nerdcommenter'
Plugin 'Shougo/vimproc.vim'
Plugin 'Shougo/deoplete.nvim'
Plugin 'vim-syntastic/syntastic'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
Plugin 'elixir-editors/vim-elixir'
Plugin 'mhinz/vim-mix-format'
Plugin 'nathanaelkane/vim-indent-guides'
call vundle#end()
filetype plugin indent on
"""""""""""""""""
" Basic Settings
"""""""""""""""""
set nocompatible
filetype off
filetype plugin indent on
set foldmethod=indent
set foldlevel=99
set autowrite
set autoindent
set smartindent
set number
set encoding=UTF-8
set autoread
set incsearch
set hlsearch
set showcmd
set nobackup
set pumheight=10
set guifont=DroidSansMono_Nerd_Font:h11
" This enables us to undo files even if you exit Vim.
if has('persistent_undo')
set undofile
set undodir=~/.config/vim/tmp/undo//
set laststatus=2
endif
if !has('gui_running')
set t_Co=256
endif
let g:indent_guides_enable_on_vim_startup = 1
"""""""""""
" Color Scheme
"""""""""""
syntax enable
set background=light
let g:solarized_termcolors=256
colorscheme solarized
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4
""""""""""""""""""""""
" Mappings
""""""""""""""""""""""
"" Autoclosing {}
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
"" Autoclosing []
inoremap [ []<Left>
inoremap [<CR> [<CR>]<Esc>O
inoremap [[ [
inoremap [] []
"" Autoclosing ()
inoremap ( ()<Left>
inoremap (<CR> (<CR>)<Esc>O
inoremap (( (
inoremap () ()
inoremap ) )<Left>
"" Buffers
map <C-j> :bprev<CR>
map <C-k> :bnext<CR>
map <C-S-d> :vsp
map <C-d> :sp
map <C-q> :bd<CR>
"" vim-go
map <C-n> :cnext<CR> " for vim-go error highlight
map <C-m> :cprevious<CR> " for vim-go error highlight
"" utils
map <leader>m :NERDTreeToggle<CR>
nnoremap <leader>a :cclose<CR>
if has("gui_running")
inoremap <C-Space> <C-n>
else " no gui
if has("unix")
inoremap <Nul> <C-n>
endif
endif
""""""""""""""""""""
" Settings for vim-go
""""""""""""""""""""
let g:go_fmt_command = "goimports"
let g:go_autodetect_gopath = 1
let g:go_list_type = "quickfix"
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_generate_tags = 1
augroup go
autocmd!
" Show by default 4 spaces for a tab
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
" :GoBuild and :GoTestCompile
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
" :GoTest
autocmd FileType go nmap <leader>t <Plug>(go-test)
" :GoRun
autocmd FileType go nmap <leader>r <Plug>(go-run)
" :GoDoc
autocmd FileType go nmap <Leader>d <Plug>(go-doc)
" :GoCoverageToggle
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle)
" :GoInfo
autocmd FileType go nmap <Leader>i <Plug>(go-info)
" :GoMetaLinter
autocmd FileType go nmap <Leader>l <Plug>(go-metalinter)
" :GoDef but opens in a vertical split
autocmd FileType go nmap <Leader>v <Plug>(go-def-vertical)
" :GoDef but opens in a horizontal split
autocmd FileType go nmap <Leader>s <Plug>(go-def-split)
" :GoAlternate commands :A, :AV, :AS and :AT
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe')
augroup END
" build_go_files is a custom function that builds or compiles the test file.
" It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
""""""""""""""""
""Clojure """"""
""""""""""""""""
augroup clojure_settings " {
autocmd!
autocmd BufNewFile,BufRead *.clj inoremap ( ()<Left>
augroup END " }
"""""""""""""""
" vim-latex "
"""""""""""""""
filetype plugin on
set shellslash
filetype indent on
let g:text_flavor='latex'
map <C-Space> <C-n>
"""""""""""""""
"""""""""""""""
" Haskell """"
"""""""""""""""
let g:haskell_enable_quantification = 1
let g:haskell_enable_recursivedo = 1
let g:haskell_enable_arrowsyntax = 1
let g:haskell_enable_pattern_synonyms = 1
let g:haskell_enable_typeroles = 1
let g:haskell_enable_static_pointers = 1
let g:haskell_backpack = 1
" replaces tabs with spaces in haskell files
augroup haskell_settings " {
autocmd!
autocmd BufNewFile,BufRead *.hs set tabstop=4 shiftwidth=4 expandtab
autocmd BufNewFile,BufRead *.hs set list
autocmd BufNewFile,BufRead *.hs set listchars=tab:→\ ,eol:↲,nbsp:␣,trail:•,extends:⟩,precedes:⟨
autocmd BufNewFile,BufRead *.hs hi IndentGuidesEven ctermbg=white
autocmd BufNewFile,BufRead *.hs hi IndentGuidesOdd ctermbg=lightgrey
augroup END " }
"""""""""""""""
" Python """""
"""""""""""""""
let ropevim_vim_completion=1
let ropevim_extended_complete=1
"""""""""""""""
" Syntastic """
"""""""""""""""
map <Leader>s :SyntasticToggleMode<CR>
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment