From 05d57bba29a19888d1d0be39e475d25409f0425d Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Mon, 19 Jul 2021 06:19:27 +0530 Subject: [PATCH 1/4] packerInit: Clone packer at opt path as we are lazy loading move packadd to packerInit --- lua/packerInit.lua | 5 ++++- lua/pluginList.lua | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/packerInit.lua b/lua/packerInit.lua index c23706a..aa9101a 100644 --- a/lua/packerInit.lua +++ b/lua/packerInit.lua @@ -1,7 +1,9 @@ +vim.cmd("packadd packer.nvim") + local present, packer = pcall(require, "packer") if not present then - local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" + local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim" print("Cloning packer..") -- remove the dir before cloning @@ -17,6 +19,7 @@ if not present then } ) + vim.cmd("packadd packer.nvim") present, packer = pcall(require, "packer") if present then diff --git a/lua/pluginList.lua b/lua/pluginList.lua index d95c7cc..bd242cb 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -1,5 +1,3 @@ -vim.cmd [[packadd packer.nvim]] - local present, _ = pcall(require, "packerInit") if present then From 0023233eef912d6476e98f2c3c4de824bd70aa98 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Mon, 19 Jul 2021 06:28:28 +0530 Subject: [PATCH 2/4] Fix formatting | Handle a edgecase in telescope config | Misc * fix formatting in pluginList, luasnip * don't use pcall on highlights * sync and compile fzf and media files only when the error occurs, add a help text telling tbe user to restart neovim --- lua/options.lua | 2 +- lua/pluginList.lua | 50 +++++++++++++++++++++++++++++++-------- lua/plugins/luasnip.lua | 10 ++------ lua/plugins/telescope.lua | 5 +++- lua/theme.lua | 2 +- 5 files changed, 48 insertions(+), 21 deletions(-) diff --git a/lua/options.lua b/lua/options.lua index cd53fb9..a12332e 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -19,7 +19,7 @@ opt.clipboard = "unnamedplus" opt.shortmess:append("sI") -- disable tilde on end of buffer: https://github.com/ neovim/neovim/pull/8546#issuecomment-643643758 -vim.cmd [[let &fcs='eob: ']] +vim.cmd("let &fcs='eob: '") -- Numbers opt.number = true diff --git a/lua/pluginList.lua b/lua/pluginList.lua index bd242cb..56f197f 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -1,4 +1,5 @@ local present, _ = pcall(require, "packerInit") +local packer if present then packer = require "packer" @@ -10,9 +11,15 @@ local use = packer.use return packer.startup( function() - use {"wbthomason/packer.nvim", event = "VimEnter"} + use { + "wbthomason/packer.nvim", + event = "VimEnter" + } - use {"akinsho/nvim-bufferline.lua", after = "nvim-base16.lua"} + use { + "akinsho/nvim-bufferline.lua", + after = "nvim-base16.lua" + } use { "glepnir/galaxyline.nvim", @@ -76,7 +83,7 @@ return packer.startup( config = function() require "plugins.compe" end, - wants = {"LuaSnip"}, + wants = "LuaSnip", requires = { { "L3MON4D3/LuaSnip", @@ -93,7 +100,10 @@ return packer.startup( } } - use {"sbdchd/neoformat", cmd = "Neoformat"} + use { + "sbdchd/neoformat", + cmd = "Neoformat" + } -- file managing , picker etc use { @@ -112,8 +122,14 @@ return packer.startup( end } - use {"nvim-lua/plenary.nvim", event = "BufRead"} - use {"nvim-lua/popup.nvim", after = "plenary.nvim"} + use { + "nvim-lua/plenary.nvim", + event = "BufRead" + } + use { + "nvim-lua/popup.nvim", + after = "plenary.nvim" + } use { "nvim-telescope/telescope.nvim", @@ -123,7 +139,11 @@ return packer.startup( end } - use {"nvim-telescope/telescope-fzf-native.nvim", run = "make", cmd = "Telescope"} + use { + "nvim-telescope/telescope-fzf-native.nvim", + run = "make", + cmd = "Telescope" + } use { "nvim-telescope/telescope-media-files.nvim", cmd = "Telescope" @@ -147,7 +167,10 @@ return packer.startup( end } - use {"andymass/vim-matchup", event = "CursorMoved"} + use { + "andymass/vim-matchup", + event = "CursorMoved" + } use { "terrortylor/nvim-comment", @@ -171,7 +194,10 @@ return packer.startup( end } - use {"tweekmonster/startuptime.vim", cmd = "StartupTime"} + use { + "tweekmonster/startuptime.vim", + cmd = "StartupTime" + } -- load autosave only if its globally enabled use { @@ -195,7 +221,11 @@ return packer.startup( use { "Pocco81/TrueZen.nvim", - cmd = {"TZAtaraxis", "TZMinimalist", "TZFocus"}, + cmd = { + "TZAtaraxis", + "TZMinimalist", + "TZFocus" + }, config = function() require "plugins.zenmode" end diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua index 825c957..dc60d0a 100644 --- a/lua/plugins/luasnip.lua +++ b/lua/plugins/luasnip.lua @@ -1,11 +1,5 @@ -local luasnip -if - not pcall( - function() - luasnip = require "luasnip" - end - ) - then +local present, luasnip = pcall(require, "luasnip") +if not present then return end diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index c3799eb..0923c8c 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -76,5 +76,8 @@ if ) then -- This should only trigger when in need of PackerSync, so better do it - vim.cmd("PackerSync") + print("After completion of PackerSync, restart neovim.") + require("packer").sync("telescope-fzf-native.nvim", "telescope-media-files.nvim") + -- why compile too ? well, packer is supposed to compile with sync only, but sometimes it doesn't work + vim.cmd("PackerCompile") end diff --git a/lua/theme.lua b/lua/theme.lua index 8d90ec2..5356706 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -4,7 +4,7 @@ local present, base16 = pcall(require, "base16") if present then base16(base16.themes["onedark"], true) - pcall(require, "highlights") + require "highlights" return true else return false From 6b507c33682a935d6d92f4f0c15105fa7a67b69b Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Mon, 19 Jul 2021 06:40:38 +0530 Subject: [PATCH 3/4] init: Asynchronously load filetype and syntax lots of improvement for startup time Co-authored-by: Vhyrro --- lua/options.lua | 7 +++++++ lua/theme.lua | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lua/options.lua b/lua/options.lua index a12332e..2210681 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -1,6 +1,13 @@ local opt = vim.opt local g = vim.g +-- Turn these off at startup, will be enabled later just before loading the theme +vim.cmd([[ + syntax off + filetype off + filetype plugin indent off +]]) + opt.ruler = false opt.hidden = true opt.ignorecase = true diff --git a/lua/theme.lua b/lua/theme.lua index 5356706..85bf895 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -3,6 +3,13 @@ vim.g.nvchad_theme = "onedark" local present, base16 = pcall(require, "base16") if present then + -- enabled these options, was disabled in options.lua + vim.cmd([[ + syntax on + filetype on + filetype plugin indent on + ]]) + base16(base16.themes["onedark"], true) require "highlights" return true From 1e658562f0656f3bffe73a4a3c9dd4c152cc6cb2 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Mon, 19 Jul 2021 07:08:28 +0530 Subject: [PATCH 4/4] install.sh: Run PackerSync from script after install too as the corresponding code for that was removed from init.lua --- install.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/install.sh b/install.sh index fbb0bf1..401ce04 100755 --- a/install.sh +++ b/install.sh @@ -153,11 +153,7 @@ main() { if _NVIM="$(command -v nvim)"; then if _check_nvim_version; then printf "\n%s\n" "=> Neovim will now open." && sleep 1 - if [ "${_UPDATE}" = "false" ]; then - "${_NVIM}" +":lua require 'pluginList' vim.cmd('PackerSync')" - else - "${_NVIM}" - fi + "${_NVIM}" +":lua require 'pluginList' vim.cmd('PackerSync')" else printf "Error: Neovim is installed, but version is lower than 0.5.x, install Neovim >= 5.x and then run nvim & do :PackerSync\n." fi