Skip to content

Instantly share code, notes, and snippets.

@kaido24
Forked from rteijeiro/.vimrc
Created June 21, 2016 19:30
Show Gist options
  • Save kaido24/95a160d84139b58a07e339e5e4b7fc59 to your computer and use it in GitHub Desktop.
Save kaido24/95a160d84139b58a07e339e5e4b7fc59 to your computer and use it in GitHub Desktop.
Vim config for Drupal project development
" Allow Vim-only settings even if they break vi keybindings.
set nocompatible
" Enable filetype detection.
filetype off
filetype plugin indent on
" Enable syntax highlighting
if &t_Co > 1
syntax enable
endif
syntax on
" Persistent Undo (vim 7.3 and later)
if exists('&undofile') && !&undofile
set undodir=~/.vim_runtime/undodir
set undofile
endif
" Indentation
set autoindent
set smartindent
set tabstop=2
set shiftwidth=2
set expandtab
" General settings
set incsearch "Find as you type
set scrolloff=2 "Number of lines to keep above/below cursor
set number "Show line numbers
set wildmode=longest,list "Complete longest string, then list alternatives
set pastetoggle=<F2> "Toggle paste mode
set fileformats=unix "Use Unix line endings
set history=300 "Number of commands to remember
set showmode "Show whether in Visual, Replace, or Insert Mode
set showmatch "Show matching brackets/parentheses
set backspace=2 "Use standard backspace behavior
set hlsearch "Highlight matches in search
set ruler "Show line and column number
set formatoptions=1 "Don't wrap text after a one-letter word
set linebreak "Break lines when appropriate
set backupcopy=yes "Fixes problems with webpack watch
" Always edit in utf-8.
set encoding=utf-8
set cursorline
set numberwidth=5
set clipboard=unnamed
" PHP Highlight
let php_baselib = 1
let php_htmlInStrings = 1
let php_parent_error_close = 1
" Highlight trailing whitespaces.
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" Syntastic config
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 = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_javascript_checkers = ['eslint']
" Enforce consistent line endings: if 'ff' is set to "unix" and there are any
" stray '\r' characters at ends of lines, then automatically remove them. See
" $VIMRUNTIME/indent/php.vim
let PHP_removeCRwhenUnix = 1
" Persistent Undo (vim 7.3 and later)
if exists('&undofile') && !&undofile
set undodir=~/.vim_runtime/undodir
set undofile
endif
if has("autocmd")
" Uncomment the following to have Vim jump to the last position when
" reopening a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" Set Drupal files as php
augroup module
autocmd BufRead,BufNewFile *.module set filetype=php
autocmd BufRead,BufNewFile *.php set filetype=php
autocmd BufRead,BufNewFile *.install set filetype=php
autocmd BufRead,BufNewFile *.test set filetype=php
autocmd BufRead,BufNewFile *.inc set filetype=php
autocmd BufRead,BufNewFile *.profile set filetype=php
autocmd BufRead,BufNewFile *.theme set filetype=php
augroup END
" Source vimrc file after saving it
" autocmd bufwritepost .vimrc source $MYVIMRC
endif
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType jade set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType c set omnifunc=ccomplete#Complet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment