Split into multiple files

This commit is contained in:
Vasili Svirydau
2017-10-26 11:36:37 -07:00
parent 5071baa987
commit bef25fc946
6 changed files with 313 additions and 300 deletions

58
config/01-plugins.vim Normal file
View File

@@ -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

70
config/02-general.vim Normal file
View File

@@ -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 <leader> 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 <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
"inoremap <up> <nop>
"inoremap <down> <nop>
"inoremap <left> <nop>
"inoremap <right> <nop>
"move up and down within virtual lines
nnoremap j gj
nnoremap k gk
"press jk in quick succession for esc key
imap jk <Esc>
" 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)

36
config/03-mappings.vim Normal file
View File

@@ -0,0 +1,36 @@
"open config with \r
nmap <leader>r :e $MYVIMRC<cr>
nmap <silent><leader>w :up<cr>
imap <silent><leader>w <Esc>:up<cr>a
cmap w!! w !sudo tee % >/dev/null
"Remove search highlight when <Esc> is pressed
nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc>
"toggle whitespace
nmap <leader>l :set list!<cr>
" noremap <silent> <leader>R :! echo reload \| nc -w 1 localhost 32000<cr><cr>
noremap <silent><leader>R :! tmux send-keys -t right "up" C-m<cr><cr>
"press space in normal mode to center screen
nmap <space> zz
nmap <leader>] :bn<cr>
nmap <leader>[ :bp<cr>
nmap <leader>d :bd<cr>
if(exists("g:loaded_ale"))
nmap <leader>e[ <Plug>(ale_previous_wrap)
nmap <leader>e] <Plug>(ale_next_wrap)
endif
let g:tsuquyomi_javascript_support = 1
if(exists("g:loaded_tsuquyomi"))
nmap <leader>p :echo tsuquyomi#hint()<cr>
endif
let g:ctrlp_funky_syntax_highlight = 1
if(exists("g:loaded_ctrlp_funky"))
nnoremap <leader>f :CtrlPFunky<CR>
endif

136
config/04-autocmds.vim Normal file
View File

@@ -0,0 +1,136 @@
if has("autocmd")
filetype plugin indent on
augroup CleanWhitespace
au!
autocmd BufWritePre * :call <SID>StripTrailingWhitespace()
function! <SID>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 <leader>{ :diffget LOCAL<cr>| endif
autocmd filterwritepre * if &diff | map <leader>\| :diffget BASE<cr>| endif
autocmd filterwritepre * if &diff | map <leader>} :diffget REMOTE<cr>| 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("<cword>")
execute "/function ".l:Name
endfun
" autocmd FileType javascript map <leader>jj :set ft=javascript.jsx<cr>
" autocmd BufRead *.js nmap <leader>f* :call JsFunctionLookup()<cr>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 = [
\'<meta> proprietary attribute "property"',
\'<html> proprietary attribute "prefix"',
\'trimming empty <span>',
\'trimming empty <i>',
\'<script> proprietary attribute "integrity"',
\'<link> proprietary attribute "integrity"',
\'<link> proprietary attribute "crossorigin"',
\'<script> proprietary attribute "crossorigin"'
\]
endif
endfunction
augroup END
endif
" Set up CtrlP with faster alternative, if possible
if executable('ag')
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast, respects .gitignore
" and .agignore. Ignores hidden files by default.
let g:ctrlp_user_command = 'ag %s -l --nocolor -f -g ""'
let g:ctrlp_use_caching = 0
else
"ctrl+p ignore files in .gitignore
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
endif
if has("gui_running")
set go-=mTr " disable toolbar, menubar and scrollbar
if has("win32")
set guifont=Source_Code_Pro:h12:cANSI
endif
if has("osx")
set guifont=Source_Code_Pro:h13
endif
else
if(has("mouse"))
set mouse=a
endif
if $TERM_PROGRAM == 'iTerm.app'
" different cursors for insert vs normal mode
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
endif
" Windows-specific setting allowing for 256-colors etc
if($ConEmuANSI == 'ON')
set term=xterm
set t_Co=256
let &t_AB='\e[48;5;%dm' " background color
let &t_AF='\e[38;5;%dm' " foreground color
inoremap <Esc>[62~ <C-X><C-E>
inoremap <Esc>[63~ <C-X><C-Y>
nnoremap <Esc>[62~ <C-E>
nnoremap <Esc>[63~ <C-Y>
endif
endif