Last active
May 12, 2018 01:23
-
-
Save risan/5158d1bd89599ea1f48da0c0c6ad6f8e to your computer and use it in GitHub Desktop.
My VIM config files
This file contains 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
"======================================== | |
" APPEARANCES | |
"======================================== | |
" Set the theme. | |
colorscheme atom-dark | |
" Set line space. | |
set linespace=10 | |
" Configure the vertical split colors. | |
hi vertsplit guifg=bg guibg=gray | |
" Set color column color. | |
hi ColorColumn guibg=#292929 | |
" Font settings. | |
set guifont=Fira_Code:h14 | |
" Hide the scrollbars. | |
set guioptions-=l | |
set guioptions-=L | |
set guioptions-=r | |
set guioptions-=R |
This file contains 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
" Always use the improved version. | |
set nocompatible | |
" Automatically write the file when switching buffer. | |
set autowriteall | |
" Use the unnamed (*) and unnamedplus (+) registers that are used by the system clipboard. | |
set clipboard^=unnamed,unnamedplus | |
" Don't redraw screen while executing macros or registers. | |
set lazyredraw | |
" Automatically detect file changes outside of vim. | |
set noautoread | |
" Set the leader key. | |
let mapleader = ',' | |
" Load the plugins. | |
so ~/.vim/plugins.vim | |
"======================================== | |
" APPEARANCES | |
"======================================== | |
" Enable syntax highlighting. | |
syntax enable | |
" Use the 256 colors. | |
set t_Co=256 | |
" Set the theme. | |
colorscheme atom-dark-256 | |
" Show the line numbers. | |
set number | |
" Highlight columns for ruller. | |
set colorcolumn=81,121 | |
" Disable the beep bell. | |
set vb t_vb= | |
" Configure the vertical split colors. | |
hi vertsplit ctermfg=bg ctermbg=gray | |
" Show tab and trailing spaces. | |
set list | |
set listchars=tab:→·,trail:· | |
"======================================== | |
" TABS AND INDENTATIONS | |
"======================================== | |
" Specify the width of tab characters. | |
set tabstop=4 | |
" Fine tune the amount of white spaces for a tab in insert mode. | |
set softtabstop=4 | |
" Expand the tab to spaces. | |
set expandtab | |
" Specify the width of tab characters in normal mode. | |
set shiftwidth=4 | |
"======================================== | |
" SEARCHING | |
"======================================== | |
" Ignore case when searching. | |
set ignorecase | |
" Keep case sensitivity when searching with mixed cases. | |
set smartcase | |
" Highlight the matched search terms. | |
set hlsearch | |
" Activate incremental search. | |
set incsearch | |
"======================================== | |
" SPLITS | |
"======================================== | |
" Open a new horizontal split below the current one. | |
set splitbelow | |
" Open a new vertical split on the right. | |
set splitright | |
"======================================== | |
" AUTOCOMPLETE | |
"======================================== | |
" Set the auto completion sources: | |
" - . : Scan the current file | |
" - w : Scan the buffers from the other windows (splits) | |
" - b : Scan the active buffers (marked with a) from the buffer list | |
" - u : Scan the unloaded buffers from the buffer list | |
" - t : Scan the tags file | |
" - i : Scan the included files (using the #include, require, load keywords) | |
set complete=.,w,b,u,t,i | |
" Completion options: | |
" - menuone : Display popup menu even when there's only one match | |
" - preview : show extra information about the selected completion | |
" - longest : only insert the longest common text of the matches | |
set completeopt=menuone,preview | |
"======================================== | |
" MAPPINGS | |
"======================================== | |
" Shortcut to edit vimrc config files. | |
nmap <Leader>ev :tabedit $MYVIMRC<cr> | |
nmap <Leader>eg :tabedit ~/.gvimrc<cr> | |
nmap <Leader>ep :tabedit ~/.vim/plugins.vim<cr> | |
" Clear the highlighted search terms. | |
nmap <Leader><space> :nohlsearch<cr> | |
" Swith split shorcuts. | |
nmap <C-h> <C-w><C-h> | |
nmap <C-j> <C-w><C-j> | |
nmap <C-k> <C-w><C-k> | |
nmap <C-l> <C-w><C-l> | |
" Indentation shortcuts. | |
nmap <Leader>[ << | |
nmap <Leader>] >> | |
vmap <Leader>[ <gv | |
vmap <Leader>] >gv | |
" Expand %% to the current directory of the active file. | |
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr> | |
" Shortcut to edit other file relative to the active one. | |
nmap <leader>ew :e %% | |
nmap <leader>es :vsp %% | |
nmap <leader>et :tabe %% | |
" NERDTree shortcuts. | |
nmap <Leader>1 :NERDTreeToggle<cr> | |
" CtrlP shortcuts. | |
nmap <Leader>r :CtrlPBufTag<cr> | |
nmap <Leader>e :CtrlPMRUFiles<cr> | |
" Tag shortcuts. | |
nmap <Leader>f :tag<space> | |
" Laravel shortcuts. | |
nmap <Leader>lr :e routes/web.php<cr> | |
nmap <Leader>lm :!php artisan make: | |
nmap <Leader>lc :e app/Http/Controllers<cr> | |
nmap <Leader>lv :e resources/views<cr> | |
" vim-php-cs-fixer shortcuts. | |
nnoremap <silent><leader>cf :call PhpCsFixerFixFile()<cr> | |
"======================================== | |
" MACROS | |
"======================================== | |
" PHP add class property. | |
let @p = "mxyiw/} | |
O$this->pa = $pa;'x?^[ \t]*$\\|{ | |
oprotected $pa; | |
`x, " | |
"======================================== | |
" PLUGINS | |
"======================================== | |
" ack.vim | |
"---------------------------------------- | |
" Use the 'ag' or the silver searcher instead of ack. | |
let g:ackprg = 'ag --vimgrep' | |
" CtrlP | |
"---------------------------------------- | |
" Exclude files or directories. | |
let g:ctrlp_custom_ignore = '\v[\/](\.git|node_modules)$' | |
" Configure match windo. | |
let g:ctrlp_match_window = 'top,order:ttb,min:1,max:20,results:20' | |
" greplace.vim | |
"---------------------------------------- | |
" Use ag instead of grep. | |
set grepprg=ag | |
" Grep command options. | |
let g:grep_cmd_opts = '--line-numbers --noheading' | |
" NERDTree | |
"---------------------------------------- | |
" Don't let NERDTree hijack the netrw. | |
let NERDTreeHijackNetrw = 0 | |
" supertab | |
"---------------------------------------- | |
" Set the default completion type. | |
let g:SuperTabDefaultCompletionType = 'context' | |
" Default completion type when context completion has no results. | |
let g:SuperTabContextDefaultCompletionType = '<C-n>' | |
" List of contexts to use for context completion. | |
let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover'] | |
" Omni completion names in order of precedence for context text. | |
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc'] | |
" Omni completion mappings for context discover. | |
let g:SuperTabContextDiscoverDiscovery = ['&completefunc:<C-x><C-u>', '&omnifunc:<C-x><C-o>'] | |
" Retains the completion type until the current completion. | |
let g:SuperTabRetainCompletionDuration = 'completion' | |
" Enhance longest match support 'longest' must be set on completeopt. | |
"let g:SuperTabLongestEnhanced = 1 | |
" Set fallback for the omni completion. | |
autocmd FileType * | |
\ if &omnifunc != '' | | |
\ call SuperTabChain(&omnifunc, '<C-n>') | | |
\ endif | |
" UltiSnips | |
"---------------------------------------- | |
" Trigger key to expand the snippet. | |
let g:UltiSnipsExpandTrigger = '<tab>' | |
" Key to jump to the next tab stop. | |
let g:UltiSnipsJumpForwardTrigger = '<C-b>' | |
" Key to jump to the previous tab stop. | |
let g:UltiSnipsJumpBackwardTrigger = '<C-z>' | |
" Directory to load the private snippets. | |
let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnips' | |
" Vim Better Whitespace | |
"---------------------------------------- | |
" Enable whitespace highlighting. | |
let g:better_whitespace_enabled=1 | |
" Highlight space characters that appear before or in-between tabs. | |
let g:show_spaces_that_precede_tabs=1 | |
" Strip whitespaces on save. | |
let g:strip_whitespace_on_save=1 | |
" Strip white lines at the end of the file. | |
let g:strip_whitelines_at_eof=1 | |
" vim-php-cs-fixer | |
"---------------------------------------- | |
let g:php_cs_fixer_path = '~/.composer/vendor/bin/php-cs-fixer' | |
if filereadable('.php_cs.dist') | |
let g:php_cs_fixer_config_file = '.php_cs.dist' | |
else | |
let g:php_cs_fixer_rules = '@Symfony' | |
endif | |
" vim-php-namespace | |
"---------------------------------------- | |
" Import class or functio using use keyword. | |
function! IPhpInsertUse() | |
call PhpInsertUse() | |
call feedkeys('a', 'n') | |
endfunction | |
autocmd FileType php inoremap <Leader>n <Esc>:call IPhpInsertUse()<CR> | |
autocmd FileType php noremap <Leader>n :call PhpInsertUse()<CR> | |
" Expand class under the cursor to the fully qualified name. | |
function! IPhpExpandClass() | |
call PhpExpandClass() | |
call feedkeys('a', 'n') | |
endfunction | |
autocmd FileType php inoremap <Leader>nf <Esc>:call IPhpExpandClass()<CR> | |
autocmd FileType php noremap <Leader>nf :call PhpExpandClass()<CR> | |
"======================================== | |
" AUTO COMMANDS | |
"======================================== | |
augroup autosourcing | |
autocmd! | |
" Source the .vimrc on save. | |
autocmd BufWritePost .vimrc source % | |
" Source the .gvimrc on save. | |
autocmd BufWritePost .gvimrc source % | |
" Source the .vimrc file on plugins.vim save. | |
autocmd BufWritePost plugins.vim source $MYVIMRC | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment