diff --git a/.vimrc.bundles b/.vimrc.bundles index b8b8ddf..51286c9 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -22,16 +22,12 @@ call plug#begin(s:plugin_dir) - "Plug 'NoahTheDuke/vim-just' - " Plug 'mbbill/undotree' - " { - " Plug 'alvan/vim-closetag' - " let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js' - " } + " https://github.com/junegunn/vim-plug/wiki/tips + function! Cond(cond, ...) + let opts = get(a:000, 0, {}) + return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) + endfunction - " for markdown{ - " Plug 'preservim/vim-markdown' - "} if has('nvim') function! UpdateRemotePlugins(...) " Needed to refresh runtime files @@ -39,17 +35,17 @@ UpdateRemotePlugins endfunction - Plug 'gelguy/wilder.nvim', { 'do': function('UpdateRemotePlugins') } + Plug 'gelguy/wilder.nvim', Cond(!exists('g:vscode'), { 'do': function('UpdateRemotePlugins') }) else Plug 'gelguy/wilder.nvim' " To use Python remote plugin features in Vim, can be skipped - Plug 'roxma/nvim-yarp' - Plug 'roxma/vim-hug-neovim-rpc' + " Plug 'roxma/nvim-yarp' + " Plug 'roxma/vim-hug-neovim-rpc' endif - Plug 'dstein64/vim-startuptime' - Plug 'simeji/winresizer' + Plug 'dstein64/vim-startuptime', Cond(!exists('g:vscode')) + Plug 'simeji/winresizer', Cond(!exists('g:vscode')) Plug 'rust-lang/rust.vim', { 'for': ['rust'] } Plug 'machakann/vim-sandwich' @@ -57,20 +53,20 @@ Plug 'jiangmiao/auto-pairs' Plug 'mg979/vim-visual-multi' - Plug 'RRethy/vim-illuminate' + Plug 'RRethy/vim-illuminate', Cond(!exists('g:vscode')) "Plug 'easymotion/vim-easymotion' Plug 'vim-scripts/restore_view.vim' - Plug 'mhinz/vim-startify' + Plug 'mhinz/vim-startify', Cond(!exists('g:vscode')) - Plug 'christoomey/vim-tmux-navigator' - Plug 'NLKNguyen/papercolor-theme' + Plug 'christoomey/vim-tmux-navigator', Cond(!exists('g:vscode')) + Plug 'NLKNguyen/papercolor-theme', Cond(!exists('g:vscode')) Plug 'airblade/vim-rooter' " Comment stuff out Plug 'tpope/vim-commentary' - Plug 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp'] } + Plug 'ludovicchabant/vim-gutentags', Cond(!exists('g:vscode'), { 'for': ['c', 'cpp'] }) " Plug 'lambdalisue/readablefold.vim' " only work with vim @@ -95,7 +91,7 @@ endif if executable('node') - Plug 'neoclide/coc.nvim', {'branch': 'release'} + Plug 'neoclide/coc.nvim', Cond(!exists('g:vscode'), {'branch': 'release'}) endif " only work with nvim > 0.5 @@ -103,35 +99,35 @@ " cause error if g:vim_type == 'nvim' if g:vim_version >= 0.5 - Plug 'xiyaowong/nvim-transparent' - Plug 'lukas-reineke/indent-blankline.nvim' + Plug 'xiyaowong/nvim-transparent', Cond(!exists('g:vscode')) + Plug 'lukas-reineke/indent-blankline.nvim', Cond(!exists('g:vscode')) " nvim theme - Plug 'EdenEast/nightfox.nvim' - Plug 'projekt0n/github-nvim-theme', { 'tag': 'v0.0.7' } + Plug 'EdenEast/nightfox.nvim', Cond(!exists('g:vscode')) + Plug 'projekt0n/github-nvim-theme', Cond(!exists('g:vscode'), { 'tag': 'v0.0.7' }) - Plug 'nvim-lualine/lualine.nvim' + Plug 'nvim-lualine/lualine.nvim', Cond(!exists('g:vscode')) endif if g:vim_version >= 0.7 Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " for telescope - Plug 'nvim-lua/plenary.nvim' - Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.x' } + Plug 'nvim-lua/plenary.nvim', Cond(!exists('g:vscode')) + Plug 'nvim-telescope/telescope.nvim', Cond(!exists('g:vscode'), { 'tag': '0.1.x' }) if executable('make') " c plugin for telescope to make it faster - Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } + Plug 'nvim-telescope/telescope-fzf-native.nvim', Cond(!exists('g:vscode'), { 'do': 'make' }) endif " comment out this plugin if the machine doesn't have required " font install - Plug 'nvim-tree/nvim-web-devicons' + Plug 'nvim-tree/nvim-web-devicons', Cond(!exists('g:vscode')) endif if g:vim_version >= 0.8 - Plug 'nvim-tree/nvim-tree.lua' + Plug 'nvim-tree/nvim-tree.lua', Cond(!exists('g:vscode')) endif if g:vim_version < 0.8 - Plug 'scrooloose/nerdtree' + Plug 'scrooloose/nerdtree', Cond(!exists('g:vscode')) endif endif @@ -148,9 +144,15 @@ function! HasPlug(plug_name, ...) let plug_dir_name = get(a:, 1, a:plug_name) " optional argument for the name of plug's folder if has_key(g:plugs, a:plug_name) && isdirectory(s:plugin_dir . "/" . plug_dir_name) + if has_key(g:plugs[a:plug_name], 'for') || has_key(g:plugs[a:plug_name], 'on') + if (has_key(g:plugs[a:plug_name], 'for') && len(g:plugs[a:plug_name]['for']) == 0) || + \ (has_key(g:plugs[a:plug_name], 'on') && len(g:plugs[a:plug_name]['on']) == 0) + return v:false + endif + endif return v:true endif - return v:false + return v:false endfunction " Plugin_Preferences diff --git a/.vimrc.lua b/.vimrc.lua index 015b254..c6f6482 100644 --- a/.vimrc.lua +++ b/.vimrc.lua @@ -5,6 +5,9 @@ local vim_version_minor = vim_version['minor'] -- print(vim.inspect(version)) -- local function vim_illuminate_config() + if not vim.fn.HasPlug('vim-illuminate') then + return + end require('illuminate').configure({ providers = { 'lsp', @@ -32,6 +35,9 @@ local function vim_illuminate_config() end local function telescope_config() + if not vim.fn.HasPlug('telescope.nvim') then + return + end if vim.fn.HasPlug('telescope-fzf-native.nvim') then require('telescope').setup { extensions = { @@ -63,6 +69,9 @@ local function telescope_config() end local function github_theme_config() + if not vim.fn.HasPlug('github-nvim-theme') then + return + end -- Example config in Lua require("github-theme").setup({ -- Overwrite the highlight groups @@ -89,6 +98,9 @@ local function color_picker_nvim_config() end local function indent_blankline_config() + if not vim.fn.HasPlug('indent-blankline.nvim') then + return + end -- Example config in Lua require("indent_blankline").setup { show_current_context = true, @@ -99,6 +111,9 @@ local function indent_blankline_config() end local function transparent_config() + if not vim.fn.HasPlug('nvim-transparent') then + return + end require("transparent").setup({ enable = true, -- boolean: enable transparent extra_groups = { -- table/string: additional groups that should be cleared @@ -111,6 +126,9 @@ local function transparent_config() end local function lualine_config() + if not vim.fn.HasPlug('lualine.nvim') then + return + end for i=1,9 do vim.api.nvim_set_keymap('n', ''..i, ':LualineBuffersJump '..i..'', { noremap = true, silent = true, nowait = true }) -- :nnoremap 1 :LualineBuffersJump 1 @@ -173,6 +191,9 @@ local function lualine_config() end local function nvim_treesitter_config() + if not vim.fn.HasPlug('nvim-treesitter') then + return + end require('nvim-treesitter.configs').setup { -- ensure_installed = { "c", "bash", "lua" }, sync_install = false, @@ -186,6 +207,9 @@ local function nvim_treesitter_config() end local function nvim_tree_config() + if not vim.fn.HasPlug('nvim-tree.lua') then + return + end -- disable netrw at the very start of your init.lua (strongly advised) vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1