From 1c991a4f7d3d06949cae9d0ca423fcf9714d1662 Mon Sep 17 00:00:00 2001 From: NTBBloodbath Date: Thu, 20 May 2021 08:07:12 -0400 Subject: [PATCH] all: fix plugins installation in fresh install --- doomrc | 45 +++++++------- install.sh | 19 +++++- lua/doom/autocmds/init.lua | 29 ++++++++-- lua/doom/config/init.lua | 19 +----- lua/plugins/init.lua | 116 ++++++++++--------------------------- 5 files changed, 98 insertions(+), 130 deletions(-) diff --git a/doomrc b/doomrc index d069101..446f570 100644 --- a/doomrc +++ b/doomrc @@ -19,7 +19,7 @@ Doom = { -- true : Enable format on save -- @default = false fmt_on_save = false, - + -- Autosave sessions -- false : Disable session autosave -- true : Enable session autosave @@ -45,28 +45,28 @@ Doom = { -- @default = false backup = false, -- WARNING: if you change this to false and you have an undo dir already, it will REMOVE the undodir (loss of data might take place) - -- Enable Line wrapping - -- false : disables line wrapping - -- true : enables line wrapping + -- Enable Line wrapping + -- false : disables line wrapping + -- true : enables line wrapping -- @default = false line_wrap = false, -- Enable Show mode ( -- INSERT --, -- NORMAL --, -- VISUAL -- ) - -- false : disables show mode - -- true : enables show mode + -- false : disables show mode + -- true : enables show mode -- @default = false show_mode = false, -- Enable scroll off - -- false : disables scroll off - -- true : enables scroll off + -- false : disables scroll off + -- true : enables scroll off -- @default = true, @default scrolloff_amount = 4, scrolloff = true, scrolloff_amount = 4, - -- Enable mouse + -- Enable mouse -- false : disables mouse - -- true : enables mouse + -- true : enables mouse -- @default = true mouse = true, @@ -88,21 +88,21 @@ Doom = { -- @default = true line_highlight = true, - -- Automatically split right + -- Automatically split right -- false : splits right (vertically) -- true : splits left (vertically) -- @default = true split_right = true, - -- Automatically split right + -- Automatically split above -- false : splits above (horizontally) -- true : splits below (horizontally) -- @default = true split_below = true, - -- Use clipboard outside of vim - -- false : won't use third party clipboard - -- true : enables third part clipboard + -- Use clipboard outside of vim + -- false : won't use third party clipboard + -- true : enables third part clipboard -- @default = true clipboard = true, @@ -153,6 +153,11 @@ Doom = { -- @default = false check_updates = false, + -- Auto install plugins on launch, useful if you don't want to run + -- PackerInstall every time you add a new plugin + -- @default = true + auto_install_plugins = true, + -- Disable dashboard status line (does not work perfectly) -- false : disables dashboard status line -- true : enables dashboard status line @@ -174,9 +179,9 @@ Doom = { -- Completion box height -- @default = 10 - complete_size = 10, - - -- Completion box transparency + complete_size = 10, + + -- Completion box transparency -- 0 = no transparency -- 100 = fully transparent -- @default = 25 @@ -226,7 +231,7 @@ Doom = { -- - float -- @default = 'horizontal' terminal_direction = 'horizontal', - + -- NOTE: This will only be activated if 'backup' is true. -- We don'recommend you put this outside of neovim so we've restricted to the path: ~/.config/nvim -- WARNING: only put the folder name that you want. (eg: undo_dir = '/undodir') @@ -241,7 +246,7 @@ Doom = { -- @default = dark colorscheme_bg = 'dark', - -- Set gui fonts here + -- Set gui fonts here -- @default = "FiraCode Nerd Font", @default font size = 15, -- WARNING: Font sizes must be in string format! guifont = 'FiraCode Nerd Font', diff --git a/install.sh b/install.sh index 9312944..4e2e35f 100755 --- a/install.sh +++ b/install.sh @@ -32,7 +32,7 @@ BYellow='\033[1;33m' # Yellow # }}} # Doom Nvim version -DoomNvimVersion='2.3.1' +DoomNvimVersion='2.3.2' # System OS System="$(uname -s)" @@ -148,8 +148,8 @@ backup_neovim() { } # }}} -# Doom Nvim updating -# ================== +# Doom Nvim installing/updating +# ============================= # {{{ update_repo() { if [[ -d "$HOME/.config/doom-nvim" ]]; then @@ -189,6 +189,15 @@ install_nvim_nightly() { log_success "Successfully installed Neovim Nightly under $HOME/.local/bin/ directory" } +install_packer() { + if [[ -d "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" ]]; then + log_info "Installing packer plugin manager ..." + # NOTE: stop installing that branch when merged into the main branch + git clone -q -b fix/premature-display-opening https://github.com/wbthomason/packer.nvim \ + $HOME/.local/share/nvim/site/pack/packer/start/packer.nvim + fi +} + install_fonts() { if [[ ! -d "$HOME/.local/share/fonts" ]]; then mkdir -p $HOME/.local/share/fonts @@ -324,6 +333,7 @@ main() { welcome check_all update_repo "main" + install_packer install_fonts backup_neovim install_done @@ -333,6 +343,7 @@ main() { welcome check_all update_repo "develop" + install_packer install_fonts backup_neovim install_done @@ -342,6 +353,7 @@ main() { welcome check_all update_repo "main" + install_packer backup_neovim install_nvim_nightly install_done @@ -368,6 +380,7 @@ main() { welcome check_all update_repo "main" + install_packer backup_neovim install_fonts check_requirements diff --git a/lua/doom/autocmds/init.lua b/lua/doom/autocmds/init.lua index fc813e8..180cf9f 100644 --- a/lua/doom/autocmds/init.lua +++ b/lua/doom/autocmds/init.lua @@ -10,8 +10,12 @@ local autocmds = { { 'BufNewFile,BufRead', 'doomrc', 'set ft=lua' }, -- Ensure every file does full syntax highlight { 'BufEnter', '*', ':syntax sync fromstart' }, - { 'BufEnter', '*', ':set signcolumn=yes'}, - { 'BufEnter', '*', ':set pumblend='..Doom.complete_transparency}, + { 'BufEnter', '*', ':set signcolumn=yes' }, + { + 'BufEnter', + '*', + ':set pumblend=' .. Doom.complete_transparency, + }, -- Compile new plugins changes at save { 'BufWritePost', @@ -45,6 +49,15 @@ if Doom.relative_num then }) end +-- Install plugins on launch +if Doom.auto_install_plugins then + table.insert(autocmds['doom_core'], { + 'VimEnter', + '*', + 'PackerInstall', + }) +end + -- Set autosave if Doom.autosave then table.insert(autocmds['doom_core'], { @@ -57,14 +70,22 @@ end -- Enable auto comment if not Doom.auto_comment then table.insert(autocmds['doom_core'], { - {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, + { + 'BufWinEnter', + '*', + 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o', + }, }) end -- Enable highlight on yank if Doom.highlight_yank then table.insert(autocmds['doom_core'], { - {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'}, + { + 'TextYankPost', + '*', + "lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})", + }, }) end diff --git a/lua/doom/config/init.lua b/lua/doom/config/init.lua index 2dee447..c751e96 100644 --- a/lua/doom/config/init.lua +++ b/lua/doom/config/init.lua @@ -4,7 +4,7 @@ -- License: MIT -- ---[[---------------------------------------]]--- -- Doom Nvim version -Doom_version = '2.3.1' +Doom_version = '2.3.2' -- Check if running Neovim or Vim and fails if: -- 1. Running Vim instead of Neovim @@ -21,21 +21,6 @@ else ) end --- If packer.nvim is not installed then install it and install core plugins after that -local packer_install_path = Fn.stdpath('data') - .. '/site/pack/packer/start/packer.nvim' -if Fn.empty(Fn.glob(packer_install_path)) > 0 then - Execute( - 'silent !git clone https://github.com/wbthomason/packer.nvim ' - .. packer_install_path - ) - Execute('packadd packer.nvim') - - -- Install plugins and then reload configs - Execute('PackerInstall') - Execute('luafile $MYVIMRC') -end - -- Set some configs on load if Fn.has('vim_starting') then -- Set encoding @@ -59,7 +44,9 @@ Default_options() require('plugins') require('doom.config.load_plugins') +-- Load the user-defined settings (global variables, autocmds, mappings) Custom_commands() + if Doom.check_updates then Check_updates() end diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 94a90d5..4b0d646 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -18,8 +18,6 @@ -- 2. We do not provide other LSP integration like coc.nvim, -- please refer to our FAQ to see why. ---- Set disabled plugins modules and plugins -local disabled_plugins = {} --- Disabled modules local disabled_git = Has_value(Doom.disabled_modules, 'git') local disabled_lsp = Has_value(Doom.disabled_modules, 'lsp') @@ -31,8 +29,12 @@ return packer.startup(function() -----[[------------]]----- --- Essentials --- -----]]------------[[----- - -- Plugins manager - use('wbthomason/packer.nvim') + -- Plugins manager, remove the branch field when that branch is merged + -- in the main branch. + use({ + 'wbthomason/packer.nvim', + branch = 'fix/premature-display-opening', + }) -- Auxiliar functions for using Lua in Neovim use('svermeulen/vimpeccable') @@ -40,9 +42,6 @@ return packer.startup(function() -- Tree-Sitter local disabled_treesitter = Has_value(Doom.disabled_plugins, 'treesitter') - if disabled_files and not disabled_treesitter then - table.insert(disabled_plugins, 'treesitter') - end use({ 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', @@ -63,21 +62,22 @@ return packer.startup(function() use({ 'glepnir/dashboard-nvim', disable = false }) -- Colorschemes - -- cannot be disabled at the moment + local disabled_colorschemes = + Has_value(Doom.disabled_plugins, 'colorschemes') use({ - 'sainnhe/sonokai', - 'sainnhe/edge', - 'sainnhe/everforest', - 'wadackel/vim-dogrun', - 'joshdick/onedark.vim', - 'ajmwagar/vim-deus', + { 'sainnhe/sonokai', disable = disabled_colorschemes }, + { 'sainnhe/edge', disable = disabled_colorschemes }, + { 'sainnhe/everforest', disable = disabled_colorschemes }, + { 'wadackel/vim-dogrun', disable = disabled_colorschemes }, + { + 'joshdick/onedark.vim', + disable = disabled_colorschemes, + }, + { 'ajmwagar/vim-deus', disable = disabled_colorschemes }, }) -- File tree local disabled_tree = Has_value(Doom.disabled_plugins, 'tree') - if disabled_tree then - table.insert(disabled_plugins, 'tree') - end use({ 'kyazdani42/nvim-tree.lua', requires = { 'kyazdani42/nvim-web-devicons' }, @@ -88,9 +88,6 @@ return packer.startup(function() -- can be disabled to use your own statusline local disabled_statusline = Has_value(Doom.disabled_plugins, 'statusline') - if disabled_statusline then - table.insert(disabled_plugins, 'statusline') - end use({ 'glepnir/galaxyline.nvim', disable = disabled_statusline, @@ -99,38 +96,26 @@ return packer.startup(function() -- Tabline -- can be disabled to use your own tabline local disabled_tabline = Has_value(Doom.disabled_plugins, 'tabline') - if disabled_tabline then - table.insert(disabled_plugins, 'tabline') - end use({ 'romgrk/barbar.nvim', disable = disabled_tabline }) -- Better terminal -- can be disabled to use your own terminal plugin local disabled_terminal = Has_value(Doom.disabled_plugins, 'terminal') - if disabled_terminal then - table.insert(disabled_plugins, 'terminal') - end use({ 'akinsho/nvim-toggleterm.lua', disable = disabled_terminal, }) -- Viewer & finder for LSP symbols and tags - local disabled_tagbar = Has_value(Doom.disabled_plugins, 'tagbar') - if disabled_tagbar then - table.insert(disabled_plugins, 'tagbar') - end + local disabled_outline = Has_value(Doom.disabled_plugins, 'outline') use({ 'simrat39/symbols-outline.nvim', - disable = disabled_tagbar, + disable = disabled_outline, }) -- Minimap -- Depends on wfxr/code-minimap to work! local disabled_minimap = Has_value(Doom.disabled_plugins, 'minimap') - if disabled_minimap then - table.insert(disabled_plugins, 'minimap') - end use({ 'wfxr/minimap.vim', disable = disabled_minimap }) -- Keybindings menu like Emacs's guide-key @@ -139,9 +124,6 @@ return packer.startup(function() -- Distraction free environment local disabled_zen = Has_value(Doom.disabled_plugins, 'zen') - if disabled_zen then - table.insert(disabled_plugins, 'zen') - end use({ 'kdav5758/TrueZen.nvim', disable = disabled_zen }) -----[[--------------]]----- @@ -159,9 +141,6 @@ return packer.startup(function() -- Git gutter better alternative, written in Lua -- can be disabled to use your own git gutter plugin local disabled_gitsigns = Has_value(Doom.disabled_plugins, 'gitsigns') - if disabled_git and not disabled_gitsigns then - table.insert(disabled_plugins, 'gitsigns') - end use({ 'lewis6991/gitsigns.nvim', disable = (disabled_git and true or disabled_gitsigns), @@ -169,9 +148,6 @@ return packer.startup(function() -- LazyGit integration local disabled_lazygit = Has_value(Doom.disabled_plugins, 'lazygit') - if disabled_git and not disabled_lazygit then - table.insert(disabled_plugins, 'lazygit') - end use({ 'kdheepak/lazygit.nvim', requires = { 'nvim-lua/plenary.nvim' }, @@ -184,9 +160,6 @@ return packer.startup(function() -- Built-in LSP Config -- NOTE: It should not be disabled if you are going to use LSP! local disabled_lspconfig = Has_value(Doom.disabled_plugins, 'lspconfig') - if disabled_lsp and not disabled_lspconfig then - table.insert(disabled_plugins, 'lspconfig') - end use({ 'neovim/nvim-lspconfig', disable = (disabled_lsp and true or disabled_lspconfig), @@ -194,9 +167,6 @@ return packer.startup(function() -- Completion plugin -- can be disabled to use your own completion plugin local disabled_compe = Has_value(Doom.disabled_plugins, 'compe') - if disabled_lsp and not disabled_compe then - table.insert(disabled_plugins, 'compe') - end use({ 'hrsh7th/nvim-compe', requires = { @@ -207,21 +177,20 @@ return packer.startup(function() disable = (disabled_lsp and true or disabled_compe), }) - -- install lsp saga - local disabled_lspsaga = - Has_value(Doom.disabled_plugins, 'lspsaga') - if disabled_lsp and not disabled_lspsaga then - table.insert(disabled_plugins, 'lspsaga') - end - use({'glepnir/lspsaga.nvim', disable = (disabled_lsp and true or disabled_lspsaga) }) + -- install lsp saga + local disabled_lspsaga = Has_value(Doom.disabled_plugins, 'lspsaga') + use({ + 'glepnir/lspsaga.nvim', + disable = (disabled_lsp and true or disabled_lspsaga), + }) -- provides the missing `:LspInstall` for `nvim-lspconfig`. local disabled_lspinstall = Has_value(Doom.disabled_plugins, 'lspinstall') - if disabled_lsp and not disabled_lspinstall then - table.insert(disabled_plugins, 'lspinstall') - end - use('kabouzeid/nvim-lspinstall') + use({ + 'kabouzeid/nvim-lspinstall', + disable = (disabled_lsp and true or disabled_lspinstall), + }) -----[[--------------]]----- --- File Related --- @@ -229,9 +198,6 @@ return packer.startup(function() -- Write / Read files without permissions (e.G. /etc files) without having -- to use `sudo nvim /path/to/file` local disabled_suda = Has_value(Doom.disabled_plugins, 'suda') - if disabled_files and not disabled_suda then - table.insert(disabled_plugins, 'suda') - end use({ 'lambdalisue/suda.vim', disable = (disabled_files and true or disabled_suda), @@ -240,9 +206,6 @@ return packer.startup(function() -- File formatting -- can be disabled to use your own file formatter local disabled_formatter = Has_value(Doom.disabled_plugins, 'formatter') - if disabled_files and not disabled_formatter then - table.insert(disabled_plugins, 'formatter') - end use({ 'lukas-reineke/format.nvim', disable = (disabled_files and true or disabled_formatter), @@ -251,9 +214,6 @@ return packer.startup(function() -- Autopairs -- can be disabled to use your own autopairs local disabled_autopairs = Has_value(Doom.disabled_plugins, 'autopairs') - if disabled_files and not disabled_autopairs then - table.insert(disabled_plugins, 'autopairs') - end use({ 'steelsojka/pears.nvim', disable = (disabled_files and true or disabled_autopairs), @@ -262,9 +222,6 @@ return packer.startup(function() -- Indent Lines local disabled_indent_lines = Has_value(Doom.disabled_plugins, 'indentlines') - if disabled_files and not disabled_indent_lines then - table.insert(disabled_plugins, 'indentlines') - end use({ 'lukas-reineke/indent-blankline.nvim', branch = 'lua', @@ -274,9 +231,6 @@ return packer.startup(function() -- EditorConfig support local disabled_editorconfig = Has_value(Doom.disabled_plugins, 'editorconfig') - if disabled_files and not disabled_editorconfig then - table.insert(disabled_plugins, 'editorconfig') - end use({ 'editorconfig/editorconfig-vim', disable = (disabled_files and true or disabled_editorconfig), @@ -286,9 +240,6 @@ return packer.startup(function() -- can be disabled to use your own comments plugin local disabled_kommentary = Has_value(Doom.disabled_plugins, 'kommentary') - if disabled_files and not disabled_kommentary then - table.insert(disabled_plugins, 'kommentary') - end use({ 'b3nj5m1n/kommentary', disable = (disabled_files and true or disabled_kommentary), @@ -299,9 +250,6 @@ return packer.startup(function() -----]]-------------[[----- -- Fastest colorizer without external dependencies! local disabled_colorizer = Has_value(Doom.disabled_plugins, 'colorizer') - if disabled_web and not disabled_colorizer then - table.insert(disabled_plugins, 'colorizer') - end use({ 'norcalli/nvim-colorizer.lua', disable = (disabled_web and true or disabled_colorizer), @@ -311,9 +259,6 @@ return packer.startup(function() -- Depends on bayne/dot-http to work! local disabled_restclient = Has_value(Doom.disabled_plugins, 'restclient') - if disabled_web and not disabled_restclient then - table.insert(disabled_plugins, 'restclient') - end use({ 'bayne/vim-dot-http', disable = (disabled_web and true or disabled_restclient), @@ -321,9 +266,6 @@ return packer.startup(function() -- Emmet plugin local disabled_emmet = Has_value(Doom.disabled_plugins, 'emmet') - if disabled_web and not disabled_emmet then - table.insert(disabled_plugins, 'emmet') - end use({ 'mattn/emmet-vim', disable = (disabled_web and true or disabled_emmet),