Last active
April 17, 2019 10:12
-
-
Save felipecwb/e4bb0058a9b255dfb736 to your computer and use it in GitHub Desktop.
My vimrc!
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
| "******************************************* | |
| "****** Felipe Francisco - @felipecwb ****** | |
| "****** https://github.com/felipecwb ****** | |
| "******************************************* | |
| "" Vim-PLug core | |
| "***************************************************************************** | |
| if has('vim_starting') | |
| set nocompatible " Be iMproved | |
| endif | |
| let vimplug_exists=expand('~/.vim/autoload/plug.vim') | |
| if ! filereadable(vimplug_exists) | |
| if ! executable("curl") | |
| echoerr "You have to install curl or first install vim-plug yourself!" | |
| execute "q!" | |
| endif | |
| echo "Installing Vim-Plug..." | |
| echo "" | |
| silent !\curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
| let g:not_finish_vimplug = "yes" | |
| autocmd VimEnter * PlugInstall | |
| endif | |
| " Required: | |
| call plug#begin(expand('~/.vim/plugged')) | |
| "***************************************************************************** | |
| "" Plug install packages | |
| "***************************************************************************** | |
| Plug 'scrooloose/nerdtree' | |
| Plug 'majutsushi/tagbar' | |
| Plug 'mhinz/vim-startify' | |
| Plug 'vim-airline/vim-airline' | |
| Plug 'sheerun/vim-polyglot' | |
| Plug 'Yggdroot/indentLine' | |
| Plug 'vim-scripts/grep.vim' | |
| Plug 'tpope/vim-commentary' | |
| Plug 'terryma/vim-multiple-cursors' | |
| Plug 'bronson/vim-trailing-whitespace' | |
| Plug 'ryanoasis/vim-devicons' | |
| Plug 'kaicataldo/material.vim' "theme | |
| Plug 'tpope/vim-fugitive' | |
| "Plug 'airblade/vim-gitgutter' | |
| Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
| Plug 'junegunn/fzf.vim' | |
| Plug 'scrooloose/syntastic' | |
| Plug 'jsfaint/gen_tags.vim' | |
| "" completitions | |
| " vim8: Plug 'Shougo/deoplete.nvim' Plug 'roxma/nvim-yarp' Plug 'roxma/vim-hug-neovim-rpc' | |
| Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
| Plug 'zchee/deoplete-clang' | |
| Plug 'zchee/deoplete-jedi' | |
| Plug 'padawan-php/deoplete-padawan', { 'do': 'composer install' } | |
| Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install -g tern' } | |
| " nvim-qt functions | |
| Plug 'equalsraf/neovim-gui-shim' | |
| "***************************************************************************** | |
| call plug#end() | |
| " Required: | |
| filetype plugin indent on | |
| "***************************************************************************** | |
| "" Basic Setup | |
| "*****************************************************************************" | |
| "" Encoding | |
| set encoding=UTF-8 | |
| set fileencoding=UTF-8 | |
| set fileencodings=UTF-8 | |
| set bomb | |
| set binary | |
| set fileformats=unix,dos,mac | |
| set ttyfast | |
| "" auto reload | |
| set autoread | |
| "" Fix backspace indent | |
| set backspace=indent,eol,start | |
| "" Tabs. May be overriten by autocmd rules | |
| set tabstop=4 | |
| set softtabstop=0 | |
| set shiftwidth=4 | |
| set expandtab | |
| "" Map leader to , | |
| let mapleader=',' | |
| "" Enable hidden buffers | |
| set hidden | |
| "" Searching | |
| set hlsearch | |
| set incsearch | |
| set ignorecase | |
| set smartcase | |
| set magic | |
| "" Directories for swp files | |
| set nobackup | |
| set noswapfile | |
| set dir=~/.vim/swap//,/var/tmp//,/tmp//,. | |
| set tags=~/.vim/tag//,/var/tmp//,/tmp//, | |
| if exists('$SHELL') | |
| set shell=$SHELL | |
| else | |
| set shell=/bin/sh | |
| endif | |
| set wildmode=list:longest,list:full | |
| set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__ | |
| "***************************************************************************** | |
| "" Visual Settings | |
| "***************************************************************************** | |
| """ Theme | |
| set background=dark | |
| colorscheme material | |
| let g:material_theme_style = 'default' "default, palenight, dark | |
| let g:material_terminal_italics = 1 | |
| let g:airline_theme = 'material' | |
| let g:indentLine_enabled = 1 | |
| """ Theme | |
| syntax on | |
| set number | |
| set nowrap | |
| set showmatch | |
| set list | |
| set listchars=tab:▸→,extends:❯,precedes:❮,trail:· | |
| set showbreak=↪ | |
| set showcmd | |
| set ruler | |
| set termguicolors | |
| set mouse=a | |
| set mousemodel=popup | |
| set t_Co=256 | |
| set guioptions=egmrti | |
| set guifont=Noto\ Mono\ for\ Powerline | |
| "" Disable the blinking cursor. | |
| set gcr=a:blinkon0 | |
| set scrolloff=0 | |
| set sidescroll=1 | |
| "" Status bar | |
| set laststatus=2 | |
| "" Use modeline overrides | |
| set modeline | |
| set modelines=10 | |
| set title | |
| set titleold="Terminal" | |
| set titlestring=%F | |
| set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\ | |
| " Search mappings: These will make it so that going to the next one in a | |
| " search will center on the line it's found in. | |
| nnoremap n nzzzv | |
| nnoremap N Nzzzv | |
| if exists("*fugitive#statusline") | |
| set statusline+=%{fugitive#statusline()} | |
| endif | |
| " vim-airline | |
| "let g:airline_theme = 'dark' | |
| let g:airline_powerline_fonts = 1 | |
| let g:airline#extensions#syntastic#enabled = 1 | |
| let g:airline#extensions#branch#enabled = 1 | |
| let g:airline#extensions#tabline#enabled = 1 | |
| let g:airline#extensions#tagbar#enabled = 1 | |
| let g:airline_skip_empty_sections = 1 | |
| "***************************************************************************** | |
| "" Abbreviations | |
| "***************************************************************************** | |
| "" no one is really happy until you have this shortcuts | |
| cnoreabbrev W! w! | |
| cnoreabbrev Q! q! | |
| cnoreabbrev Qa! qa! | |
| cnoreabbrev Qall! qall! | |
| cnoreabbrev Wq wq | |
| cnoreabbrev Wa wa | |
| cnoreabbrev wQ wq | |
| cnoreabbrev WQ wq | |
| cnoreabbrev W w | |
| cnoreabbrev Q q | |
| cnoreabbrev Qa qa | |
| "" NERDTree configuration | |
| let g:NERDTreeIgnore = ['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__'] | |
| let g:NERDTreeSortOrder = ['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$'] | |
| let g:NERDTreeChDirMode = 2 | |
| let g:NERDTreeMinimalUI = 1 | |
| let g:NERDTreeShowBookmarks = 1 | |
| let g:NERDTreeHighlightCursorline = 1 | |
| let g:nerdtree_tabs_focus_on_files = 1 | |
| "let g:NERDTreeMapOpenInTabSilent = '<RightMouse>' | |
| let g:NERDTreeShowHidden = 1 | |
| let g:NERDTreeWinSize = 45 | |
| set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite | |
| nnoremap <silent> <A-E> :NERDTreeFind<CR> | |
| noremap <A-e> :NERDTreeToggle<CR> | |
| " grep.vim | |
| nnoremap <silent> <A-f> :Rgrep<CR> | |
| let Grep_Default_Options = '-IR' | |
| let Grep_Skip_Files = '*.log *.db' | |
| let Grep_Skip_Dirs = '.git node_modules' | |
| " terminal emulation | |
| nnoremap <silent> <leader>sh :terminal<CR> | |
| "***************************************************************************** | |
| "" Functions | |
| "***************************************************************************** | |
| if ! exists('*s:setupWrapping') | |
| function s:setupWrapping() | |
| set wrap | |
| set wm=2 | |
| set textwidth=79 | |
| endfunction | |
| endif | |
| " When open a binary file | |
| function! OpenBinary() | |
| silent execute('!xdg-open ' . fnameescape(expand('<afile>'))) | |
| bdelete | |
| endfunction | |
| " Don't close window, when deleting a buffer | |
| function! <SID>BufcloseCloseIt() | |
| let l:currentBufNum = bufnr("%") | |
| let l:alternateBufNum = bufnr("#") | |
| if buflisted(l:alternateBufNum) | |
| buffer # | |
| else | |
| bnext | |
| endif | |
| if bufnr("%") == l:currentBufNum | |
| new | |
| endif | |
| if buflisted(l:currentBufNum) | |
| execute("bdelete!" . l:currentBufNum) | |
| endif | |
| endfunction | |
| "***************************************************************************** | |
| "" Autocmd Rules | |
| "***************************************************************************** | |
| "" The PC is fast enough, do syntax highlight syncing from start unless 200 lines | |
| augroup vimrc-sync-fromstart | |
| autocmd! | |
| autocmd BufEnter * :syntax sync maxlines=200 | |
| augroup END | |
| "" Remember cursor position | |
| augroup vimrc-remember-cursor-position | |
| autocmd! | |
| autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif | |
| augroup END | |
| "" txt | |
| augroup vimrc-wrapping | |
| autocmd! | |
| autocmd BufRead,BufNewFile *.txt call s:setupWrapping() | |
| augroup END | |
| "" make/cmake | |
| augroup vimrc-make-cmake | |
| autocmd! | |
| autocmd FileType make setlocal noexpandtab | |
| autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake | |
| augroup END | |
| "" force checktime for reaload | |
| autocmd FocusGained * :checktime | |
| "" open a binary file in list | |
| autocmd BufEnter *.{jpg,jpeg,png,gif,ico,pdf} :call OpenBinary() | |
| "" avoid close vim whem close a buffer | |
| command! Bclose call <SID>BufcloseCloseIt() | |
| "***************************************************************************** | |
| "" Mappings | |
| "***************************************************************************** | |
| " close windows | |
| "if has("gui_running") | |
| nnoremap <C-q> <C-w>c | |
| "endif | |
| "" Opens an edit command with the path of the currently edited file filled in | |
| noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR> | |
| "" Split | |
| noremap <Leader>h :split<CR> | |
| noremap <Leader>v :vsplit<CR> | |
| "" Tabs | |
| nnoremap <silent> <Leader>t :tabnew<CR> | |
| " The Silver Searcher - Ag | |
| if executable('ag') | |
| set grepprg=ag\ --nogroup\ --nocolor | |
| let $FZF_DEFAULT_COMMAND = 'ag -U --nocolor --hidden --ignore .git -g ""' | |
| nnoremap fd :grep! --hidden --ignore .git "\b<C-r><C-w>\b"<CR>:cw<CR><CR> | |
| nnoremap fD :grep! -U --hidden --ignore .git "\b<C-r><C-w>\b"<CR>:cw<CR><CR> | |
| nnoremap fip :grep! -U --hidden --ignore .git '<C-r><C-w>' <C-R>=expand("%:h") . "/" <CR> | |
| endif | |
| " files and buffers | |
| nnoremap <silent> <C-p> :Files<CR> | |
| nnoremap <silent> <A-g> :Buffers<CR> | |
| "visual mode pressing * or # searches for the current selection | |
| vnoremap <silent> * :call visualselection('f')<cr> | |
| vnoremap <silent> # :call visualselection('b')<cr> | |
| " Tagbar | |
| nmap <silent> <A-t> :TagbarToggle<CR> | |
| let g:tagbar_autofocus = 1 | |
| " Disable visualbell | |
| set noerrorbells visualbell t_vb= | |
| if has('autocmd') | |
| autocmd GUIEnter * set visualbell t_vb= | |
| endif | |
| "" Copy/Paste/Cut | |
| if has('unnamedplus') | |
| set clipboard=unnamed,unnamedplus | |
| endif | |
| " select all | |
| nmap <A-a> ggVG | |
| imap <A-a> <Esc>ggVG | |
| " cut | |
| "nnoremap <A-x> Vx | |
| "vnoremap <A-x> x | |
| " yank to os's clipboard | |
| vmap yo "+y | |
| vnoremap <A-c> "+y | |
| "paste from os's clipboard | |
| nmap po "+p | |
| inoremap <A-v> <Esc>"+pli | |
| nnoremap <A-v> "+Pl | |
| vmap <A-v> "+Pgv"+y | |
| "vmap duplicate lines | |
| vnoremap <C-d> "1y"1P | |
| nnoremap <C-d> "1Y"1P | |
| inoremap <C-d> <Esc>"1Y"1Pji | |
| " C-S-Direction selection | |
| nnoremap <C-S-Left> vb | |
| nnoremap <C-S-Right> ve | |
| inoremap <C-S-Left> <Esc>vb | |
| inoremap <C-S-Right> <Esc>ve | |
| "" registers | |
| "delete | |
| nnoremap d "_d | |
| nnoremap D "_D | |
| vnoremap d "_d | |
| vnoremap D "_D | |
| nnoremap <leader>d "+d | |
| nnoremap <leader>D "+D | |
| vnoremap <leader>d "+d | |
| vnoremap <leader>D "+D | |
| "substitute | |
| nnoremap s "_s | |
| nnoremap S "_S | |
| vnoremap s "_s | |
| vnoremap S "_S | |
| nnoremap <leader>s "+s | |
| nnoremap <leader>S "+S | |
| vnoremap <leader>s "+s | |
| vnoremap <leader>S "+S | |
| "" Buffer swap | |
| noremap <A-z> :bp<CR> | |
| noremap <A-x> :bn<CR> | |
| noremap <A-q> :Bclose<CR> | |
| noremap <C-S-Tab> :bp<CR> | |
| noremap <C-Tab> :bn<CR> | |
| noremap <C-Del> :Bclose<CR> | |
| "" Clean search (highlight) | |
| nnoremap <silent> <S-space> :noh<cr> | |
| "" Switching windows | |
| noremap <C-j> <C-w>j | |
| noremap <C-k> <C-w>k | |
| noremap <C-l> <C-w>l | |
| noremap <C-h> <C-w>h | |
| noremap <C-Down> <C-w>j | |
| noremap <C-Up> <C-w>k | |
| noremap <C-Right> <C-w>l | |
| noremap <C-Left> <C-w>h | |
| "" Vmap for maintain Visual Mode after shifting > and < | |
| vnoremap < <gv | |
| vnoremap > >gv | |
| vnoremap <S-Tab> <gv | |
| nnoremap <S-Tab> << | |
| nnoremap <Tab> >> | |
| inoremap <S-Tab> <BS> | |
| "" Move visual block | |
| vnoremap <S-Down> :'<,'>m '>+1<CR>gv | |
| vnoremap <S-Up> :'<,'>m '<-2<CR>gv | |
| inoremap <S-Down> <Esc>:m +1<CR>i | |
| inoremap <S-up> <esc>:m -2<cr>i | |
| nnoremap <S-down> :m +1<cr> | |
| nnoremap <S-Up> :m -2<CR> | |
| " completion | |
| inoremap <silent> <C-Space> <C-x><C-o> | |
| nnoremap <silent> <C-Space> i<C-x><C-o> | |
| "***************************************************************************** | |
| "" Custom configs | |
| "***************************************************************************** | |
| " c | |
| autocmd FileType c setlocal tabstop=4 shiftwidth=4 expandtab | |
| autocmd FileType cpp setlocal tabstop=4 shiftwidth=4 expandtab | |
| " go | |
| let g:syntastic_go_checkers = ['golint', 'govet'] | |
| let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] } | |
| autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 | |
| " markdown | |
| autocmd FileType markdown setlocal conceallevel=0 | |
| " php | |
| autocmd FileType php,python setlocal expandtab ts=4 sw=4 softtabstop=4 | |
| " for html files, 2 spaces | |
| " html, twig, blade, css, javascript, yaml | |
| autocmd FileType html,twig,html.twig,blade,css,javascript,yaml setlocal expandtab ts=2 sw=2 softtabstop=2 | |
| let g:syntastic_html_checkers=[''] | |
| " javascript | |
| let g:javascript_enable_domhtmlcss = 1 | |
| augroup vimrc-javascript | |
| autocmd! | |
| autocmd FileType javascript set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2 | |
| augroup END | |
| " python | |
| " vim-python | |
| augroup vimrc-python | |
| autocmd! | |
| autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=4 colorcolumn=80 | |
| \ formatoptions+=croq softtabstop=4 | |
| \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with | |
| augroup END | |
| " syntastic | |
| let g:syntastic_python_checkers=['python', 'flake8'] | |
| let g:syntastic_python_flake8_args='--ignore=E501' | |
| " vim-airline | |
| let g:airline#extensions#virtualenv#enabled = 1 | |
| " Syntax highlight | |
| " Default highlight is better than polyglot | |
| let g:polyglot_disabled = ['python'] | |
| let python_highlight_all = 1 | |
| "***************************************************************************** | |
| "" Convenience variables | |
| "***************************************************************************** | |
| " syntastic | |
| let g:syntastic_always_populate_loc_list=1 | |
| let g:syntastic_error_symbol='✗' | |
| let g:syntastic_warning_symbol='⚠' | |
| let g:syntastic_style_error_symbol = '✗' | |
| let g:syntastic_style_warning_symbol = '⚠' | |
| let g:syntastic_auto_loc_list=1 | |
| let g:syntastic_loc_list_height=5 | |
| let g:syntastic_aggregate_errors = 1 | |
| " deopplete | |
| let g:deoplete#enable_at_startup = 1 | |
| let g:deoplete#sources#padawan#server_addr = 'http://127.0.0.1:15155' | |
| let g:deoplete#sources#padawan#server_command = '.vim/plugged/deoplete-padawan/vendor/mkusher/padawan/bin/padawan-server' | |
| " neovim python | |
| let g:python_host_prog = '/usr/bin/python2' | |
| let g:python3_host_prog = '/usr/bin/python3' | |
| " vim-airline | |
| if !exists('g:airline_symbols') | |
| let g:airline_symbols = {} | |
| endif | |
| " powerline symbols | |
| let g:airline#extensions#tabline#left_sep = '' | |
| let g:airline#extensions#tabline#left_alt_sep = '' | |
| let g:airline#extensions#linecolumn#prefix = '¶' | |
| let g:airline#extensions#paste#symbol = 'ρ' | |
| let g:airline_left_sep = '' | |
| let g:airline_left_alt_sep = '' | |
| let g:airline_right_sep = '' | |
| let g:airline_right_alt_sep = '' | |
| let g:airline_symbols.branch = '' | |
| let g:airline_symbols.readonly = '' | |
| let g:airline_symbols.linenr = '' | |
| let g:airline_symbols.paste = '∥' | |
| let g:airline_symbols.whitespace = 'Ξ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment