diff --git a/vim/autoload/.keep b/vim/autoload/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/vim/backup/.keep b/vim/backup/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/vim/ftplugin/json.vim b/vim/ftplugin/json.vim new file mode 100644 index 0000000..01b6efa --- /dev/null +++ b/vim/ftplugin/json.vim @@ -0,0 +1,2 @@ +com! FormatJSON :%!python3 -m json.tool +map = :FormatJSON diff --git a/vim/ftplugin/xml.vim b/vim/ftplugin/xml.vim new file mode 100644 index 0000000..8797759 --- /dev/null +++ b/vim/ftplugin/xml.vim @@ -0,0 +1,6 @@ +let b:ale_fixers = ['xmllint'] +let b:ale_fix_on_save = 0 + +let g:xml_syntax_folding=1 +setlocal foldmethod=syntax +autocmd Syntax xml,html,xhtml normal zR diff --git a/vim/makefile b/vim/makefile index 8d2e246..cac44b9 100644 --- a/vim/makefile +++ b/vim/makefile @@ -10,8 +10,13 @@ install: | init update init: if (( $$+commands[vim] )) ; then $(report) header "Setting up vim" - $(mk_link) $(SRC_DIR) $(TARGET_DIR) + mkdir -p $(TARGET_DIR) $(mk_link) $(SRC_DIR)/vimrc ~/.vimrc + $(mk_link) $(SRC_DIR)/vimrc.d $(TARGET_DIR)/vimrc.d + $(mk_link) $(SRC_DIR)/spell $(TARGET_DIR)/spell + ( mkdir -p $(TARGET_DIR)/backup \ + && chmod 700 $(TARGET_DIR)/backup ) \ + ; $(report) "setting up backup dir" else $(report) warn "cannot find vim?" fi @@ -21,7 +26,7 @@ update: $(report) header "Upgrading vim" curl -fsLo $(PLUG_PATH) $(PLUG_URL) \ ; $(report) "vim plug setup" - vim +PlugInstall +PlugUpdate +qall \ + vim +PlugInstall +PlugUpdate +PlugClean +qall \ ; $(report) "downloading/updating plugins" stty sane # dropping in & out causes some weird tty behavior. else diff --git a/vim/spell/en.utf-8.add b/vim/spell/en.utf-8.add index 9d2c629..0e9f695 100644 --- a/vim/spell/en.utf-8.add +++ b/vim/spell/en.utf-8.add @@ -1,21 +1,21 @@ -off -env -Ctrl -zsh -dotfiles CoffeeScript -Haml -ctag Ctags -mkdir -tmux -hostname -rebase -rebases -ctags -config -zsh -backend +Ctrl +GreenFiling +Haml SES Tybera -GreenFiling +backend +config +ctag +ctags +dotfiles +env +hostname +mkdir +off +rebase +rebases +tmux +zsh +zsh diff --git a/vim/vimrc b/vim/vimrc index a55218b..2f9b7de 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1,7 +1,147 @@ -source ~/.vim/vimrc.d/base.vim -source ~/.vim/vimrc.d/plugins.vim -source ~/.vim/vimrc.d/ui.vim -source ~/.vim/vimrc.d/keybind.vim +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Sections: +" -> Plug Setup +" -> Brief Config +" -> Plugs & Configure +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" PlugSetup: +" -> Auto Install Plug +" -> Auto Add Missing Plugs +" -> Add Conditional Helper +" -> Has Async + +" Install vim-plug if not found +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +endif + +" Run PlugInstall if there are missing plugins +autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + \| PlugInstall --sync | source $MYVIMRC +\| endif + +" Convenience function for arbitrary conditional loading +" See https://github.com/junegunn/vim-plug/wiki/tips#conditional-activation for more. +function! Cond(cond, ...) + let opts = get(a:000, 0, {}) + return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) +endfunction + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Brief Config: +" -> Sane Config Base +" -> Leader Key +" -> Has Async Var + +" Sane Config Based on Tpope's Vim-Sensible +" https://github.com/tpope/vim-sensible +source ~/.vim/vimrc.d/sensible.vim + +" Take me to your leader +let mapleader="," + +" Added Async Var +let g:has_async = v:version >= 800 || has('nvim') + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Plugs_Configure: +" -> Molokai Theme +" -> Deoplete Completion Framework +" -> Git Gutter +" -> Rainbow Parens +" -> Auto Pair +" -> Vim Surround +" -> Vim Airline +" -> Vim Eunuch +" -> Nerdtree +" -> Incsearch +" -> EasyMotion +" -> Incsearch + EasyMotion +" -> Fzf +" -> ALE + +call plug#begin('~/.vim/plugged') + +" Theme +Plug 'tomasr/molokai' + autocmd VimEnter * colorscheme molokai + hi LineNr ctermfg=245 ctermbg=235 + let g:molokai_original=1 + let g:rehash256=1 + match ErrorMsg '\%>120v.\+' + match ErrorMsg '\s\+$' + +" Deoplete : Fancy vim8+/nvim autocomplete framework +if (has('python3') || has('nvim')) + Plug 'Shougo/deoplete.nvim' + " completion source + Plug 'Shougo/neco-syntax' + " running on non-nvim instances requires the following + " See https://github.com/Shougo/deoplete.nvim#install for more + Plug 'roxma/nvim-yarp', Cond(! has('nvim')) + Plug 'roxma/vim-hug-neovim-rpc', Cond(! has('nvim')) + let g:deoplete#enable_at_startup=1 +endif + +" GitGutter : Letting you know whats changed +Plug 'airblade/vim-gitgutter' + +" Rainbow Parens : making at color term more useful +Plug 'kien/rainbow_parentheses.vim' + +" Auto Pair : Vim plugin, insert or delete brackets, parens, quotes in pair +Plug 'jiangmiao/auto-pairs' + +" Vim Surround : quoting/parenthesizing made simple +Plug 'tpope/vim-surround' + +" Vim Airline : Modeline support +Plug 'vim-airline/vim-airline' + +" Vim Eunuch : Helpers for UNIX +Plug 'tpope/vim-eunuch' + +" Nerdtree : A tree explorer plugin for vim. +Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } + +" Incsearch : Improved incremental searching for Vim +Plug 'haya14busa/incsearch.vim' + +" EasyMotion : Vim motions on speed! +Plug 'easymotion/vim-easymotion' + let g:EasyMotion_smartcase = 1 + map f (easymotion-bd-f2) + nmap f (easymotion-overwin-f2) + +" Incsearch & EasyMotion : peanut butter & chocolate +Plug 'haya14busa/incsearch-easymotion.vim' + map / (incsearch-easymotion-/) + map ? (incsearch-easymotion-?) + map g/ (incsearch-easymotion-stay) + +" FZF : Fuzzy was he found +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' + let g:fzf_layout = { 'down': '40%' } + map :History + map b :Buffers + +" ALE : Asynchronous Lint Engine +Plug 'dense-analysis/ale', Cond(g:has_async) + if g:has_async + map = :ALEFix + endif + let g:ale_fixers = {'*': ['remove_trailing_lines', 'trim_whitespace']} + let g:ale_fix_on_save = 1 + let g:ale_completion_enabled = 1 + +call plug#end() " vim: set filetype=vim: " -*- mode: vim -*- diff --git a/vim/vimrc.d/base.vim b/vim/vimrc.d/base.vim deleted file mode 100644 index 1871074..0000000 --- a/vim/vimrc.d/base.vim +++ /dev/null @@ -1,72 +0,0 @@ -set go= -set t_Co=256 - -syntax on -filetype plugin indent on -set encoding=utf-8 -set hidden -set showcmd -set nowrap -set backspace=indent,eol,start -set autoindent -set number -set shiftround -set ignorecase -set smartcase -set hlsearch -set incsearch -set history=1000 -set undolevels=1000 -set title -set noerrorbells -set list -set listchars=tab:>>,trail:.,extends:>,precedes:<,nbsp:. -set ttyfast -set mouse=a -set nocompatible -set backup -set noswapfile -set backupdir=~/.vim/backup -set laststatus=2 -set fileformats=unix,dos,mac -set expandtab -set softtabstop=2 tabstop=2 shiftwidth=2 -set ruler -set cursorline -set cuc cul -set wildmenu -set lazyredraw -set showmatch " highlight matching [{()}] -set wildignore=*.swp,*.bak -set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/* -set wildmode=longest,list:full -set linebreak -set nolist " list disables linebreak - -set omnifunc=syntaxcomplete#Complete -set dictionary=/usr/share/dict/words - -" The Silver Searcher -if executable('ag') - set grepprg=ag\ --nogroup\ --nocolor -endif - - -if v:version > 702 && has('patch541') - set formatoptions+=j -endif - -let g:has_async = v:version >= 800 || has('nvim') - -"" Toggle relative/absolute numbering -function! NumberToggle() - if(&relativenumber == 1) - set number - else - set relativenumber - endif -endfunc - -"" -com! FormatJson :%!python3 -m json.tool -com! FormatXML :%!python3 -c "import xml.dom.minidom, sys; print(xml.dom.minidom.parse(sys.stdin).toprettyxml())" diff --git a/vim/vimrc.d/keybind.vim b/vim/vimrc.d/keybind.vim deleted file mode 100644 index 7180782..0000000 --- a/vim/vimrc.d/keybind.vim +++ /dev/null @@ -1,93 +0,0 @@ -"" Keybinds - -let mapleader="," - -"" Kill -nnoremap kb :BD - -"" Toggles : t for toggle -" Toggle PasteMode -nnoremap tp :set invpaste paste? -" Toggle wordwrap -nnoremap tw :set wrap! -" Toggle Git Gutter :: Requires GitGutter -nnoremap tg :GitGutterToggle -" Toggle Indent :: Requires Yggdroot/indentLine -nnoremap ti :IndentLinesToggle -" Tooggle Spell Check -nnoremap ts :setlocal spell! spelllang=en -" Toggle Relative Numbers -nnoremap t# :call NumberToggle() -" Toggle Syntastic :: Requires scrooloose/syntastic -nnoremap tc :SyntasticToggleMode - -" Keybind ri -nnoremap ri :call ri#OpenSearchPrompt(0) " horizontal split" -nnoremap rk :call ri#LookupNameUnderCursor() " keyword lookup" - -" vim-test mappings : T for Testing -nnoremap Tt :TestFile -nnoremap Ts :TestNearest -nnoremap Tl :TestLast -nnoremap Ta :TestSuite -nnoremap Tgt :TestVisit - -" Enter for Nerd :: Requires Nerdtree -map :NERDTreeToggle - -" Sudo Save :: Requires tpope/vim-eunuch -nnoremap W :SudoWrite - -" Quick Format : f for Format -nnoremap fi :normal migg=G`i` -nnoremap fw :FixWhitespace -vnoremap ft :Tabularize / -nnoremap fT :Tabularize /\zs - -" Set File Type Use : F for Filetype -nnoremap Fm :set filetype=markdown -nnoremap Fv :set filetype=vim -nnoremap Frb :set filetype=ruby - -" Tagbar -nmap :TagbarToggle - -" CTRL-P -map :CtrlPMRU -nnoremap b :CtrlPBuffer - -" Better Search :: Requires haya14busa/incsearch.vim -map / (incsearch-forward) -map ? (incsearch-backward) -map g/ (incsearch-stay) - -nnoremap : - -" Better Subsitute :: Requires osyo-manga/vim-over -nnoremap s :OverCommandLine %s/ - -" Format XML -map @@x :%s/<\([^>]\)*>/\r&\r/g:g/^$/dvat= - -" Switch windows with shift + jikl -nnoremap :wincmd l -nnoremap :wincmd j -nnoremap :wincmd h -nnoremap :wincmd k - -" Line Switch -nnoremap :m .+1== -nnoremap :m .-2== -vnoremap :m '>+1gv=gv -vnoremap :m '<-2gv=gv - -" Plug Stuff -nnoremap pi :PlugInstall -nnoremap pu :PlugUpdate -nnoremap ps :PlugStatus - -" UltiSnips -let g:UltiSnipsExpandTrigger="" -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="" -imap pumvisible() ? "\=UltiSnips#ExpandSnippet()" : "\=UltiSnips#ExpandSnippet()" diff --git a/vim/vimrc.d/plugins.vim b/vim/vimrc.d/plugins.vim deleted file mode 100644 index f7b19a7..0000000 --- a/vim/vimrc.d/plugins.vim +++ /dev/null @@ -1,107 +0,0 @@ -" ============================================================================== -" PLUGINS -" This -filetype off - -"" automatically install new plugs -if empty(glob('~/.vim/autoload/plug.vim')) - silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -"" Start Vim-Plug -call plug#begin('~/.vim/plugged') - -"" Cond loading -function! Cond(cond, ...) - let opts = get(a:000, 0, {}) - return a:cond ? opts : extend(opts, { 'on': [],'for': [] }) -endfunction - -" Themes -Plug 'kamwitsta/flatwhite-vim' -Plug 'tomasr/molokai' - -" Extensions -Plug 'Shougo/deoplete.nvim' , Cond(g:has_async, { 'on': [] }) -Plug 'Shougo/neco-vim' , {'for' : 'vim'} -Plug 'Shougo/neocomplete.vim' , Cond(!g:has_async, { 'on': [] }) -Plug 'Shougo/vimproc.vim' , {'do' : 'make'} -Plug 'Yggdroot/indentLine' -Plug 'airblade/vim-gitgutter' -Plug 'bronson/vim-trailing-whitespace' -Plug 'godlygeek/tabular' -Plug 'haya14busa/incsearch.vim' -Plug 'honza/vim-snippets' -Plug 'janko-m/vim-test' -Plug 'jiangmiao/auto-pairs' -Plug 'jpalardy/vim-slime' -Plug 'kien/ctrlp.vim' -Plug 'kien/rainbow_parentheses.vim' -Plug 'majutsushi/tagbar' -Plug 'osyo-manga/vim-over' -Plug 'qpkorr/vim-bufkill' , {'on': 'BD'} -Plug 'rizzatti/dash.vim' -Plug 'roxma/nvim-yarp' , Cond(g:has_async) -Plug 'roxma/vim-hug-neovim-rpc' , Cond(g:has_async) -Plug 'scrooloose/nerdcommenter' -Plug 'scrooloose/nerdtree' , { 'on': 'NERDTreeToggle' } -Plug 'scrooloose/syntastic' , Cond(!g:has_async) -Plug 'tpope/vim-eunuch' -Plug 'tpope/vim-markdown' , {'for' : 'markdown'} -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'w0rp/ale' , Cond(g:has_async) - -for fpath in split(globpath('~/.vim/plug.d/', '*.vim'), '\n') - exe 'source' fpath -endfor - -" CTRL-P - let g:ctrlp_cmd = 'CtrlPMixed' - let g:ctrlp_working_path_mode = 'ra' - if executable('ag') - let g:ctrlp_user_command = 'ag -Q -l --nocolor --hidden -g "" %s' - endif - -" VIM-AIRPLAINE - let g:airline_powerline_fonts = 1 - if !exists('g:airline_symbols') - let g:airline_symbols = {} - endif - let g:airline#extensions#tabline#enabled = 1 - let g:airline#extensions#tabline#left_sep = ' ' - let g:airline#extensions#tabline#left_alt_sep = '|' - let g:airline_theme = 'powerlineish' - set laststatus=2 - set ttimeoutlen=50 - -" RAINBOW_PARENTHESE - let g:rbpt_colorpairs = [ - \ ['brown', 'RoyalBlue3'], - \ ['Darkblue', 'SeaGreen3'], - \ ['darkgray', 'DarkOrchid3'], - \ ['darkgreen', 'firebrick3'], - \ ['darkcyan', 'RoyalBlue3'], - \ ['darkred', 'SeaGreen3'], - \ ['darkmagenta', 'DarkOrchid3'], - \ ['brown', 'firebrick3'], - \ ['gray', 'RoyalBlue3'], - \ ['black', 'SeaGreen3'], - \ ['darkmagenta', 'DarkOrchid3'], - \ ['Darkblue', 'firebrick3'], - \ ['darkgreen', 'RoyalBlue3'], - \ ['darkcyan', 'SeaGreen3'], - \ ['darkred', 'DarkOrchid3'], - \ ['red', 'firebrick3'], - \ ] - let g:rbpt_max = 16 - au VimEnter * RainbowParenthesesToggle - au Syntax * RainbowParenthesesLoadRound - au Syntax * RainbowParenthesesLoadSquare - au Syntax * RainbowParenthesesLoadBraces - - - -call plug#end() diff --git a/vim/vimrc.d/sensible.vim b/vim/vimrc.d/sensible.vim new file mode 100644 index 0000000..30064ee --- /dev/null +++ b/vim/vimrc.d/sensible.vim @@ -0,0 +1,161 @@ +if exists('g:loaded_sensible') || &compatible + finish +else + let g:loaded_sensible = 'yes' +endif + +" lazy for faster redraw +set lazyredraw + +" disable vi compatibility +set nocompatible + +" set encoding +set encoding=utf-8 + +" show the full incomplete command at the bottom of screen. +set showcmd + +" mouse support +set mouse=a + +" enable line numbers +set number + +" highlight the cursorline +set cursorline +" and also the column +set cuc cul + +" make laggy connections work faster +set ttyfast + +" case-insensitive filename completion +set wildignorecase + +" allow unsaved hidden buffers +" https://vimtricks.com/p/what-is-set-hidden/ +set hidden + +" disable wrapping +set nowrap + +" round tabs to the nearest tab +set shiftround + +" set the tab to match +set autoindent + +" when searching ignore case +set ignorecase + +" when using case respect it +set smartcase + +" highlight results +set hlsearch + +"search as you type +set incsearch + +" you know what's helpful a ridiculous back button +set history=1000 +set undolevels=1000 + +" user backfile files foften +set backup +set backupdir=~/.vim/backup + +" swap files kind of clutter up +set noswapfile + +" I get these enough. I don't need more. +set noerrorbells + +" always have a status. +set laststatus=2 + +" tab logic +set expandtab +set softtabstop=2 tabstop=2 shiftwidth=2 + +" add tab completion for commands +" https://vim.fandom.com/wiki/Great_wildmode/wildmenu_and_console_mouse +set wildmode=list:longest,full + +" highlight matching [{()}] +set showmatch + +" spellnig mattears. +set dictionary=/usr/share/dict/words + +" ag isn't grep but it is faster. +if executable('ag') + set grepprg=ag\ --nogroup\ --nocolor +endif + +if has('autocmd') + filetype plugin indent on +endif + +if has('syntax') && !exists('g:syntax_on') + syntax enable +endif + +" backspace cross the following +set backspace=indent,eol,start +set complete-=i +set smarttab + +set nrformats-=octal + +if !has('nvim') && &ttimeoutlen == -1 + set ttimeout + set ttimeoutlen=100 +endif + +" Use to clear the highlighting of :set hlsearch. +if maparg('', 'n') ==# '' + nnoremap :nohlsearch=has('diff')?'diffupdate':'' +endif + +if !&scrolloff + set scrolloff=1 +endif +if !&sidescrolloff + set sidescrolloff=5 +endif +set display+=lastline + +if &listchars ==# 'eol:$' + set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ +endif + +" Delete commment characters when joining comment lines +if v:version > 703 || v:version == 703 && has("patch541") + set formatoptions+=j " Delete comment character when joining commented lines +endif + +" max tab count +if &tabpagemax < 50 + set tabpagemax=50 +endif + +if !empty(&viminfo) + set viminfo^=! +endif + +set sessionoptions-=options +set viewoptions-=options + +" Allow color schemes to do bright colors without forcing bold. +if &t_Co == 8 && $TERM !~# '^Eterm' + set t_Co=16 +endif + +" Load matchit.vim, but only if the user hasn't installed a newer version. +if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' + runtime! macros/matchit.vim +endif + +" vim:set ft=vim et sw=2: diff --git a/vim/vimrc.d/ui.vim b/vim/vimrc.d/ui.vim deleted file mode 100644 index defc7eb..0000000 --- a/vim/vimrc.d/ui.vim +++ /dev/null @@ -1,19 +0,0 @@ - -"" GUI -if has('gui_macvim') - let macvim_skip_colorscheme = 1 - colorscheme flatwhite - set lines=60 columns=108 linespace=0 - set guifont=Source\ Code\ Pro\ for\ Powerline:h10 -else - set background=dark - let g:molokai_original=1 - let g:rehash256=1 - set t_Co=256 - colorscheme molokai - hi LineNr ctermfg=245 ctermbg=235 -endif - -"" Error Message -match ErrorMsg '\%>120v.\+' -match ErrorMsg '\s\+$'