Skip to content

Instantly share code, notes, and snippets.

@erickpatrick
Last active July 21, 2019 16:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erickpatrick/f8db46360f375e02bdc2af2313c5234c to your computer and use it in GitHub Desktop.
Save erickpatrick/f8db46360f375e02bdc2af2313c5234c to your computer and use it in GitHub Desktop.
.vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" EVERYTHING RUNS SMOOTLY ONLY ON *VIM 8* "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NECESSARY PLUGINS "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGIN MANAGER "
" - https://github.com/VundleVim/Vundle.vim "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Plugin Manager manages itself LOL
Plugin 'VundleVim/Vundle.vim'
" General plugins
" Plugin 'nanotech/jellybeans.vim'
Plugin 'dracula/vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'scrooloose/nerdtree'
Plugin 'mileszs/ack.vim'
Plugin 'ludovicchabant/vim-gutentags'
Plugin 'ddrscott/vim-side-search'
Plugin 'vim-airline/vim-airline'
Plugin 'junegunn/fzf.vim'
Plugin 'mhinz/vim-signify'
Plugin 'vim-syntastic/syntastic'
Plugin 'moll/vim-bbye'
" PHP specific plugins
Plugin 'StanAngeloff/php.vim'
Plugin 'lvht/phpcd.vim'
Plugin '2072/vim-syntax-for-PHP.git'
" Other plugins
Plugin 'cakebaker/scss-syntax.vim'
call vundle#end()
filetype plugin indent on
" basic mapping to avoid the problem with fast fingers =P
:command! WQ wq
:command! Wq wq
:command! W w
:command! Q q
cmap w!! w !sudo tee > /dev/null %
"basic configuration
set updatetime=250
set background=dark
set tabstop=4
set shiftwidth=4
set softtabstop=0
set smarttab
set expandtab
set wildmenu
set wildmode=list:longest,full
set ttyfast
set showmatch
set hlsearch
set incsearch
set number relativenumber
set matchtime=1
set laststatus=2
set t_Co=256
set backspace=indent,eol,start
set visualbell
set noerrorbells
set splitbelow
set splitright
set backupdir=~/.vim/backup
set directory=~/.vim/swap
set encoding=utf-8
set signcolumn=yes
set shell=/bin/bash " or /usr/bin/zsh or you preferent one
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,var
set rtp+=~/.fzf
set hidden
syntax on
color dracula
let mapleader=","
nnoremap <leader><space> :nohlsearch<CR>
"""""""""""""""""""""""""""" Bbye
set runtimepath^=~/.vim/bundle/bbye
nnoremap <Leader>q :Bdelete<CR>
"""""""""""""""""""""""""""" Buffer switching
nnoremap <F5> :buffers<CR>:buffer<Space>
"""""""""""""""""""""""""""" Gutentags
let g:gutentags_modules = ['ctags']
let g:gutentags_cache_dir = '~/.vim/gutentags'
let g:gutentags_ctags_exclude = ['*.css', '*.html', '*.js', '*.json', '*.xml',
\ '*.phar', '*.ini', '*.rst', '*.md',
\ '*vendor/*/test*', '*vendor/*/Test*',
\ '*vendor/*/fixture*', '*vendor/*/Fixture*',
\ '*var/cache*', '*var/log*', '*var*', '*node_modules*']
"""""""""""""""""""""""""""" Others
let g:ackprg = 'ag --nogroup --nocolor --column'
let g:jellybeans_use_lowcolor_black = 0
"""""""""""""""""""""""""""" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_php_checkers=['php', 'phpcs']
let g:syntastic_php_phpcs_args='--standard=PSR2 -n'
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_aggregate_errors = 1
"""""""""""""""""""""""""""" PHPActor
let g:phpactorPhpBin = 'php'
let g:phpactorBranch = 'master'
let g:phpactorOmniError = v:true
" autocmd BufEnter * call ncm2#enable_for_buffer()
" autocmd FileType php setlocal omnifunc=phpactor#Complete
set completeopt=noinsert,menuone,noselect
" Include use statement
nmap <Leader>u :call phpactor#UseAdd()<CR>
" Invoke the context menu
nmap <Leader>mm :call phpactor#ContextMenu()<CR>
" Invoke the navigation menu
nmap <Leader>nn :call phpactor#Navigate()<CR>
" Goto definition of class or class member under the cursor
nmap <Leader>o :call phpactor#GotoDefinition()<CR>
" Transform the classes in the current file
nmap <Leader>tt :call phpactor#Transform()<CR>
" Generate a new class (replacing the current file)
nmap <Leader>cc :call phpactor#ClassNew()<CR>
" Extract expression (normal mode)
nmap <silent><Leader>ee :call phpactor#ExtractExpression(v:false)<CR>
" Extract expression from selection
vmap <silent><Leader>ee :<C-U>call phpactor#ExtractExpression(v:true)<CR>
" Extract method from selection
vmap <silent><Leader>em :<C-U>call phpactor#ExtractMethod()<CR>
"""""""""""""""""""""""""""
function! PhpSyntaxOverride()
hi! def link phpDocTags phpDefine
hi! def link phpDocParam phpType
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END
"""""""""""""""""""""""""""
nmap <F2> :NERDTreeToggle<CR>
nmap <F3> :NERDTreeFind<CR>
nmap <F4> :q<CR>
nmap <S-F4> :q!<CR>
"""""""""""""""""""""""""""
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType html setlocal omnifunc=htmlcomplete#CompleteTags
""""""""""""""""""""""""""" SCSS Syntax
au BufRead,BufNewFile *.scss set filetype=scss.css
autocmd FileType scss set iskeyword+=-
"""""""""""""""""""""""""""" Tab/Enter choose suggestion
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" SideSearch current word and return to original window
nnoremap <Leader>ss :SideSearch <C-r><C-w><CR> | wincmd p
" Create an shorter `SS` command
command! -complete=file -nargs=+ SS execute 'SideSearch <args>'
" or command abbreviation
cabbrev SS SideSearch
let g:side_search_prg = 'ag --word-regexp'
\. " --ignore='*.js.map'"
\. " --heading --stats -B 1 -A 4"
""""""""""""""""""""""""""" RipGrep + FZF
nnoremap <leader>a :Rg<space>
nnoremap <leader>A :exec "Rg ".expand("<cword>")<cr>
autocmd VimEnter * command! -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --fixed-strings --ignore-case --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
""""""""""""""""""""""""""" Vim PHP Wrapper
nnoremap <buffer> <silent> <Leader>dk :call VphpwDocClosestMethod(0)<CR>
nnoremap <buffer> <silent> <Leader>dj :call VphpwDocClosestMethod(1)<CR>
noremap <buffer> <silent> <Leader>dl :call VphpwAlignDocblock()<CR>
nnoremap <buffer> <silent> <Leader>dd :call VphpwDeleteEnclosingDocblock()<CR>
noremap <buffer> <silent> <Leader>dr :call VphpwResetDocblock()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment