From bef25fc946c90adf0b700c1a6dd628d355af4745 Mon Sep 17 00:00:00 2001 From: Vasili Svirydau Date: Thu, 26 Oct 2017 11:36:37 -0700 Subject: [PATCH] Split into multiple files --- .gitignore | 1 + config/01-plugins.vim | 58 ++++++++ config/02-general.vim | 70 +++++++++ config/03-mappings.vim | 36 +++++ config/04-autocmds.vim | 136 ++++++++++++++++++ vimrc | 312 ++--------------------------------------- 6 files changed, 313 insertions(+), 300 deletions(-) create mode 100644 config/01-plugins.vim create mode 100644 config/02-general.vim create mode 100644 config/03-mappings.vim create mode 100644 config/04-autocmds.vim diff --git a/.gitignore b/.gitignore index d4e0431..a4b56ac 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ autoload/plug.vim autoload/plug.vim.old plugged/ +.cache/ diff --git a/config/01-plugins.vim b/config/01-plugins.vim new file mode 100644 index 0000000..a5b55eb --- /dev/null +++ b/config/01-plugins.vim @@ -0,0 +1,58 @@ +let plug_path=expand(vim_files . '/autoload/plug.vim') +let have_plug=filereadable(plug_path) +if(!have_plug && executable('curl')) + echo "Installing Plug" + + execute '!curl -fLo "' . plug_path . '" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + execute 'source ' . plug_path + let have_plug = 1 +endif + +if(have_plug) + call plug#begin(vim_files . '/plugged') + + Plug 'tpope/vim-sensible' " Sensible defaults for vim + Plug 'w0ng/vim-hybrid' " Hybrid colorscheme + Plug 'vim-airline/vim-airline' " Status bar + Plug 'vim-airline/vim-airline-themes' " Status bar themes + Plug 'ivyl/vim-bling' " blink search results + Plug 'ctrlpvim/ctrlp.vim' " Fuzzy search + Plug 'tacahiroy/ctrlp-funky' " Fuzzy in-buffer search + Plug 'tommcdo/vim-lion' " Align stuff + Plug 'tpope/vim-fugitive' " Work with git repos + Plug 'tpope/vim-surround' " Surround with quotes + Plug 'rking/ag.vim' " Silver Searcher Support + Plug 'tpope/vim-commentary' " Commenting + " Plug 'vimwiki/vimwiki' " http://vimwiki.github.io/ + + " Language + if executable('rails') + Plug 'tpope/vim-rails' " Rails integration + endif + Plug 'mattn/emmet-vim' " ZenCoding + Plug 'sheerun/vim-polyglot' " Language Support Bundle + + Plug 'sbdchd/neoformat' " Automatic code formatting + + Plug 'quramy/vim-js-pretty-template' " Syntax highlight inside template strings + Plug 'quramy/tsuquyomi' " Language server support for TypeScript + + " Quality of life + Plug 'edkolev/tmuxline.vim' + + if version >= 800 + Plug 'w0rp/ale' + endif + + if stridx($SHELL, 'fish') >= 0 + Plug 'dag/vim-fish' " Fish Shell Support + endif + + call plug#end() + + if empty(glob(vim_files . '/plugged')) + PlugInstall + endif +endif + + diff --git a/config/02-general.vim b/config/02-general.vim new file mode 100644 index 0000000..9bc1596 --- /dev/null +++ b/config/02-general.vim @@ -0,0 +1,70 @@ +set shortmess=I " turn off splash screen +set hidden " enable multiple dirty buffers +set modelines=0 +set nocompatible +set number " show line numbers +set visualbell +set wildmode=full +set background=dark +silent! colorscheme hybrid +let mapleader = '\' "Set before any key remapping +set hlsearch "highlight search results +set ignorecase "ignore capitalization +set smartcase +set cursorline "highlight current line +set listchars=tab:▸\ ,eol:¬ + "Invisible character colors +highlight NonText guifg=#4a4a59 +highlight SpecialKey guifg=#4a4a59 +"tab settings +set shiftwidth=4 +set tabstop=4 +set expandtab + +set backspace=2 "set sane backspace behaviour + +"No more arrow keys +nnoremap +nnoremap +nnoremap +nnoremap +"inoremap +"inoremap +"inoremap +"inoremap + +"move up and down within virtual lines +nnoremap j gj +nnoremap k gk + +"press jk in quick succession for esc key +imap jk + +" set wildignore+=*/Deploy/*,*/node_modules/*,*/build/*,*/lib/*,*/bower_components/*,*/jspm_packages/* +set completeopt=longest,menu,menuone + +" Stolen from maralla/dotvim +function! EnsureExists(path) + if !isdirectory(expand(a:path)) + call mkdir(expand(a:path)) + endif +endfunction + +" persistent undo +if exists('+undofile') + set undofile + set undodir=~/.vim/.cache/undo +endif + +" backups +set backup +set backupdir=~/.vim/.cache/backup + +" swap files +set directory=~/.vim/.cache/swap +set noswapfile + +call EnsureExists('~/.vim/.cache') +call EnsureExists(&undodir) +call EnsureExists(&backupdir) +call EnsureExists(&directory) diff --git a/config/03-mappings.vim b/config/03-mappings.vim new file mode 100644 index 0000000..6ff95b6 --- /dev/null +++ b/config/03-mappings.vim @@ -0,0 +1,36 @@ +"open config with \r +nmap r :e $MYVIMRC +nmap w :up +imap w :upa +cmap w!! w !sudo tee % >/dev/null + +"Remove search highlight when is pressed +nnoremap :nohlsearch + +"toggle whitespace +nmap l :set list! + +" noremap R :! echo reload \| nc -w 1 localhost 32000 +noremap R :! tmux send-keys -t right "up" C-m + +"press space in normal mode to center screen +nmap zz +nmap ] :bn +nmap [ :bp +nmap d :bd + +if(exists("g:loaded_ale")) + nmap e[ (ale_previous_wrap) + nmap e] (ale_next_wrap) +endif + +let g:tsuquyomi_javascript_support = 1 +if(exists("g:loaded_tsuquyomi")) + nmap p :echo tsuquyomi#hint() +endif + +let g:ctrlp_funky_syntax_highlight = 1 +if(exists("g:loaded_ctrlp_funky")) + nnoremap f :CtrlPFunky +endif + diff --git a/config/04-autocmds.vim b/config/04-autocmds.vim new file mode 100644 index 0000000..b56c67e --- /dev/null +++ b/config/04-autocmds.vim @@ -0,0 +1,136 @@ + if has("autocmd") + filetype plugin indent on + + augroup CleanWhitespace + au! + autocmd BufWritePre * :call StripTrailingWhitespace() + function! StripTrailingWhitespace() + let pos = getpos('.') + %s/\s\+$//e + call setpos('.', pos) + endfun + augroup END + + augroup InsertTimer + au! + "Autoexit to normal mode after 15 seconds of inactivity + autocmd CursorHoldI * stopinsert + autocmd InsertEnter * let updaterestore=&updatetime | set updatetime=15000 + autocmd InsertLeave * let &updatetime=updaterestore + augroup END + + augroup vimrc + "Automatically reload VIMRC file after saving + au! + autocmd bufwritepost $MYVIMRC source $MYVIMRC + if (exists('g:loaded_airline') && g:loaded_airline) + autocmd bufwritepost $MYVIMRC AirlineRefresh + endif + augroup END + + augroup diffmode + au! + " Mappings for diff mode + autocmd filterwritepre * if &diff | map { :diffget LOCAL| endif + autocmd filterwritepre * if &diff | map \| :diffget BASE| endif + autocmd filterwritepre * if &diff | map } :diffget REMOTE| endif + augroup END + + augroup javascript + "Custom mappings + au! + autocmd FileType javascript set ai sw=2 sts=2 et + + "Javascript Function lookup + function! JsFunctionLookup() + let l:Name = expand("") + execute "/function ".l:Name + endfun + + " autocmd FileType javascript map jj :set ft=javascript.jsx + " autocmd BufRead *.js nmap f* :call JsFunctionLookup()zz + " autocmd BufRead *.js,*.jsx let g:syntastic_javascript_checkers = ['eslint'] + " autocmd BufWritePre *.js Neoformat + let g:neoformat_javascript_prettier = { + \ 'exe' : 'prettier', + \ 'args': ['--stdin', '--trailing-comma=es5', '--single-quote'], + \ 'stdin': 1 + \ } + augroup END + + augroup ruby + au! + autocmd FileType ruby,haml,eruby,yaml,html,sass,cucumber,slim set ai sw=2 sts=2 et + autocmd BufRead *.rb let g:syntastic_ruby_checkers = ['rubocop', 'mri'] + autocmd BufRead *.rb let g:syntastic_ruby_rubocop_exec = '/usr/bin/rubocop' + augroup END + + augroup html + au! + au BufNewFile,BufRead *.ejs set filetype=html + autocmd FileType html call SetHtmlOptions() + function! SetHtmlOptions() + if(executable('tidy')) + let g:syntastic_html_tidy_ignore_errors = [ + \' proprietary attribute "property"', + \' proprietary attribute "prefix"', + \'trimming empty ', + \'trimming empty ', + \'