Skip to content

Instantly share code, notes, and snippets.

@jmarceli
Created November 23, 2017 15:41
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 jmarceli/a379d89f07734e0c46a544c61177e672 to your computer and use it in GitHub Desktop.
Save jmarceli/a379d89f07734e0c46a544c61177e672 to your computer and use it in GitHub Desktop.
My .vimrc
" RELOAD WITHOUT closing vim
" :so ~/.vimrc
"
set nocompatible
"""""""""""""""""""
" PLUGINS
"""""""""""""""""""
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" snippets
Plug 'sirver/ultisnips'
Plug 'honza/vim-snippets'
Plug 'rstacruz/vim-ultisnips-css'
" autocomplete
Plug 'Valloric/YouCompleteMe'
" general
Plug 'dbakker/vim-projectroot'
" comments and files tree
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'scrooloose/nerdcommenter'
" nice status line
"Plug 'bling/vim-airline'
" general improvements
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-unimpaired'
" tags list (like methods and variables)
Plug 'majutsushi/tagbar'
" live syntax check
"Plug 'scrooloose/syntastic'
" faster search than ACK
Plug 'rking/ag.vim'
" easier replace in multiple files
Plug 'dkprice/vim-easygrep'
" tags maching (opening with closing)
Plug 'tmhedberg/matchit'
" HTML5 support
Plug 'othree/html5.vim'
" SMARTY
Plug 'vim-scripts/smarty-syntax'
" JAVASCRIPT
Plug 'othree/yajs.vim'
Plug 'othree/es.next.syntax.vim'
"Plug 'isRuslan/vim-es6.vim'
Plug 'mxw/vim-jsx'
Plug 'pangloss/vim-javascript' " adds indentation support for .jsx
Plug 'leafgarland/typescript-vim' " typescript support
" Coffeescript support
"Plug 'kchmck/vim-coffee-script'
" CJSX support (reactJS + Coffeescript)
"Plug 'mtscout6/vim-cjsx'
" Markdown support
Plug 'tpope/vim-markdown'
" CSS
Plug 'stephenway/postcss.vim'
"Plug 'groenewege/vim-less'
" Blade
Plug 'jwalton512/vim-blade'
" NODEJS
Plug 'Slava/vim-spacebars'
" RAILS
" general rails cmds
Plug 'tpope/vim-rails'
" rails coding style check
Plug 'ngmy/vim-rubocop'
" haml, sass, scss
"Plug 'tpope/vim-haml'
" END
" PHP
" Twig highlighting
Plug 'evidens/vim-twig'
" PHP debug
Plug 'joonty/vdebug'
" END
" COLORS
" original railscasts colorscheme (too dark IMO)
Plug 'jpo/vim-railscasts-theme'
"Plug 'flazz/vim-colorschemes'
"Plug 'altercation/vim-colors-solarized'
" END
" plugin from http://vim-scripts.org/vim/scripts.html
"Plug 'L9'
" Git plugin not hosted on GitHub
"Plug 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plug 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plug 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plug 'user/L9', {'name': 'newL9'}
" Initialize plugin system
call plug#end()
" Brief help
" :PlugList - lists configured plugins
" :PlugInstall - installs plugins; append `!` to update or just :PlugUpdate
" :PlugSearch foo - searches for foo; append `!` to refresh local cache
" :PlugClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plug stuff after this line
"""""""""""""""""""""""
" GLOBAL CONFIG
"""""""""""""""""""""""
let mapleader = ","
set isk+=- " add dash to word boundaries (for CSS variables)
"""""""""""""""""""""""
" PLUGIN CONFIGURATION
""""""""""""""""""""""
" ULTISNIPS BEGIN
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" ULTISNIPS END
" PROJECTROOT
let g:rootmarkers = ['.projectroot', 'docker-compose.yml', '.git', '.hg', '.svn', '.bzr','_darcs','build.xml']
"
" NERDTREE TABS BEGIN
" Use nerdtree-tabs plugin
map <Leader>n :NERDTreeToggle<CR>
" hide selected files/folders
let NERDTreeIgnore = ['^__pycache__$']
"g:nerdtree_tabs_open_on_gui_startup (default: 1)
"Open NERDTree on gvim/macvim startup
let g:nerdtree_tabs_open_on_console_startup=1 "(default: 0)
"Open NERDTree on console vim startup
"let g:nerdtree_tabs_no_startup_for_diff (default: 1)
"Do not open NERDTree if vim starts in diff mode
"let g:nerdtree_tabs_smart_startup_focus (default: 1)
"On startup, focus NERDTree if opening a directory, focus file if opening a file. (When set to 2, always focus file window after startup).
"let g:nerdtree_tabs_open_on_new_tab (default: 1)
"Open NERDTree on new tab creation (if NERDTree was globally opened by :NERDTreeTabsToggle)
"let g:nerdtree_tabs_meaningful_tab_names (default: 1)
"Unfocus NERDTree when leaving a tab for descriptive tab names
"let g:nerdtree_tabs_autoclose (default: 1)
"Close current tab if there is only one window in it and it's NERDTree
let g:nerdtree_tabs_synchronize_view=0 "(default: 1)
"Synchronize view of all NERDTree windows (scroll and cursor position)
"let g:nerdtree_tabs_synchronize_focus (default: 1)
"Synchronize focus when switching windows (focus NERDTree after tab switch if and only if it was focused before tab switch)
"let g:nerdtree_tabs_focus_on_files (default: 0)
"When switching into a tab, make sure that focus is on the file window, not in the NERDTree window. (Note that this can get annoying if you use NERDTree's feature "open in new tab silently", as you will lose focus on the NERDTree.)
"let g:nerdtree_tabs_startup_cd (default: 1)
"When given a directory name as a command line parameter when launching Vim, :cd into it.
"let g:nerdtree_tabs_autofind (default: 0)
"Automatically find and select currently opened file in NERDTree.
" NERDTREE END
"" AIRLINE BEGIN
"" vim-airline configuration
"set guifont=Inconsolata\ for\ Powerline\ 12
"set laststatus=2
"set t_Co=256
"let g:airline#extensions#tabline#enabled = 1
"let g:airline_powerline_fonts = 1
"let g:Powerline_symbols = 'fancy'
"set encoding=utf-8
""set fillchars+=stl:\ ,stlnc:\
""let g:Powerline_mode_V="V·LINE"
""let g:Powerline_mode_cv="V·BLOCK"
""let g:Powerline_mode_S="S·LINE"
""let g:Powerline_mode_cs="S·BLOCK"
""let g:airline_theme = 'tomorrow' " breaks vim so used only in gvimrc
"let g:airline#extensions#default#section_truncate_width = {
"\ 'b': 80,
"\ 'x': 100,
"\ 'y': 100,
"\ 'z': 100,
"\ 'warning': 100,
"\ }
"" AIRLINE END
" VDEBUG BEGIN
" don't break automatically on first line
let g:vdebug_features = { 'max_children': 128 }
let g:vdebug_options = {
\ 'port' : 9005,
\ 'server' : '',
\ 'continuous_mode': 1,
\ 'break_on_open': 0,
\ 'watch_window_style': 'compact',
\ }
"let g:vdebug_options = {'debug_file': 'vdebug_log', 'debug_file_level': 2,'watch_window_style': 'expanded','marker_default': '*','continuous_mode': 0,'ide_key': '','break_on_open': 1,'on_close': 'detach','path_maps': {'/var/www': '/home/janek/www'},'marker_closed_tree': '+','timeout': 30,'port': 9001,'marker_open_tree': '-','debug_window_level': 1,'server': 'localhost'}
function! SetupDebug()
let g:vdebug_options['path_maps'] = {'/app': call('projectroot#get', a:000)}
" Hack to override vdebug options
source ~/.vim/plugged/vdebug/plugin/vdebug.vim
endfunction
autocmd VimEnter * :call SetupDebug()
"nmap <leader>xd :call SetupDebug()<cr>
"let g:vdebug_keymap = { 'run' : '<F1>' }
"nnoremap <F5> :call SetupDebug() <bar> :VdebugStart <cr>
"nnoremap <F2> <ESC>:echo "test" <bar> :echo "test2" <cr>
" VDEBUG END
" AG.VIM BEGIN
" Ag instead of grep
" autocmd QuickFixCmdPost *grep* cwindow
"set grepprg=ag " use AG instead of grep
set grepprg=ag\ --nocolor\ --nogroup\ --column
" change grep format
set grepformat=%f:%l:%c%m
" mappings
nmap <leader>a <Esc>:Ag!
"nnoremap \ :Ag<SPACE>
" use custom ag path
let g:ag_prg="ag --column --nogroup --nocolor"
" Commented out because of duplication warning
" bind \ (backward slash) to grep shortcut
"command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
" AG.VIM END
" TAGBAR BEGIN
nmap <leader>b :TagbarToggle<CR>
" TAGBAR END
" FUGITIVE BEGIN
" force vertical diff split (instead of default horizontal)
set diffopt+=vertical
" FUGITIVE END
" SYNTASTIC BEGIN
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_html_checkers=[''] " disable HTML checks
let g:syntastic_ruby_checkers = ['rubocop']
" SYNTASTIC END
" VIM-JSX BEGIN
let g:jsx_ext_required = 0
" VIM-JSX END
"""""""""""""""""""""""""""
" CUSTOM CONFIG
"""""""""""""""""""""""""""
" each plugin settings entry begins with two empty lines (for readability)
set backspace=indent,eol,start " fix backspace
set foldenable " enable folding with (open all-close all) - zM, zR, (next-prev) - zj, zk, (open-close) - za, zc
"set foldmethod=syntax " automatically fold based on syntax
"set foldlevelstart=1
"let javaScript_fold=1 " JavaScript
"let perl_fold=1 " Perl
"let php_folding=1 " PHP
"let r_syntax_folding=1 " R
"let ruby_fold=1 " Ruby
"let sh_fold_enabled=1 " sh
"let vimsyn_folding='af' " Vim script
"let xml_syntax_folding=1 " XML
"set foldmethod=indent " automatically fold based on indent level
set smartindent
set nu
set ts=2
set shiftwidth=2
set expandtab
set autoindent
" disables automatic line wrap (very annoying)
set textwidth=0
set wrapmargin=0
map <C-d> :t.<CR>
map <C-o> :Breakpoint<CR>
" nmap - map for normal mode only
" tab switching
nmap <C-s> :tabn<CR>
nmap <C-a> :tabp<CR>
" window switching
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
" copy paste from system clipboard
map <C-v> "+p
map <C-c> "+y
" paste multiple times after copy
xnoremap p pgvy
" replace selected text globally with prompt
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" disable paste by pressing mouse middle button
:map <MiddleMouse> <Nop>
:imap <MiddleMouse> <Nop>
" disable arrow navigation
"noremap <Up> <NOP>
"noremap <Down> <NOP>
"noremap <Left> <NOP>
"noremap <Right> <NOP>
" disable column/row navigation
noremap h <NOP>
" noremap j <NOP>
" noremap k <NOP>
noremap l <NOP>
" diffupdate shortcut
"command Dfu diffupdate
" USE DEFAULT dp instead
" disable automatic search wrapping
set nowrapscan
" map key to delete to the 'black hole' register
map <leader>dd "_dd
map <leader>d "_d
"set background=dark
colorscheme railscasts
"colorscheme solarized
"candystripe
"store swap files in separate directory
set backupdir=~/.vim/tmp/backup//
set directory=~/.vim/tmp/swap//
" copy current file name (relative/absolute) to system clipboard
if has("mac") || has("gui_macvim") || has("gui_mac")
" relative path (src/foo.txt)
nnoremap <leader>cf :let @*=expand("%")<CR>
" absolute path (/something/src/foo.txt)
nnoremap <leader>cF :let @*=expand("%:p")<CR>
" filename (foo.txt)
nnoremap <leader>ct :let @*=expand("%:t")<CR>
" directory name (/something/src)
nnoremap <leader>ch :let @*=expand("%:p:h")<CR>
endif
" copy current file name (relative/absolute) to system clipboard (Linux version)
if has("gui_gtk") || has("gui_gtk2") || has("gui_gnome") || has("unix")
" relative path (src/foo.txt)
nnoremap <leader>cf :let @+=expand("%")<CR>
" absolute path (/something/src/foo.txt)
nnoremap <leader>cF :let @+=expand("%:p")<CR>
" filename (foo.txt)
nnoremap <leader>ct :let @+=expand("%:t")<CR>
" directory name (/something/src)
nnoremap <leader>ch :let @+=expand("%:p:h")<CR>
endif
" highlight syntax in .tpl files as Twig
au BufNewFile,BufRead *.tpl set filetype=html.twig
" highlight syntax in .tpl files as Smarty
"au BufNewFile,BufRead *.tpl set filetype=smarty
" highlight PHP files
au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp,*.inc,*.info setf php
" highlight Markdown files
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
"autocmd BufNewFile,BufReadPost *.jsx set filetype=javascript
" MACVIM
" (DOESNT WORK!!!)
if has("gui_macvim")
" mvim specific
set guifont=Inconsolata\ for\ Powerline\ 20
endif
" POWERLINE integration
set rtp+=/usr/local/lib/python2.7/site-packages/powerline/bindings/vim/
" Always show statusline
set laststatus=2
"
" " Use 256 colours (Use this setting only if your terminal supports 256
" colours)
set t_Co=256"
" POWERLINE end
" EASYGREP
let g:EasyGrepCommand=1
let g:EasyGrepRecursive=1
let g:EasyGrepFilesToExclude='*.swp,*~,*.reg'
" EASYGREP end
" rubocop
let g:vimrubocop_keymap = 0
nmap <Leader>r :RuboCop<CR>
" rubocop END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment