Skip to content

Instantly share code, notes, and snippets.

@chartjes
Created November 12, 2018 21:27
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 chartjes/a0db4e783277f92759b5075f061345fa to your computer and use it in GitHub Desktop.
Save chartjes/a0db4e783277f92759b5075f061345fa to your computer and use it in GitHub Desktop.
"
" MAIN CUSTOMIZATION FILE
"
"
set nocompatible
syntax on
set encoding=utf8
filetype off
" Load our plugins
call plug#begin('~/.vim/plugged')
Plug 'gmarik/Vundle.vim'
Plug 'tmhedberg/SimpylFold'
Plug 'vim-scripts/indentpython.vim'
Plug 'roxma/nvim-completion-manager'
Plug 'nvie/vim-flake8'
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-surround'
Plug 'phpactor/phpactor'
Plug 'roxma/ncm-phpactor'
Plug 'arnaud-lb/vim-php-namespace'
Plug 'junegunn/fzf.vim'
Plug '/usr/local/opt/fzf'
Plug 'wincent/ferret'
Plug 'adoy/vim-php-refactoring-toolbox'
Plug '2072/PHP-Indenting-for-VIm'
Plug 'SirVer/ultisnips'
Plug 'StanAngeloff/php.vim'
Plug 'stephpy/vim-php-cs-fixer'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins'}
Plug 'w0rp/ale'
Plug 'lvht/phpcd.vim', {'for': 'php', 'do': 'composer install'}
Plug 'ervandew/supertab'
Plug 'jsfaint/gen_tags.vim'
call plug#end()
filetype plugin indent on
" easily switch between vsplit windows
map <c-j> <C-w>j
map <c-k> <C-w>k
map <c-h> <c-w>h
map <c-l> <c-w>l
" Do smart autoindenting
set smartindent
set autoindent
" save yourself if you forgot to use sudo to save something
cmap w!! w !sudo tee % >/dev/null
" I like linenumbers, thanks
set number
" Save temporary/backup files not in the local directory, but in your ~/.vim
" directory, to keep them out of git repos.
" But first mkdir backup, swap, and undo first to make this work
call system('mkdir ~/.vim')
call system('mkdir ~/.vim/backup')
call system('mkdir ~/.vim/swap')
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
" Keep undo history across sessions by storing it in a file
if has('persistent_undo')
call system('mkdir ~/.vim/undo')
set undodir=~/.vim/undo//
set undofile
set undolevels=1000
set undoreload=10000
endif
" set search case to a good configuration http://vim.wikia.com/wiki/Searching
set ignorecase
set smartcase
" search characters as they're entered
set incsearch
" Automatically source .vimrc every time it changes
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc nested source %
augroup END
" I like pretty colours in my terminal
set t_Co=256
" Enable folding
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
" Show Python docstrings when folding
let g:SimpylFold_docstring_preview=1
" Make our Python code look nice
let python_highlight_all=1
" NERDTree settings
let NERDTreeIgnore=['\.pyc$', '\~$']
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Get FZF and ripgrep working together
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 --no-ignore --hidden --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)
" Settings for phpactor
" Include use statement
nmap <Leader>u :call phpactor#UseAdd()<CR>
" Invoke the context menu
nmap <Leader>mm :call phpactor#ContextMenu()<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 method from selection
vmap <silent><Leader>ex :<C-U>call phpactor#ExtractMethod()<CR>
" Use Phpactor for auto-completion when doing PHP
autocmd FileType php setlocal omnifunc=phpactor#Complete
" Indenting for my PHP projects
autocmd FileType php setlocal autoindent expandtab tabstop=4 softtabstop=4 shiftwidth=4 shiftround
" php-cs-fixer rules
let g:php_cs_fixer_enable_default_mapping = 1
let g:php_cs_fixer_cache = ".php_cs.cache"
let g:php_cs_fixer_config_file = ".php_cs.dist"
" deoplete configuration
let g:deoplete#enable_at_startup = 1
let g:deoplete#ignore_sources = get(g:, 'deoplete#ignore_sources', {})
let g:deoplete#ignore_sources.php = ['omni']
" ALE config settings
let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 1
let g:ale_linters = {'php': ['phpstan'],}
let g:airline#extensions#ale#enabled = 1
let g:ale_sign_column_always = 1
augroup ALELint
au!
au VimEnter,WinEnter,BufWinEnter * ALELint
augroup end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment