aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2021-07-02 01:30:47 +0800
committerjdhao <jdhao@hotmail.com>2021-07-02 01:30:47 +0800
commit83ef151e363c9f5495dd492ae985ce54c28935d0 (patch)
tree070b8dea8a20760938ef27f1eb813d08b6b4384f
parenta8a073146dea2752e8597157d7f03406386aa242 (diff)
switch to packer for plugin management
-rw-r--r--core/plugins.vim303
-rw-r--r--core/ui.vim17
-rw-r--r--lua/plugins.lua269
3 files changed, 275 insertions, 314 deletions
diff --git a/core/plugins.vim b/core/plugins.vim
index bc701c8..fc9fd84 100644
--- a/core/plugins.vim
+++ b/core/plugins.vim
@@ -1,297 +1,7 @@
scriptencoding utf-8
-"{ Plugin installation
-"{{ Vim-plug related settings.
-" The root directory to install all plugins.
-let g:plug_home=expand(stdpath('data') . '/plugged')
-" Use fastgit for clone on Linux systems.
-if g:is_linux
- let g:plug_url_format = 'https://hub.fastgit.org/%s.git'
-endif
-
-if empty(readdir(g:plug_home))
- augroup plug_init
- autocmd!
- autocmd VimEnter * PlugInstall --sync | quit |source $MYVIMRC
- augroup END
-endif
-"}}
-
-"{{ Autocompletion related plugins
-call plug#begin()
-Plug 'neovim/nvim-lspconfig'
-Plug 'hrsh7th/nvim-compe'
-"}}
-
-"{{ language-specific plugins
-" Python syntax highlighting and more
-if g:is_mac || g:is_win
- Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }
-endif
-
-" Python indent (follows the PEP8 style)
-Plug 'Vimjas/vim-python-pep8-indent', {'for': 'python'}
-
-" Python-related text object
-Plug 'jeetsukumaran/vim-pythonsense'
-Plug 'machakann/vim-swap'
-
-" IDE for Lisp
-if executable('sbcl')
- " Plug 'kovisoft/slimv'
- Plug 'vlime/vlime', {'rtp': 'vim/', 'for': 'lisp'}
-endif
-"}}
-
-"{{ Search related plugins
-" Super fast movement with vim-sneak
-Plug 'justinmk/vim-sneak'
-
-" Clear highlight search automatically for you
-Plug 'romainl/vim-cool'
-
-" Show current search term in different color
-Plug 'PeterRincker/vim-searchlight'
-
-" Show match number for incsearch
-Plug 'osyo-manga/vim-anzu'
-
-" Stay after pressing * and search selected text
-Plug 'haya14busa/vim-asterisk'
-
-" File search, tag search and more
-if g:is_win
- Plug 'Yggdroot/LeaderF'
-else
- Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
-endif
-
-" Another similar plugin is command-t
-" Plug 'wincent/command-t'
-
-" Another grep tool (similar to Sublime Text Ctrl+Shift+F)
-" Plug 'dyng/ctrlsf.vim'
-
-" A greping tool
-" Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
-"}}
-
-"{{ UI: Color, theme etc.
-" A list of colorscheme plugin you may want to try. Find what suits you.
-Plug 'lifepillar/vim-gruvbox8'
-Plug 'ajmwagar/vim-deus'
-Plug 'lifepillar/vim-solarized8'
-Plug 'joshdick/onedark.vim'
-Plug 'KeitaNakamura/neodark.vim'
-Plug 'sainnhe/edge'
-Plug 'sainnhe/sonokai'
-Plug 'sainnhe/gruvbox-material'
-
-if !exists('g:started_by_firenvim')
- " colorful status line and theme
- Plug 'vim-airline/vim-airline'
- Plug 'vim-airline/vim-airline-themes'
- Plug 'mhinz/vim-startify'
-endif
-
-Plug 'lukas-reineke/indent-blankline.nvim', {'branch': 'lua'}
-"}}
-
-"{{ Plugin to deal with URL
-" Highlight URLs inside vim
-Plug 'itchyny/vim-highlighturl'
-
-" For Windows and Mac, we can open an URL in the browser. For Linux, it may
-" not be possible since we maybe in a server which disables GUI.
-if g:is_win || g:is_mac
- " open URL in browser
- Plug 'tyru/open-browser.vim'
-endif
-"}}
-
-"{{ Navigation and tags plugin
-" Only install these plugins if ctags are installed on the system
-if executable('ctags')
- " plugin to manage your tags
- Plug 'ludovicchabant/vim-gutentags'
- " show file tags in vim window
- Plug 'liuchengxu/vista.vim'
-endif
-"}}
-
-"{{ File editting plugin
-" Snippet engine and snippet template
-Plug 'SirVer/ultisnips'
-Plug 'honza/vim-snippets'
-
-" Automatic insertion and deletion of a pair of characters
-Plug 'jiangmiao/auto-pairs'
-
-" Comment plugin
-Plug 'tpope/vim-commentary'
-
-" Multiple cursor plugin like Sublime Text?
-" Plug 'mg979/vim-visual-multi'
-
-" Title character case
-Plug 'christoomey/vim-titlecase'
-
-" Autosave files on certain events
-Plug '907th/vim-auto-save'
-
-" Show undo history visually
-Plug 'simnalamburt/vim-mundo'
-
-" Manage your yank history
-if g:is_win || g:is_mac
- Plug 'svermeulen/vim-yoink'
-endif
-
-Plug 'bfredl/nvim-miniyank'
-
-" Handy unix command inside Vim (Rename, Move etc.)
-Plug 'tpope/vim-eunuch'
-
-" Repeat vim motions
-Plug 'tpope/vim-repeat'
-
-" Show the content of register in preview window
-" Plug 'junegunn/vim-peekaboo'
-Plug 'jdhao/better-escape.vim'
-
-if g:is_mac
- Plug 'lyokha/vim-xkbswitch'
-elseif g:is_win
- Plug 'Neur1n/neuims'
-endif
-"}}
-
-"{{ Linting, formating
-" Syntax check and make
-" Plug 'neomake/neomake'
-
-" Another linting plugin
-Plug 'dense-analysis/ale'
-
-" Auto format tools
-Plug 'sbdchd/neoformat', { 'on': 'Neoformat' }
-" Plug 'Chiel92/vim-autoformat'
-"}}
-
-"{{ Git related plugins
-" Show git change (change, delete, add) signs in vim sign column
-Plug 'mhinz/vim-signify'
-" Another similar plugin
-" Plug 'airblade/vim-gitgutter'
-
-" Git command inside vim
-Plug 'tpope/vim-fugitive'
-"}}
-
-"{{ Plugins for markdown writing
-" Another markdown plugin
-Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
-
-" Faster footnote generation
-Plug 'vim-pandoc/vim-markdownfootnotes', { 'for': 'markdown' }
-
-" Vim tabular plugin for manipulate tabular, required by markdown plugins
-Plug 'godlygeek/tabular', {'on': 'Tabularize'}
-
-" Markdown JSON header highlight plugin
-Plug 'elzr/vim-json', { 'for': ['json', 'markdown'] }
-
-" Markdown previewing (only for Mac and Windows)
-if g:is_win || g:is_mac
- Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug'] }
-endif
-
-if g:is_mac
- Plug 'rhysd/vim-grammarous'
-endif
-
-Plug 'chrisbra/unicode.vim'
-"}}
-
-"{{ Text object plugins
-" Additional powerful text object for vim, this plugin should be studied
-" carefully to use its full power
-Plug 'wellle/targets.vim'
-
-" Plugin to manipulate characer pairs quickly
-" Plug 'tpope/vim-surround'
-Plug 'machakann/vim-sandwich'
-
-" Add indent object for vim (useful for languages like Python)
-Plug 'michaeljsmith/vim-indent-object'
-"}}
-
-"{{ LaTeX editting and previewing plugin
-" Only use these plugin on Windows and Mac and when LaTeX is installed
-if ( g:is_win || g:is_mac ) && executable('latex')
- " vimtex use autoload feature of Vim, so it is not necessary to use `for`
- " keyword of vim-plug to try to lazy-load it,
- " see https://github.com/junegunn/vim-plug/issues/785
- Plug 'lervag/vimtex'
-
- " Plug 'matze/vim-tex-fold', {'for': 'tex'}
- " Plug 'Konfekt/FastFold'
-endif
-"}}
-
-"{{ Tmux related plugins
-" Since tmux is only available on Linux and Mac, we only enable these plugins
-" for Linux and Mac
-if executable('tmux')
- " Let vim detect tmux focus event correctly, see
- " https://github.com/neovim/neovim/issues/9486 and
- " https://vi.stackexchange.com/q/18515/15292
- Plug 'tmux-plugins/vim-tmux-focus-events'
-
- " .tmux.conf syntax highlighting and setting check
- Plug 'tmux-plugins/vim-tmux', { 'for': 'tmux' }
-endif
-"}}
-
-"{{ Misc plugins
-" Modern matchit implementation
-Plug 'andymass/vim-matchup'
-
-" Smoothie motions
-Plug 'psliwka/vim-smoothie'
-
-Plug 'tpope/vim-scriptease'
-
-" Asynchronous command execution
-Plug 'skywind3000/asyncrun.vim'
-" Another asynchronous plugin
-" Plug 'tpope/vim-dispatch'
-Plug 'cespare/vim-toml'
-
-" Edit text area in browser using nvim
-if g:is_mac || g:is_win
- Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
-endif
-
-" Debugger plugin
-if g:is_mac || g:is_linux
- Plug 'sakhnik/nvim-gdb', { 'do': ':!./install.sh \| UpdateRemotePlugins' }
-endif
-
-" Session management plugin
-Plug 'tpope/vim-obsession'
-
-" Calculate statistics for visual selection
-Plug 'wgurecky/vimSum'
-if g:is_linux
- Plug 'ojroques/vim-oscyank'
-endif
-
-" REPL for nvim
-Plug 'hkupty/iron.nvim'
-call plug#end()
-"}}
-"}
+" Plugin installation
+lua require 'plugins'
"{ Plugin settings
"{{ Vim-plug settings
@@ -299,11 +9,10 @@ call plug#end()
" To use these shortcut: first activate command line with `:`, then input the
" short alias, e.g., `pi`, then press <space>, the alias will be expanded
" to the full command automatically
-call utils#Cabbrev('pi', 'PlugInstall')
-call utils#Cabbrev('pud', 'PlugUpdate')
-call utils#Cabbrev('pug', 'PlugUpgrade')
-call utils#Cabbrev('ps', 'PlugStatus')
-call utils#Cabbrev('pc', 'PlugClean')
+call utils#Cabbrev('pi', 'PackerInstall')
+call utils#Cabbrev('pud', 'PackerUpdate')
+call utils#Cabbrev('pc', 'PackerClean')
+call utils#Cabbrev('ps', 'PackerSync')
"}}
"{{ Auto-completion related
diff --git a/core/ui.vim b/core/ui.vim
index 8a89a0c..bba4819 100644
--- a/core/ui.vim
+++ b/core/ui.vim
@@ -10,10 +10,6 @@ set termguicolors
let s:my_theme_dict = {}
function! s:my_theme_dict.gruvbox8() dict abort
- " We should check if theme exists before using it, otherwise you will get
- " error message when starting Nvim
- if !utils#HasColorscheme('gruvbox8') | return | endif
-
" Italic options should be put before colorscheme setting,
" see https://github.com/morhetz/gruvbox/wiki/Terminal-specific#1-italics-is-disabled
let g:gruvbox_italics=1
@@ -24,50 +20,37 @@ function! s:my_theme_dict.gruvbox8() dict abort
endfunction
function! s:my_theme_dict.deus() dict abort
- if !utils#HasColorscheme('deus') | return | endif
-
colorscheme deus
endfunction
function! s:my_theme_dict.solarized8() dict abort
- if !utils#HasColorscheme('solarized8') | return | endif
-
let g:solarized_term_italics=1
let g:solarized_visibility='high'
colorscheme solarized8_high
endfunction
function! s:my_theme_dict.onedark() dict abort
- if !utils#HasColorscheme('onedark') | return | endif
-
let g:onedark_terminal_italics = 1
colorscheme onedark
endfunction
function! s:my_theme_dict.neodark() dict abort
- if !utils#HasColorscheme('neodark') | return | endif
-
colorscheme neodark
endfunction
function! s:my_theme_dict.edge() dict abort
- if !utils#HasColorscheme('edge') | return | endif
-
let g:edge_enable_italic = 1
let g:edge_better_performance = 1
colorscheme edge
endfunction
function! s:my_theme_dict.sonokai() dict abort
- if !utils#HasColorscheme('sonokai') | return | endif
-
let g:sonokai_enable_italic = 1
let g:sonokai_better_performance = 1
colorscheme sonokai
endfunction
function! s:my_theme_dict.gruvbox_material() dict abort
- if !utils#HasColorscheme('gruvbox-material') | return | endif
let g:gruvbox_material_enable_italic = 1
let g:gruvbox_material_better_performance = 1
colorscheme gruvbox-material
diff --git a/lua/plugins.lua b/lua/plugins.lua
new file mode 100644
index 0000000..a977035
--- /dev/null
+++ b/lua/plugins.lua
@@ -0,0 +1,269 @@
+vim.cmd [[packadd packer.nvim]]
+local execute = vim.api.nvim_command
+local fn = vim.fn
+
+local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
+
+if fn.empty(fn.glob(install_path)) > 0 then
+ fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path})
+ execute 'packadd packer.nvim'
+end
+
+require('packer').startup(
+{
+ function(use)
+ use 'wbthomason/packer.nvim'
+
+ -- nvim-lsp configuration
+ use 'neovim/nvim-lspconfig'
+
+ -- auto-completion engine
+ use 'hrsh7th/nvim-compe'
+
+ -- Python syntax highlighting and more
+ if (vim.g.is_mac == 1) or (vim.g.is_win == 1) then
+ use {'numirias/semshi', run = ':UpdateRemotePlugins', ft = {'python', }}
+ end
+
+ -- Python indent (follows the PEP8 style)
+ use {'Vimjas/vim-python-pep8-indent', ft = {'python', }}
+
+ -- Python-related text object
+ use {'jeetsukumaran/vim-pythonsense', ft = {'python'}}
+
+ use 'machakann/vim-swap'
+ -- IDE for Lisp
+ if fn.executable('sbcl') > 0 then
+ -- use 'kovisoft/slimv'
+ use {'vlime/vlime', rtp = 'vim/', ft={'lisp', }}
+ end
+
+ -- Super fast movement with vim-sneak
+ use 'justinmk/vim-sneak'
+
+ -- Clear highlight search automatically for you
+ use 'romainl/vim-cool'
+
+ -- Show current search term in different color
+ use 'PeterRincker/vim-searchlight'
+
+ -- Show match number for incsearch
+ use 'osyo-manga/vim-anzu'
+
+ -- Stay after pressing * and search selected text
+ use 'haya14busa/vim-asterisk'
+
+ -- File search, tag search and more
+ if vim.g.is_win == 1 then
+ use 'Yggdroot/LeaderF'
+ else
+ use {'Yggdroot/LeaderF', run = ':LeaderfInstallCExtension'}
+ end
+
+ -- Another similar plugin is command-t
+ -- use 'wincent/command-t'
+
+ -- Another grep tool (similar to Sublime Text Ctrl+Shift+F)
+ -- use 'dyng/ctrlsf.vim'
+
+ -- A greping tool
+ -- use {'mhinz/vim-grepper', cmd = {'Grepper', '<plug>(GrepperOperator)'}}
+
+ -- A list of colorscheme plugin you may want to try. Find what suits you.
+ use 'lifepillar/vim-gruvbox8'
+ use 'ajmwagar/vim-deus'
+ use 'lifepillar/vim-solarized8'
+ use 'joshdick/onedark.vim'
+ use 'KeitaNakamura/neodark.vim'
+ use 'sainnhe/edge'
+ use 'sainnhe/sonokai'
+ use 'sainnhe/gruvbox-material'
+
+ if fn.exists('g:started_by_firenvim') == 0 then
+ -- colorful status line and theme
+ use 'vim-airline/vim-airline'
+ use 'vim-airline/vim-airline-themes'
+ use 'mhinz/vim-startify'
+ end
+
+ use {'lukas-reineke/indent-blankline.nvim', branch = 'lua'}
+
+ -- Highlight URLs inside vim
+ use 'itchyny/vim-highlighturl'
+
+ -- For Windows and Mac, we can open an URL in the browser. For Linux, it may
+ -- not be possible since we maybe in a server which disables GUI.
+ if (vim.g.is_win == 1) or (vim.g.is_mac == 1) then
+ -- open URL in browser
+ use 'tyru/open-browser.vim'
+ end
+
+ -- Only install these plugins if ctags are installed on the system
+ if fn.executable('ctags') > 0 then
+ -- plugin to manage your tags
+ use 'ludovicchabant/vim-gutentags'
+ -- show file tags in vim window
+ use 'liuchengxu/vista.vim'
+ end
+
+ -- Snippet engine and snippet template
+ use {'SirVer/ultisnips', event = {'InsertEnter'}}
+ use {'honza/vim-snippets', event = {'InsertEnter'}}
+
+ -- Automatic insertion and deletion of a pair of characters
+ use {'jiangmiao/auto-pairs', event = {'InsertEnter'}}
+
+ -- Comment plugin
+ use 'tpope/vim-commentary'
+
+ -- Multiple cursor plugin like Sublime Text?
+ -- use 'mg979/vim-visual-multi'
+
+ -- Title character case
+ use 'christoomey/vim-titlecase'
+
+ -- Autosave files on certain events
+ use '907th/vim-auto-save'
+
+ -- Show undo history visually
+ use 'simnalamburt/vim-mundo'
+
+ -- Manage your yank history
+ if (vim.g.is_win == 1) or (vim.g.is_mac == 1) then
+ use 'svermeulen/vim-yoink'
+ end
+
+ use 'bfredl/nvim-miniyank'
+
+ -- Handy unix command inside Vim (Rename, Move etc.)
+ use 'tpope/vim-eunuch'
+
+ -- Repeat vim motions
+ use 'tpope/vim-repeat'
+
+ -- Show the content of register in preview window
+ -- Plug 'junegunn/vim-peekaboo'
+ use {'jdhao/better-escape.vim', event = {'InsertEnter', }}
+
+ if vim.g.is_mac == 1 then
+ use {'lyokha/vim-xkbswitch', event = {'InsertEnter', }}
+ elseif vim.g.is_win == 1 then
+ use {'Neur1n/neuims', event = {'InsertEnter', }}
+ end
+
+ -- Syntax check and make
+ -- use 'neomake/neomake'
+
+ -- Another linting plugin
+ use 'dense-analysis/ale'
+
+ -- Auto format tools
+ use {'sbdchd/neoformat', cmd = {'Neoformat', }}
+ -- use 'Chiel92/vim-autoformat'
+
+ -- Show git change (change, delete, add) signs in vim sign column
+ use 'mhinz/vim-signify'
+ -- Another similar plugin
+ -- use 'airblade/vim-gitgutter'
+
+ -- Git command inside vim
+ use 'tpope/vim-fugitive'
+
+ -- Another markdown plugin
+ use {'plasticboy/vim-markdown', ft = {'markdown', }}
+
+ -- Faster footnote generation
+ use {'vim-pandoc/vim-markdownfootnotes', ft = {'markdown', }}
+
+ -- Vim tabular plugin for manipulate tabular, required by markdown plugins
+ use {'godlygeek/tabular', cmd = {'Tabularize'}}
+
+ -- Markdown JSON header highlight plugin
+ use {'elzr/vim-json', ft = {'json', 'markdown'}}
+
+ -- Markdown previewing (only for Mac and Windows)
+ if (vim.g.is_win == 1) or (vim.g.is_mac == 1) then
+ use {'iamcco/markdown-preview.nvim', run = function() fn['mkdp#util#install']() end, ft = {'markdown'}}
+ end
+
+ if vim.g.is_mac == 1 then
+ use {'rhysd/vim-grammarous', ft = {'markdown', }}
+ end
+
+ use 'chrisbra/unicode.vim'
+
+ -- Additional powerful text object for vim, this plugin should be studied
+ -- carefully to use its full power
+ use 'wellle/targets.vim'
+
+ -- Plugin to manipulate characer pairs quickly
+ -- use 'tpope/vim-surround'
+ use 'machakann/vim-sandwich'
+
+ -- Add indent object for vim (useful for languages like Python)
+ use 'michaeljsmith/vim-indent-object'
+
+ -- Only use these plugin on Windows and Mac and when LaTeX is installed
+ if ( vim.g.is_win == 1 or vim.g.is_mac ==1 ) and fn.executable('latex') > 0 then
+ -- vimtex use autoload feature of Vim, so it is not necessary to use `for`
+ -- keyword of vim-plug to try to lazy-load it,
+ -- see https://github.com/junegunn/vim-plug/issues/785
+ use {'lervag/vimtex', ft = {'tex', }}
+
+ -- use {'matze/vim-tex-fold', ft = {'tex', }}
+ -- use 'Konfekt/FastFold'
+ end
+
+ -- Since tmux is only available on Linux and Mac, we only enable these plugins
+ -- for Linux and Mac
+ if fn.executable('tmux') > 0 then
+ -- Let vim detect tmux focus event correctly, see
+ -- https://github.com/neovim/neovim/issues/9486 and
+ -- https://vi.stackexchange.com/q/18515/15292
+ use 'tmux-plugins/vim-tmux-focus-events'
+
+ -- .tmux.conf syntax highlighting and setting check
+ use {'tmux-plugins/vim-tmux', ft = {'tmux', }}
+ end
+
+ -- Modern matchit implementation
+ use {'andymass/vim-matchup', event = {'VimEnter',}}
+
+ -- Smoothie motions
+ use 'psliwka/vim-smoothie'
+
+ use 'tpope/vim-scriptease'
+
+ -- Asynchronous command execution
+ use {'skywind3000/asyncrun.vim', opt = true, cmd = {'AsyncRun', }}
+ -- Another asynchronous plugin
+ -- Plug 'tpope/vim-dispatch'
+ use {'cespare/vim-toml', ft = {'toml',}}
+
+ -- Edit text area in browser using nvim
+ if (vim.g.is_win == 1) or (vim.g.is_mac == 1) then
+ use {'glacambre/firenvim', run = function() fn['firenvim#install'](0) end}
+ end
+
+ -- Debugger plugin
+ if (vim.g.is_win == 1) or (vim.g.is_linux == 1) then
+ use {'sakhnik/nvim-gdb', run = {'bash install.sh'}}
+ end
+
+ -- Session management plugin
+ use 'tpope/vim-obsession'
+
+ -- Calculate statistics for visual selection
+ use 'wgurecky/vimSum'
+
+ if vim.g.is_linux == 1 then
+ use 'ojroques/vim-oscyank'
+ end
+
+ -- REPL for nvim
+ use 'hkupty/iron.nvim'
+ end,
+ config = {
+ max_jobs = 16,
+ }
+})