Skip to content

Instantly share code, notes, and snippets.

@compressed
Last active April 1, 2017 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save compressed/75a10f0be388ee04b7a9 to your computer and use it in GitHub Desktop.
Save compressed/75a10f0be388ee04b7a9 to your computer and use it in GitHub Desktop.
set nocompatible " be iMproved, required
set hidden
filetype off " required
" line numbers
set number
set relativenumber
set backspace=2 "allow deleting any chars in insert mode
set laststatus=2
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set laststatus=2 " Always display the status line
" Numbers
set number
set numberwidth=5
set linebreak " ensure words are wrapped fully, not mid-word
" Softtabs, 2 spaces
set tabstop=4
set shiftwidth=4
set expandtab
set spell
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1 "this is just what i use"
set printfont=hack:h09
set printoptions=left:5pc
" Set the leader key to ,
let mapleader = ","
" Paste and keep pasting same thing, don't take what was removed
vnoremap <Leader>p "_dP
" Tab through open buffers
noremap <Leader>b :b<space>
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif
call plug#begin('~/.vim/plugged')
Plug 'tomtom/tcomment_vim'
Plug 'aehlke/vim-rename3'
" Plug 'nelstrom/vim-markdown-folding'
Plug 'Konfekt/FastFold'
Plug 'ciaranm/detectindent'
Plug 'tomasr/molokai'
Plug 'godlygeek/tabular'
Plug 'tpope/vim-markdown'
" Markdown
let g:markdown_fenced_languages = ['coffee', 'css', 'erb=eruby', 'javascript', 'js=javascript', 'json=javascript', 'ruby', 'sass', 'xml', 'julia', 'rust']
Plug 'tommcdo/vim-exchange'
Plug 'rust-lang/rust.vim'
let g:rustfmt_autosave = 1
Plug 'docker/docker' , {'rtp': '/contrib/syntax/vim/'}
Plug 'bling/vim-airline'
let g:airline_powerline_fonts = 1 " airline use powerline fonts
Plug 'airblade/vim-gitgutter'
Plug 'terryma/vim-multiple-cursors'
Plug 'fatih/vim-go'
Plug 'xolox/vim-misc'
Plug 'tpope/vim-fugitive'
Plug 'JuliaLang/julia-vim'
Plug 'tpope/vim-vinegar'
Plug 'cespare/vim-toml'
Plug 'cstrahan/vim-capnp'
Plug 'kchmck/vim-coffee-script'
Plug 'chrisbra/csv.vim'
Plug 'cohama/lexima.vim'
Plug 'tpope/vim-surround'
Plug 'Shougo/deoplete.nvim'
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_smart_case = 1
let g:deoplete#omni_patterns = {}
let g:deoplete#omni_patterns.rust = '[(\.)(::)]'
function! BuildComposer(info)
if a:info.status != 'unchanged' || a:info.force
!cargo build --release
UpdateRemotePlugins
endif
endfunction
Plug 'phildawes/racer', { 'do': function('BuildComposer') }
Plug 'racer-rust/vim-racer'
let g:racer_insert_paren = 1
let g:racer_cmd = $HOME . "/.vim/plugged/racer/target/release/racer"
let $RUST_SRC_PATH = $HOME . "/.multirust/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src"
let g:racer_experimental_completer = 1
Plug 'ervandew/supertab'
let g:SuperTabDefaultCompletionType = "<c-n>"
" markdown-composer
" Plug 'euclio/vim-markdown-composer', { 'do': function('BuildComposer') }
Plug 'SirVer/ultisnips'
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<Tab>"
let g:UltiSnipsJumpForwardTrigger="<Tab>"
let g:UltiSnipsJumpBackwardTrigger="<S-Tab>"
" Snippets are separated from the engine. Add this if you want them:
Plug 'honza/vim-snippets'
Plug 'ap/vim-css-color'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
nnoremap <silent> <C-p> :Files <CR>
Plug 'junegunn/fzf.vim'
Plug 'benekastah/neomake'
" rusty tags settings
au FileType rust setl tags=rusty-tags.vi;/,~/rust/rusty-tags.vi
let g:neomake_rust_rustytags_maker = {
\ 'exe': 'rusty-tags',
\ 'args': ['vi'],
\ 'append_file': 0,
\ }
" cargo check
let g:neomake_rust_cargocheck_maker = {
\ 'exe': 'cargo',
\ 'args': ['check'],
\ 'errorformat':
\ '%-Z%f:%l,' .
\ '%+C %s,' .
\ '%A%f:%l:%c: %*\d:%*\d\ %t%*[^:]: %m,',
\ 'append_file': 0,
\ }
" rustc check
let g:neomake_rust_rustc2_maker = {
\ 'exe': 'rustc',
\ 'args': ['-Zparse-only'],
\ 'errorformat':
\ '%-Z%f:%l,' .
\ '%+C %s,' .
\ '%A%f:%l:%c: %*\d:%*\d\ %t%*[^:]: %m,'
\ }
" let g:neomake_serialize = 1
" let g:neomake_serialize_abort_on_error = 1
let g:neomake_rust_enabled_makers = ['rustytags', 'cargocheck']
let g:neomake_open_list = 2
" let g:neomake_logfile='/Users/chris/.vim/neomake.log'
function! ToggleNeoMake()
if !exists('#NeoMakeGroup#BufWritePost')
augroup NeoMakeGroup
autocmd!
autocmd BufWritePost *.rs* Neomake
" autocmd BufWritePost *.rs Neomake! cargocheck
augroup END
else
augroup NeoMakeGroup
autocmd!
augroup END
endif
endfunction
map <Leader>nm :call ToggleNeoMake()<CR>
let g:neomake_javascript_enabled_makers = ['standard']
autocmd! BufWritePost *.js Neomake
" call ToggleNeoMake()
Plug 'FuzzOli87/vim-js-indent'
" Add plugins to &runtimepath
call plug#end()
" ensure <CR> works when popup is visible
call lexima#init()
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : lexima#expand('<LT>CR>', 'i')
filetype plugin indent on " required
colorscheme molokai
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
syntax on
endif
" paste
if &term =~ "xterm.*"
let &t_ti = &t_ti . "\e[?2004h"
let &t_te = "\e[?2004l" . &t_te
function XTermPasteBegin(ret)
set pastetoggle=<Esc>[201~
set paste
return a:ret
endfunction
map <expr> <Esc>[200~ XTermPasteBegin("i")
imap <expr> <Esc>[200~ XTermPasteBegin("")
cmap <Esc>[200~ <nop>
cmap <Esc>[201~ <nop>
endif
" Share OS clipboard
set clipboard=unnamed
" rm trailing whitespace
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
set t_ut= " ensure background color shows correctly under tmux
set ttyfast " Smooth redraws
set ttimeoutlen=10 " Faster escape sequences
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=500
augroup END
set updatetime=500 " Update things faster (e.g. GitGutter)
set noshowmode " Leave --insert-- to AirLines
set noerrorbells " Sound off
" Indentation
set smartindent
set shiftwidth=2 softtabstop=2 tabstop=2 expandtab
set cursorline " Highlight active line
" Do not search here
set wildignore=*/node_modules/*
set nowritebackup " vim was saving file twice, causes problems for file watching
function! s:DiffWithSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
com! DiffSaved call s:DiffWithSaved()
" highlight after 100
let &colorcolumn=join(range(101,999),",")
autocmd FileType julia setlocal expandtab softtabstop=4 shiftwidth=4 tabstop=4
" tell it to use an undo file
set undofile
" set a directory to store the undo history
set undodir=~/.vim/vimundo/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment