Created
November 25, 2018 16:07
-
-
Save jstoone/b75e66be6bfaf7ab7525b0ff759102bf to your computer and use it in GitHub Desktop.
Neovim config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"----------------- | |
" Init | |
"----------------- | |
if empty(glob('~/.config/nvim/autoload/plug.vim')) | |
" Auto-install vim-plug | |
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd! | |
autocmd VimEnter * PlugInstall | |
endif | |
" }}} | |
"----------------- | |
" Plugins | |
"----------------- | |
call plug#begin('~/nvim/plugged') | |
Plug 'scrooloose/nerdtree' " file tree to vim | |
Plug 'tpope/vim-commentary' " commenting | |
Plug 'tpope/vim-surround' " quoting/parenthesizing made simple | |
Plug 'mattn/emmet-vim' " emmet for vim | |
Plug 'itchyny/lightline.vim' " simple status bar | |
Plug 'chriskempson/base16-vim' " base16 colors | |
Plug 'sheerun/vim-polyglot' " a solid language pack | |
Plug 'w0rp/ale' " async linting/fixing | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' } | |
Plug 'junegunn/fzf.vim' " fuzzy finder (CtrlP replacement) | |
Plug 'arnaud-lb/vim-php-namespace', {'for': 'php'} | |
Plug 'ludovicchabant/vim-gutentags' | |
Plug 'stephpy/vim-php-cs-fixer' " easy use of php-cs-fixer | |
Plug 'phpactor/phpactor', {'for': 'php', 'do': 'composer install'} | |
call plug#end() | |
"----------------- | |
" General | |
"----------------- | |
let mapleader = ',' " Make comma the leader key instead of backslash | |
syntax enable " Enable syntax highlighting | |
set number " Add line numbers | |
set list " Show spaces set smarttab set shiftwidth=4 | |
set tabstop=4 " Use four columns per tab | |
set softtabstop=4 " Use four columns per tab in insert mode | |
set shiftwidth=4 " Use four columns per tab when using << and >> | |
set expandtab " Use spaces instead of tabs set autoindent set smartindent | |
"set ignorecase smartcase " Makes searches case insensitive unless they contain capitals | |
set undofile " Preserve undo history per file, through multiple sessions | |
"----------------- | |
" Command-mode | |
"----------------- | |
cnoremap <C-A> <Home> | |
cnoremap <C-E> <End> | |
cnoremap <C-K> <C-U> | |
cnoremap <C-P> <Up> | |
cnoremap <C-N> <Down> | |
"----------------- | |
" Searching | |
"----------------- | |
" Make it easy to remove highlights after search | |
nmap <Leader><space> :nohlsearch<cr> | |
" Quick search with space | |
nmap <space> / | |
" Quick backwards search with Ctrl+Space | |
nmap <c-space> ? | |
"----------------- | |
" Splits | |
"----------------- | |
set splitbelow " Default splits to appear BELOW active buffer | |
set splitright " Default vsplits to appear TO THE RIGHT of the active buffer | |
" Cut off Ctrl-W when navigating splits | |
nmap <C-J> <C-W><C-J> | |
nmap <C-K> <C-W><C-K> | |
nmap <C-H> <C-W><C-H> | |
nmap <C-L> <C-W><C-L> | |
" Vertial splits shortcut | |
nmap <Leader>L :vsp<cr> | |
" Horizontal splits shortcut | |
nmap <Leader>J :sp<cr> | |
"----------------- | |
" NERDTree | |
"----------------- | |
nmap <leader><tab> :NERDTreeToggle<cr> | |
"----------------- | |
" Lightline | |
"----------------- | |
set noshowmode | |
"----------------- | |
" Base16 | |
"----------------- | |
set signcolumn=yes " Always show the sign column | |
set background=dark | |
set foldcolumn=0 | |
" Fill the TabLine with the background color | |
highlight TabLineFill ctermbg=black | |
highlight TabLine ctermbg=black | |
highlight TabLineSel ctermbg=black | |
" Configuring the left side gutter to look good with GitGutter and the like | |
highlight LineNr ctermbg=black | |
highlight FoldColumn ctermbg=black | |
highlight SignColumn ctermbg=black | |
" set correct base16 theme | |
let base16colorspace=256 | |
colorscheme base16-atelier-dune-light | |
"----------------- | |
" FZF | |
"----------------- | |
let g:fzf_layout = { 'down': '~20%' } | |
let g:fzf_nvim_statusline = 0 " Disable statusline overwriting | |
let g:fzf_buffers_jump = 1 " Jump to existing buffer if possible | |
nmap <silent> <C-p> :Files<cr> | |
nmap <silent> <C-r> :History<cr> | |
nmap <silent> <C-f> :BTags<cr> | |
nmap <silent> <C-s> :Tags<cr> | |
" When fzf starts in a terminal buffer, you may want to hide the statusline of the containing buffer. | |
autocmd! FileType fzf | |
autocmd FileType fzf set laststatus=0 noshowmode noruler | |
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler | |
"----------------- | |
" php-cs-fixer | |
"----------------- | |
autocmd BufWritePost *.php silent! call PhpCsFixerFixFile() | |
"----------------- | |
" ALE | |
"----------------- | |
let g:ale_sign_column_always = 1 | |
let g:ale_sign_error = 'e' | |
let g:ale_sign_warning = 'w' | |
"----------------- | |
" vim-php-namespace | |
"----------------- | |
let g:php_namespace_sort_after_insert = 1 | |
function! IPhpInsertUse() | |
call PhpInsertUse() | |
call feedkeys('a', 'n') | |
endfunction | |
"" Insert PHP 'use'-statement in both normal and insert mode | |
autocmd FileType php inoremap <Leader>nn <Esc>:call IPhpInsertUse()<CR> | |
autocmd FileType php noremap <Leader>nn :call PhpInsertUse()<CR> | |
function! IPhpExpandClass() | |
call PhpExpandClass() | |
call feedkeys('a', 'n') | |
endfunction | |
"" Expand PHP FQN in both normal and insert mode | |
autocmd FileType php inoremap <Leader>nf <Esc>:call IPhpExpandClass()<CR> | |
autocmd FileType php noremap <Leader>nf :call PhpExpandClass()<CR> | |
"----------------- | |
" gutentags | |
"----------------- | |
let g:gutentags_ctags_extra_args = [ | |
\ '--recurse=yes', | |
\ '--tag-relative=yes', | |
\ '--exclude=.git', | |
\ '--languages=php', | |
\ '--PHP-kinds=+cdfint-av', | |
\ '--langmap=php:.engine.inc.module.theme.install.php', | |
\ '--PHP-kinds=+cf-v' | |
\] | |
let g:gutentags_exclude = [ | |
\ '*.css', '*.html', '*.js', '*.json', '*.xml', | |
\ '*.phar', '*.ini', '*.rst', '*.md', | |
\ '*var/cache*', '*var/log*' | |
\] | |
"----------------- | |
" MAPPINGS | |
"----------------- | |
" Remap redo, since ctrl-r is now recent files | |
nmap U :redo<cr> | |
" Treat long lines as break lines (useful when moving around in them) | |
nmap j gj | |
nmap k gk | |
" Make it easy to edit Vimrc file | |
nmap <Leader>ev :tabedit $MYVIMRC<cr> | |
" Make it easy to edit my plugins file | |
nmap <Leader>ep :tabedit $HOME/.vim/plugins.vim<cr> | |
" Run phpunit on the current file | |
nmap <Leader>tt :!clear && phpunit %<cr> | |
" Run phpunit on the entire suite | |
nmap <Leader>ta :!clear && phpunit<cr> | |
"----------------- | |
" AUTOCOMMANDS | |
"----------------- | |
" Automatically source the Vimrc file on save | |
augroup autosourcing | |
" kill previous auto commands in group | |
autocmd! | |
" rc files | |
autocmd BufWritePost .vimrc so % | |
autocmd BufWritePost init.vim so % | |
" other config files | |
autocmd BufWritePost .Xdefaults ! xrdb % | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment