diff --git a/.vimrc b/.vimrc index aa29f4a..7bb6e33 100644 --- a/.vimrc +++ b/.vimrc @@ -99,7 +99,7 @@ " Vim UI { - if filereadable(expand("~/.vim/bundle/vim-colors-solarized/colors/solarized.vim")) + if filereadable(expand("~/.vim/plugged/vim-colors-solarized/colors/solarized.vim")) let g:solarized_termcolors=256 let g:solarized_termtrans=1 let g:solarized_contrast="normal" @@ -268,71 +268,17 @@ " Plugins { - " Misc { - if isdirectory(expand("~/.vim/bundle/nerdtree")) - let g:NERDShutUp=1 - endif - if isdirectory(expand("~/.vim/bundle/matchit.zip")) - let b:match_ignorecase = 1 - endif - " } - " AutoCloseTag { " Make it so AutoCloseTag works for xml and xhtml files as well au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim nmap ac ToggleAutoCloseMappings " } - " NerdTree { - if isdirectory(expand("~/.vim/bundle/nerdtree")) - nnoremap :NERDTreeToggle - " map e :NERDTreeFind - nmap nt :NERDTreeFind - - let NERDTreeShowBookmarks=1 - let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$'] - let NERDTreeChDirMode=0 - let NERDTreeQuitOnOpen=1 - let NERDTreeMouseMode=2 - let NERDTreeShowHidden=1 - let NERDTreeKeepTreeInNewTab=1 - endif - " } " JSON { nmap jt :%!python -m json.tool:set filetype=json let g:vim_json_syntax_conceal = 0 " } - " indent_guides { - if isdirectory(expand("~/.vim/bundle/vim-indent-guides/")) - let g:indent_guides_start_level = 2 - let g:indent_guides_guide_size = 1 - let g:indent_guides_enable_on_vim_startup = 0 - map f :IndentGuidesToggle - - endif - " } - " vim-airline { - " Set configuration options for the statusline plugin vim-airline. - " Use the powerline theme and optionally enable powerline symbols. - " To use the symbols , , , , , , and .in the statusline - " segments add the following to your .vimrc.before.local file: - " let g:airline_powerline_fonts=1 - " If the previous symbols do not render for you then install a - " powerline enabled font. - - " See `:echo g:airline_theme_map` for some more choices - " Default in terminal vim is 'dark' - let g:airline_section_z = '' - let g:airline_section_y = '' - - if isdirectory(expand("~/.vim/bundle/vim-airline-themes/")) - if !exists('g:airline_theme') - let g:airline_theme = 'solarized' - endif - endif - - " } " } @@ -478,7 +424,7 @@ " space-d jump to definition if coc is installed "nnoremap d :call CocAction('jumpDefinition', v: false) "nnoremap r :call CocAction('jumpReferences', v: false) - if filereadable(expand("~/.vim-config/.exp-coc-config")) + if filereadable(expand("~/.dotfile/.exp-coc-config")) source ~/.vim-config/.exp-coc-config endif diff --git a/.vimrc.bundles b/.vimrc.bundles index 6783fa8..823894c 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -1,136 +1,121 @@ -" Modeline and Notes { -" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell: -" -" This file imports the various plugins of spf13. -" } " Environment { " Basics { set nocompatible " Must be first line - set background=dark " Assume a dark background " } - - " Setup Bundle Support { - " The next three lines ensure that the ~/.vim/bundle/ system works - filetype off - set rtp+=~/.vim/bundle/vundle - call vundle#rc() - " } - - " Add an UnBundle command { - function! UnBundle(arg, ...) - let bundle = vundle#config#init_bundle(a:arg, a:000) - call filter(g:vundle#bundles, 'v:val["name_spec"] != "' . a:arg . '"') - endfunction - - com! -nargs=+ UnBundle - \ call UnBundle() - " } - " } -" Bundles { " Deps { - Bundle 'gmarik/vundle' - Bundle 'MarcWeber/vim-addon-mw-utils' - Bundle 'tomtom/tlib_vim' - if executable('ag') - Bundle 'mileszs/ack.vim' - let g:ackprg = 'ag --nogroup --nocolor --column --smart-case' - elseif executable('ack-grep') - let g:ackprg="ack-grep -H --nocolor --nogroup --column" - Bundle 'mileszs/ack.vim' - elseif executable('ack') - Bundle 'mileszs/ack.vim' - endif + "Plug 'MarcWeber/vim-addon-mw-utils' + "Plug 'tomtom/tlib_vim' " } + " + " Plugin directory + let plugin_dir = '~/.vim/plugged/' + call plug#begin(plugin_dir) - " In your .vimrc.before.local file - " list only the plugin groups you will use - if !exists('g:spf13_bundle_groups') - let g:spf13_bundle_groups=['my_bundle', 'general'] - endif + Plug 'neoclide/coc.nvim', {'branch': 'release'} + " add desired extensions to the following global variable + " coc-tsserver: javascript + " coc-pyright: python + " coc-clangd: c/c++, may need to install clangd seperatly + let g:coc_global_extensions = ['coc-pyright', 'coc-rls'] + Plug 'rust-lang/rust.vim' + " syntax highlighting(and more) for typescript + " { + Plug 'leafgarland/typescript-vim' + " } + " { + Plug 'alvan/vim-closetag' + let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js' + " } + Plug 'altercation/vim-colors-solarized' + "Plug 'lifepillar/vim-solarized8' + "Plug 'spf13/vim-colors' + Plug 'scrooloose/nerdtree' - " To override all the included bundles, add the following to your - " .vimrc.bundles.local file: - " let g:override_spf13_bundles = 1 - if !exists("g:override_spf13_bundles") - - - " my bundles { - if count(g:spf13_bundle_groups, 'my_bundle') - " { - "Bundle 'codota/tabnine-vim' - Bundle 'neoclide/coc.nvim' - Bundle 'rust-lang/rust.vim' - " add desired extensions to the following global variable - " coc-tsserver: javascript - " coc-pyright: python - " coc-clangd: c/c++, may need to install clangd seperatly - let g:coc_global_extensions = ['coc-pyright', 'coc-rls'] - " syntax highlighting(and more) for typescript - " { - Bundle 'leafgarland/typescript-vim' - " } - " { - Bundle 'alvan/vim-closetag' - let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js' - " } - endif - " }] - " General { - if count(g:spf13_bundle_groups, 'general') - Bundle 'altercation/vim-colors-solarized' - "Bundle 'lifepillar/vim-solarized8' - "Bundle 'spf13/vim-colors' - Bundle 'scrooloose/nerdtree' - - " for markdown{ - Bundle 'godlygeek/tabular' - Bundle 'preservim/vim-markdown' - "} - " for window resize{ - Bundle 'simeji/winresizer' + " for markdown{ + Plug 'godlygeek/tabular' + Plug 'preservim/vim-markdown' + "} + " for window resize{ + Plug 'simeji/winresizer' let g:winresizer_start_key = '' let g:winresizer_vert_resize = 2 let g:winresizer_horiz_resize = 2 - " } - - Bundle 'tpope/vim-surround' - Bundle 'rhysd/conflict-marker.vim' - " { - Bundle 'jiangmiao/auto-pairs' - "let g:AutoPairsFlyMode = 1 - - " } - " { - Bundle 'mg979/vim-visual-multi' - " } - Bundle 'matchit.zip' - Bundle 'vim-airline/vim-airline' - Bundle 'vim-airline/vim-airline-themes' + " } + + Plug 'tpope/vim-surround' + Plug 'rhysd/conflict-marker.vim' + " { + Plug 'jiangmiao/auto-pairs' + "let g:AutoPairsFlyMode = 1 + + " } + " { + Plug 'mg979/vim-visual-multi' + " } + Plug 'vim-airline/vim-airline' + Plug 'vim-airline/vim-airline-themes' - " For nvim-bufferline - " { - "Bundle 'kyazdani42/nvim-web-devicons' - "Bundle 'akinsho/nvim-bufferline.lua' - " } - Bundle 'bling/vim-bufferline' - Bundle 'easymotion/vim-easymotion' - Bundle 'nathanaelkane/vim-indent-guides' - if !exists('g:spf13_no_views') - Bundle 'vim-scripts/restore_view.vim' - endif + " For nvim-bufferline + " { + "Plug 'kyazdani42/nvim-web-devicons' + "Plug 'akinsho/nvim-bufferline.lua' + " } + Plug 'bling/vim-bufferline' + Plug 'easymotion/vim-easymotion' + Plug 'nathanaelkane/vim-indent-guides' + Plug 'vim-scripts/restore_view.vim' + call plug#end() + +" Plugin Preferences +" + " NerdTree { + if isdirectory(expand(plugin_dir . "/nerdtree")) + let g:NERDShutUp=1 + nnoremap :NERDTreeToggle + " map e :NERDTreeFind + nmap nt :NERDTreeFind + + let NERDTreeShowBookmarks=1 + "let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$'] + let NERDTreeChDirMode=0 + let NERDTreeQuitOnOpen=1 + let NERDTreeMouseMode=2 + let NERDTreeShowHidden=1 + let NERDTreeKeepTreeInNewTab=1 endif " } - endif + " indent_guides { + if isdirectory(expand(plugin_dir . "/vim-indent-guides/")) + let g:indent_guides_start_level = 2 + let g:indent_guides_guide_size = 1 + let g:indent_guides_enable_on_vim_startup = 0 + map f :IndentGuidesToggle + + endif + " } + " vim-airline { + " Set configuration options for the statusline plugin vim-airline. + " Use the powerline theme and optionally enable powerline symbols. + " To use the symbols , , , , , , and .in the statusline + " segments add the following to your .vimrc.before.local file: + " let g:airline_powerline_fonts=1 + " If the previous symbols do not render for you then install a + " powerline enabled font. - " Custome script { - - if filereadable(expand("~/.vim-config/buffer_arrange.vim")) - source ~/.vim-config/buffer_arrange.vim - endif - + " See `:echo g:airline_theme_map` for some more choices + " Default in terminal vim is 'dark' + let g:airline_section_z = '' + let g:airline_section_y = '' + + if isdirectory(expand(plugin_dir . "/vim-airline-themes/")) + if !exists('g:airline_theme') + let g:airline_theme = 'solarized' + endif + endif + " } diff --git a/install.sh b/install.sh index 6bd39ba..095a953 100755 --- a/install.sh +++ b/install.sh @@ -15,12 +15,10 @@ msg() { } success() { - if [ "$ret" -eq '0' ]; then - msg "\33[32m[✔]\33[0m ${1}${2}" - fi + msg "\33[32m[✔]\33[0m ${1}${2}" } -error() { +function fatal_error() { msg "\33[31m[✘]\33[0m ${1}${2}" exit 1 } @@ -41,13 +39,14 @@ program_must_exist() { # throw error on non-zero return value if [ "$?" -ne 0 ]; then - error "You must have '$1' installed to continue." + fatal_error "You must have '$1' installed to continue." fi } env_set() { if [ -z "$1" ]; then - error "You must have your $1 environmental variable set to continue." + fatal_error "You must have your $1 environmental variable set to continue." + exit 1 fi } @@ -65,15 +64,19 @@ try_symlink() { ############################ SETUP FUNCTIONS backup_file() { - original_file=$1 - if [ -e "$original_file" ]; then + local original_file=$1 + if [ -f "$original_file" ] && [ ! -L "$original_file" ]; then today=`date +%Y%m%d_%s` - [ -e "$i" ] && [ ! -L "$i" ] && mv -v "$original_file" "$original_file.$today"; - ret="$?" + mv -v "$original_file" "$original_file.$today"; success "Your file $original_file has been backed up as $original_file.$today" fi } +# Usage: sync_repo path url +# +# This function try to clone git repo host in @url +# to @path. If @path alreay exsits, it will simply +# update the repo sync_repo() { local repo_path="$1" local repo_uri="$2" @@ -96,19 +99,21 @@ sync_repo() { setup_vundle() { - local VUNDLE_URI="https://github.com/gmarik/vundle.git" - sync_repo "$HOME/.vim/bundle/vundle" \ - "$VUNDLE_URI" \ - "master" \ - "vundle" + # setup for vim + curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim > /dev/null 2>&1 + + # setup for neovim + #sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ + # https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' local system_shell="$SHELL" export SHELL='/bin/sh' vim \ "+set nomore" \ - "+BundleInstall!" \ - "+BundleClean" \ + "+PlugInstall!" \ + "+PlugClean" \ "+qall" export SHELL="$system_shell" @@ -134,7 +139,7 @@ source ~/.vimrc" > $nvim_config set_up_tmux() { if program_exists "tmux"; then - backup_file "$APP_PATH/.tmux.conf" + backup_file "$HOME/.tmux.conf" try_symlink "$APP_PATH/.tmux.conf" "$HOME/.tmux.conf" && \ success "tmux config setup successed" else @@ -152,8 +157,8 @@ set_up_vim() { "$REPO_BRANCH" \ "$app_name" - backup_file "$APP_PATH/.vimrc" - backup_file "$APP_PATH/.vimrc.bundles" + backup_file "$HOME/.vimrc" + backup_file "$HOME/.vimrc.bundles" try_symlink "$APP_PATH/.vimrc" "$HOME/.vimrc" try_symlink "$APP_PATH/.vimrc.bundles" "$HOME/.vimrc.bundles"