Skip to content

Instantly share code, notes, and snippets.

@galvao
Created October 6, 2020 10:29
Show Gist options
  • Save galvao/776a84d7e911d185e42547ca4c7cecc7 to your computer and use it in GitHub Desktop.
Save galvao/776a84d7e911d185e42547ca4c7cecc7 to your computer and use it in GitHub Desktop.
tmp init.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" .vimrc - Vim/GVim Configuration File
"
" Er Galvão Abbott - https://github.com/galvao/dotfiles
"
" Official docs @ http://vimdoc.sourceforge.net/htmldoc/usr_toc.html
"
" Many thanks to Matthew Weier O'Phinney for his articles about it:
" - https://mwop.net/blog/249-vim-toolbox-2010-edition.html
" - https://mwop.net/blog/164-Vim-Productivity-Tips-for-PHP-Developers.html
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" No compatibility with vi
:set nocompatible
" Best mouse usage on vim >= 8
:set mouse=a
:set encoding=utf8
" Plugs
call plug#begin('~/.config/nvim/plugged')
Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin', {'as': 'NERDTree Git'}
Plug 'vim-airline/vim-airline', { 'as': 'vim-airline' }
Plug 'vim-airline/vim-airline-themes', { 'as': 'vim-airline-themes' }
Plug 'ervandew/supertab', { 'as': 'SuperTab' }
Plug 'vim-vdebug/vdebug', { 'as': 'VDebug' }
Plug 'segeljakt/vim-silicon', {'as': 'silicon'}
Plug 'rbong/vim-flog', {'as': 'flog'}
Plug 'StanAngeloff/php.vim', {'as': 'php-vim'}
Plug 'HerringtonDarkholme/yats.vim', {'as': 'ts-syntax-yats'}
Plug 'freitass/todo.txt-vim'
Plug 'tpope/vim-fugitive'
call plug#end()
" Run NERDTree on start
autocmd vimenter * NERDTree
syntax on
filetype plugin indent on
set guifont=Hack:h13
" @todo: No undo file, global clipboard
:set undofile
:set clipboard=unnamed
:set ttyfast
" Automatic indentation, smart indentation
:set autoindent
:set smartindent
" Set the folding method to indent
:set foldmethod=indent
:set foldlevelstart=99
" Use the space bar to open/close foldings
nnoremap <Space> za
let g:SuperTabMappingForward = '<tab>'
let g:SuperTabMappingBackward = '<s-tab>'
" Can't exactly remember, guessing is so folding is not activated upon opening a file
:autocmd BufWinEnter * let &foldlevel = max(map(range(1, line('$')), 'foldlevel(v:val)'))
" Reload .vimrc upon saving it
au BufWritePost ~/.config/nvim/init.vim so ~/.config/nvim/init.vim
" Starting indentation on level 1 and a smaller guide size
:let g:indent_guides_start_level = 2
:let g:indent_guides_guide_size = 1
" Highlights an area of 120 characters, so you notice if you go over this limit (PSR12)
let &colorcolumn=join(range(121,999),",")
hi ColorColumn ctermbg=red guibg=maroon
" Get rid of backup, buffer and undo files
:set backupdir=/tmp//
:set directory=/tmp//
:set udir=/tmp//
" Check Syntax with CTRL + L
map <C-L> :!php -l %<CR>
" Forgot to sudo a file? Type :w!!
cmap w!! w !sudo tee % >/dev/null
" Ignore these extensions
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
" Tabs as four spaces
:set smarttab
:set expandtab
:set tabstop=4
:set softtabstop=4
:set shiftwidth=4
:set shiftround
:set number
:set showcmd
:set showmode
:set linespace=2
" "Regular" backspace behaviour
:set backspace=start,eol,indent
" Incremental search, show matches
:set incsearch
:set showmatch
" F3 toggles search highlight
nnoremap <F3> :set hlsearch!<CR>
" Case insensitive, respect case if caps are typed
:set ignorecase
:set smartcase
" SQL and HTML Syntax inside PHP strings
:let php_sql_query=1
:let php_htmlInStrings=1
:let php_folding=1
:let php_parent_error_close=1
:let php_parent_error_open=1
" Treat phpt, phtml and phps as PHP files
:autocmd BufNewFile,BufRead *.phpt set ft=php
:autocmd BufNewFile,BufRead *.phtml set ft=php
:autocmd BufNewFile,BufRead *.phps set ft=php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment