Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set nocompatible
- filetype on
- filetype off
- set encoding=utf-8
- let &t_Co=256
- set linespace=0
- set lazyredraw
- set ttyfast
- set autoindent " always set autoindenting on
- set copyindent " copy the previous indentation on autoindenting
- set colorcolumn=100
- set formatprg=par\ -w100
- set list
- set relativenumber
- let mapleader = ','
- " Moving lines in VISUAL mode
- vnoremap <C-j> :m '>+1<CR>gv=gv
- vnoremap <C-k> :m '<-2<CR>gv=gv
- noremap <leader>w :w<CR>
- noremap <leader>W :wq<CR>
- noremap <leader>q :q<CR>
- nnoremap <leader>Q :q!<CR>
- noremap <S-l> gt
- noremap <S-h> gT
- " PACKAGE LIST
- " Use this variable inside your local configuration to declare
- " which package you would like to include
- "
- if ! exists('g:vimified_packages')
- let g:vimified_packages = ['general', 'fancy', 'coding', 'indent', 'golang', 'ruby', 'rails', 'rspec', 'javascript', 'colour', 'ctags']
- endif
- " Vundle
- "
- """""""""""""""""""""""""""""""""""""""
- set rtp+=~/.vim/bundle/Vundle.vim
- call vundle#begin()
- Plugin 'gmarik/Vundle.vim'
- Plugin 'tpope/vim-sensible'
- " Package: General
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'general')
- Plugin 'vitalk/vim-simple-todo'
- Plugin 'rking/ag.vim'
- function! AgGrep()
- let command = 'ag -i '.expand('<cword>')
- cexpr system(command)
- cw
- endfunction
- function! AgVisual()
- normal gv"xy
- let command = 'ag -i '.@x
- cexpr system(command)
- cw
- endfunction
- map <leader>a :call AgGrep()<CR>
- vmap <leader>a :call AgVisual()<CR>
- Plugin 'tpope/vim-surround'
- " Add $ as a jQuery surround, _ for Underscore.js
- autocmd FileType javascript let b:surround_36 = "$(\r)"
- \ | let b:surround_95 = "_(\r)"
- Plugin 'kana/vim-textobj-user'
- Plugin 'kana/vim-textobj-line'
- Plugin 'terryma/vim-multiple-cursors'
- Plugin 'scrooloose/nerdtree'
- let NERDTreeHijackNetrw = 0
- let g:NERDTreeWinSize = 25
- let g:NERDTreeChDirMode = 2
- let NERDTreeShowHidden = 1
- map \ :NERDTreeToggle<CR>
- map \| :NERDTreeFind<CR>
- Plugin 'ctrlpvim/ctrlp.vim'
- let g:ctrlp_match_window = 'bottom,order:ttb,min:1,max:10,results:10'
- let g:ctrlp_clear_cache_on_exit = 0
- let g:ctrlp_max_files = 0
- let g:ctrlp_prompt_mappings = {
- \ 'AcceptSelection("e")': ['<c-t>'],
- \ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'],
- \ }
- nnoremap <silent> <leader>f :CtrlP<CR>
- noremap <leader>b :CtrlPBuffer<CR>
- Plugin 'FelikZ/ctrlp-py-matcher'
- let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }
- if executable('ag')
- " Use Ag over Grep
- set grepprg=ag\ --nogroup\ --nocolor
- let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --ignore ".git" --ignore ".DS_Store" --hidden -g ""'
- else
- nnoremap <silent> <leader>F :ClearCtrlPCache<CR>\|:CtrlP<CR>
- endif
- " File Renaming (credit: garybernhardt)
- function! RenameFile()
- let old_name = expand('%')
- let new_name = input('New file name: ', expand('%'), 'file')
- if new_name != '' && new_name != old_name
- exec ':saveas ' . new_name
- exec ':silent !rm ' . old_name
- redraw!
- endif
- endfunction
- map <leader>n :call RenameFile()<cr>
- " Smart Tab completion (credit: garybernhardt)
- function! InsertTabWrapper()
- let col = col('.') - 1
- if !col || getline('.')[col - 1] !~ '\k'
- return "\<tab>"
- else
- return "\<c-p>"
- endif
- endfunction
- " inoremap <tab> <c-r>=InsertTabWrapper()<cr>
- inoremap <s-tab> <c-n>
- function! SetupWrapping()
- set wrap
- set wrapmargin=2
- set textwidth=100
- endfunction
- au BufRead,BufNewFile *.txt call SetupWrapping()
- au BufRead,BufNewFile *.md call SetupWrapping()
- endif
- " Package: Fancy
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'fancy')
- Plugin 'vim-airline/vim-airline'
- Plugin 'vim-airline/vim-airline-themes'
- Plugin 'enricobacis/vim-airline-clock'
- let g:airline_theme='one'
- let g:airline_powerline_fonts=1
- let g:airline#extensions#tabline#enabled = 1
- let g:airline#extensions#tabline#show_buffers = 0
- let g:airline#extensions#tabline#show_splits = 0
- let g:airline#extensions#tabline#show_tabs = 1
- let g:airline#extensions#tabline#show_tab_nr = 0
- let g:airline#extensions#tabline#show_tab_type = 0
- let g:airline#extensions#tabline#close_symbol = '×'
- let g:airline#extensions#tabline#show_close_button = 0
- endif
- " Package: Coding
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'coding')
- Plugin 'sbdchd/neoformat'
- Plugin 'tpope/vim-fugitive'
- map <leader>g :Gblame<CR>
- Plugin 'tpope/vim-commentary'
- xmap <leader>/ <Plug>Commentary
- nmap <leader>/ <Plug>CommentaryLine
- Plugin 'AndrewRadev/splitjoin.vim'
- Plugin 'tpope/vim-endwise'
- " strip trailing whitespace on save
- function! StripTrailingWhitespace()
- let save_cursor = getpos('.')
- %s/\s\+$//e
- call setpos('.', save_cursor)
- endfunction
- autocmd BufWritePre *.rb,*.yml,*.js,*jsx,*.css,*.less,*.sass,*.scss,*.html,*.xml,*.erb,*.haml,*.coffee call StripTrailingWhitespace()
- Plugin 'w0rp/ale'
- Plugin 'MarcWeber/vim-addon-mw-utils'
- Plugin 'tomtom/tlib_vim'
- Plugin 'SirVer/ultisnips'
- Plugin 'argtextobj.vim'
- Plugin 'terryma/vim-expand-region'
- Plugin 'ervandew/supertab'
- Plugin 'Valloric/YouCompleteMe'
- " make YCM compatible with UltiSnips (using supertab)
- let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
- let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
- let g:SuperTabDefaultCompletionType = '<C-n>'
- " better key bindings for UltiSnipsExpandTrigger
- let g:UltiSnipsExpandTrigger = "<tab>"
- let g:UltiSnipsJumpForwardTrigger = "<tab>"
- let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
- endif
- " Package: Indent
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'indent')
- Plugin 'michaeljsmith/vim-indent-object'
- let g:indentobject_meaningful_indentation = ['haml', 'sass', 'yaml', 'markdown']
- Plugin 'Yggdroot/indentLine'
- let g:indentLine_fileType = ['yaml', 'coffee']
- endif
- " Package: Go
- "
- if count(g:vimified_packages, 'golang')
- Plugin 'fatih/vim-go'
- let g:go_fmt_command = "goimports"
- let g:go_highlight_types = 0
- let g:go_highlight_functions = 0
- let g:go_highlight_methods = 1
- let g:go_metalinter_autosave = 1
- let g:go_auto_type_info = 1
- let g:go_auto_sameids = 0
- 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, 'tab drop')
- noremap <C-b> :GoRun<CR>
- endif
- " Package: Ruby
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'ruby') || count(g:vimified_packages, 'rails')
- Plugin 'vim-ruby/vim-ruby'
- Plugin 'nelstrom/vim-textobj-rubyblock'
- let g:textobj_rubysymbol_no_default_key_mappings = 1
- xmap as <Plug>(textobj-rubysymbol-a)
- omap as <Plug>(textobj-rubysymbol-a)
- xmap is <Plug>(textobj-rubysymbol-i)
- omap is <Plug>(textobj-rubysymbol-i)
- Plugin 'bootleq/vim-textobj-rubysymbol'
- " set question mark to be part of a VIM word. in Ruby it is!
- autocmd FileType ruby set iskeyword=@,48-57,_,?,!,192-255
- set wildignore+=*.gem
- " ysiw# Wrap the token under the cursor in #{}
- " v...s# Wrap the selection in #{}
- let g:surround_113 = "#{\r}" " v
- let g:surround_35 = "#{\r}" " #
- " ,# Surround a word with #{ruby interpolation}
- map ,# ysiw#
- vmap ,# c#{<C-R>"}<ESC>
- endif
- " Package: Rails
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'rails')
- Plugin 'tpope/vim-rails'
- let g:rails_ctags_arguments='--exclude=".git" --exclude="log" --exclude="doc" --exclude="spec/javascripts/helpers"'
- Plugin 'othree/html5.vim'
- Plugin 'plasticboy/vim-markdown'
- let g:vim_markdown_folding_disabled=1
- autocmd FileType scss set iskeyword=@,48-57,_,-,?,!,192-255
- set wildignore+=*/public/assets/**
- set wildignore+=*/vendor/rails/**
- set wildignore+=*/vendor/cache/**
- " wrap selection in erb tags
- let g:surround_45 = "<% \r %>" " -
- let g:surround_61 = "<%= \r %>" " =
- endif
- " Package: Rspec
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'rspec')
- Plugin 'keith/rspec.vim'
- endif
- " Package: Javascript
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'javascript')
- Plugin 'kchmck/vim-coffee-script'
- Plugin 'mustache/vim-mustache-handlebars'
- Plugin 'pangloss/vim-javascript'
- Plugin 'mxw/vim-jsx'
- Plugin 'kana/vim-textobj-function'
- Plugin 'thinca/vim-textobj-function-javascript'
- Plugin 'mattn/emmet-vim'
- let g:user_emmet_settings = {
- \ 'javascript.jsx' : {
- \ 'extends' : 'jsx',
- \ },
- \}
- au BufNewFile,BufRead *.json set filetype=javascript
- endif
- " Package: Ctags
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'ctags')
- Plugin 'folke/AutoTag'
- let g:autotagExcludeSuffixes="tml.xml.text.txt.vim"
- map <leader>rt :!ctags --extra=+f --exclude=.git --exclude=log --exclude=doc -R *<CR><CR>
- map <C-\> :tnext<CR>
- endif
- " Package: Colour
- "
- """""""""""""""""""""""""""""""""""""""
- if count(g:vimified_packages, 'colour') || count(g:vimified_packages, 'color')
- Plugin 'rakr/vim-one', {'rtp': 'vim/'}
- :hi TabLineFill term=bold cterm=bold ctermbg=237
- endif
- call vundle#end()
- filetype plugin indent on
- syntax on
- if count(g:vimified_packages, 'coding')
- let g:expand_region_text_objects = {
- \ 'iw' :0,
- \ 'i"' :0,
- \ 'i''' :0,
- \ 'i]' :1,
- \ 'ia' :0,
- \ 'aa' :0,
- \ 'ib' :1,
- \ 'iB' :1,
- \ 'il' :0
- \ }
- if count(g:vimified_packages, 'ruby') || count(g:vimified_packages, 'rails')
- call expand_region#custom_text_objects('ruby', {
- \ 'as' :1,
- \ 'ir' :1,
- \ 'ar' :1
- \ })
- call expand_region#custom_text_objects('html', {
- \ 'it' :1
- \ })
- endif
- if count(g:vimified_packages, 'javascript')
- call expand_region#custom_text_objects('javascript', {
- \ 'if' :1,
- \ 'af' :1
- \ })
- call expand_region#custom_text_objects('coffee', {
- \ 'ii' :1
- \ })
- endif
- endif
- if count(g:vimified_packages, 'colour') || count(g:vimified_packages, 'color')
- colorscheme one
- set background=light
- endif
- "
- " Options
- "
- """""""""""""""""""""""""""""""""""""""
- set notimeout " no command timeout
- set expandtab " use soft tabs
- set tabstop=2
- set shiftwidth=2 " width of auto-indent
- set softtabstop=2
- set nowrap " no wrapping
- set textwidth=0
- set number " line numbers
- set numberwidth=4
- autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=2 shiftwidth=2
- " completion sources: (current file, loaded buffers, unloaded buffers, tags)
- set complete=.,b,u,]
- set wildmode=longest,list:longest
- set wildignore+=*vim/backups*
- set wildignore+=*DS_Store*
- set wildignore+=tags
- set wildignore+=*/tmp/**
- set wildignore+=*/log/**
- set wildignore+=.git,*.rbc,*.class,.svn,*.png,*.jpg,*.gif
- set list " show whitespace
- if has('gui_running')
- set listchars=trail:·
- else
- set listchars=trail:~
- endif
- set showtabline=2 " always show tab bar
- set showmatch " show matching brackets
- set hidden " allow hidden, unsaved buffers
- set splitbelow " add new window towards right
- set splitright " add new window towards bottom
- set scrolloff=3 " scroll when the cursor is 3 lines from bottom
- set sidescroll=1
- set sidescrolloff=5
- set cursorline " highlight current line
- " Turn folding off for real, hopefully
- set foldmethod=manual
- set nofoldenable
- " make searches case-sensitive only if they contain upper-case characters
- set smartcase
- " store temporary files in a central spot
- set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
- set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
- " switch syntax highlighting on, when the terminal has colors
- if &t_Co > 2 || has('gui_running')
- set hlsearch
- endif
- "
- " Keybindings
- "
- """""""""""""""""""""""""""""""""""""""
- " clear the search buffer when hitting space
- :nnoremap <space> :nohlsearch<cr>
- " sometimes I hold the shift too long ... just allow it
- cabbrev W w
- cabbrev Q q
- cabbrev Tabe tabe
- " split screen
- :noremap <leader>v :vsp<CR>
- :noremap <leader>h :split<CR>
- " toggle fullscreen
- :noremap tt :tab split<CR>
- :noremap ty :tabc <CR>
- " opens an edit command with the path of the currently edited file filled in
- map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
- " opens a tab edit command with the path of the currently edited file filled in
- " map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
- " make Y consistent with D and C
- map Y y$
- map <silent> <leader>y :<C-u>silent '<,'>w !pbcopy<CR>
- " copy current file path to system pasteboard
- map <leader>C :let @* = expand("%")<CR>:echo "Copied: ".expand("%")<CR>
- " reload .vimrc
- map <leader>rv :source ~/.vimrc<CR>
- " open quickfix list item in new tab
- nnoremap <buffer> <CR> :tabnew\|cc <C-r>=line(".")<CR><CR>
- if has('gui_macvim')
- " Fullscreen takes up entire screen
- set fuoptions=maxhorz,maxvert
- map <D-CR> :set invfu<cr>
- set guifont=Source\ Code\ Pro\ Medium:h14
- endif
- function! OpenTodo()
- let todoFile = getcwd() . "/todo.txt"
- if filereadable(todoFile)
- tab drop todo.txt | tabm 0
- endif
- endfunction
- nnoremap <leader>t :call OpenTodo()<CR>
- set listchars=tab:\|\
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement