[2/4] Refactor: plugins: Handle packer seperatly | Changes for configs
eg: require "plugins.neoscroll" instead of require "plugins.neoscroll".config() second commit of refactor handle require errors handle cloning of packer
This commit is contained in:
parent
d16ffabcfd
commit
3e83ec5314
45
lua/packerInit.lua
Normal file
45
lua/packerInit.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
local packer
|
||||||
|
if
|
||||||
|
not pcall(
|
||||||
|
function()
|
||||||
|
packer = require "packer"
|
||||||
|
end
|
||||||
|
)
|
||||||
|
then
|
||||||
|
local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||||
|
|
||||||
|
print("Cloning packer..")
|
||||||
|
-- remove the dir before cloning
|
||||||
|
vim.fn.delete(packer_path, "rf")
|
||||||
|
vim.fn.system(
|
||||||
|
{
|
||||||
|
"git",
|
||||||
|
"clone",
|
||||||
|
"https://github.com/wbthomason/packer.nvim",
|
||||||
|
"--depth",
|
||||||
|
"20",
|
||||||
|
packer_path
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if pcall(
|
||||||
|
function()
|
||||||
|
packer = require "packer"
|
||||||
|
end
|
||||||
|
)
|
||||||
|
then
|
||||||
|
print("Packer cloned successfully.")
|
||||||
|
else
|
||||||
|
error("Couldn't clone packer !\nPacker path: " .. packer_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return packer.init {
|
||||||
|
display = {
|
||||||
|
open_fn = function()
|
||||||
|
return require("packer.util").float {border = "single"}
|
||||||
|
end
|
||||||
|
},
|
||||||
|
git = {
|
||||||
|
clone_timeout = 600 -- Timeout, in seconds, for git clones
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,17 @@
|
|||||||
local packer = require("packer")
|
local packer
|
||||||
local use = packer.use
|
if
|
||||||
|
pcall(
|
||||||
packer.init {
|
function()
|
||||||
display = {
|
require "packerInit"
|
||||||
open_fn = function()
|
|
||||||
return require("packer.util").float {border = "single"}
|
|
||||||
end
|
end
|
||||||
},
|
)
|
||||||
git = {
|
then
|
||||||
clone_timeout = 600 -- Timeout, in seconds, for git clones
|
packer = require "packer"
|
||||||
}
|
else
|
||||||
}
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local use = packer.use
|
||||||
|
|
||||||
return packer.startup(
|
return packer.startup(
|
||||||
function()
|
function()
|
||||||
@ -21,7 +22,7 @@ return packer.startup(
|
|||||||
use {
|
use {
|
||||||
"glepnir/galaxyline.nvim",
|
"glepnir/galaxyline.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.statusline").config()
|
require "plugins.statusline"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,8 +33,7 @@ return packer.startup(
|
|||||||
"norcalli/nvim-colorizer.lua",
|
"norcalli/nvim-colorizer.lua",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = function()
|
||||||
require("colorizer").setup()
|
require "plugins.colorizer"
|
||||||
vim.cmd("ColorizerReloadAllBuffers")
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ return packer.startup(
|
|||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.treesitter").config()
|
require "plugins.treesitter"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ return packer.startup(
|
|||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
after = "nvim-lspinstall",
|
after = "nvim-lspinstall",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.lspconfig").config()
|
require "plugins.lspconfig"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ return packer.startup(
|
|||||||
"onsails/lspkind-nvim",
|
"onsails/lspkind-nvim",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = function()
|
||||||
require("lspkind").init()
|
require "plugins.lspkind"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ return packer.startup(
|
|||||||
"hrsh7th/nvim-compe",
|
"hrsh7th/nvim-compe",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.compe").config()
|
require "plugins.compe"
|
||||||
end,
|
end,
|
||||||
wants = {"LuaSnip"},
|
wants = {"LuaSnip"},
|
||||||
requires = {
|
requires = {
|
||||||
@ -81,7 +81,7 @@ return packer.startup(
|
|||||||
wants = "friendly-snippets",
|
wants = "friendly-snippets",
|
||||||
event = "InsertCharPre",
|
event = "InsertCharPre",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.compe").snippets()
|
require "plugins.luasnip"
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -98,14 +98,14 @@ return packer.startup(
|
|||||||
"kyazdani42/nvim-tree.lua",
|
"kyazdani42/nvim-tree.lua",
|
||||||
cmd = "NvimTreeToggle",
|
cmd = "NvimTreeToggle",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.nvimtree").config()
|
require "plugins.nvimtree"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"kyazdani42/nvim-web-devicons",
|
"kyazdani42/nvim-web-devicons",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.icons").config()
|
require "plugins.icons"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ return packer.startup(
|
|||||||
},
|
},
|
||||||
cmd = "Telescope",
|
cmd = "Telescope",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.telescope").config()
|
require "plugins.telescope"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ return packer.startup(
|
|||||||
"lewis6991/gitsigns.nvim",
|
"lewis6991/gitsigns.nvim",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.gitsigns").config()
|
require "plugins.gitsigns"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,13 +142,7 @@ return packer.startup(
|
|||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
after = "nvim-compe",
|
after = "nvim-compe",
|
||||||
config = function()
|
config = function()
|
||||||
require("nvim-autopairs").setup()
|
require "plugins.autopairs"
|
||||||
require("nvim-autopairs.completion.compe").setup(
|
|
||||||
{
|
|
||||||
map_cr = true,
|
|
||||||
map_complete = true -- insert () func completion
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +152,7 @@ return packer.startup(
|
|||||||
"terrortylor/nvim-comment",
|
"terrortylor/nvim-comment",
|
||||||
cmd = "CommentToggle",
|
cmd = "CommentToggle",
|
||||||
config = function()
|
config = function()
|
||||||
require("nvim_comment").setup()
|
require "plugins.comment"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +166,7 @@ return packer.startup(
|
|||||||
"SessionSave"
|
"SessionSave"
|
||||||
},
|
},
|
||||||
setup = function()
|
setup = function()
|
||||||
require("plugins.dashboard").config()
|
require "plugins.dashboard"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +176,7 @@ return packer.startup(
|
|||||||
use {
|
use {
|
||||||
"Pocco81/AutoSave.nvim",
|
"Pocco81/AutoSave.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.zenmode").autoSave()
|
require "plugins.autosave"
|
||||||
end,
|
end,
|
||||||
cond = function()
|
cond = function()
|
||||||
return vim.g.auto_save == true
|
return vim.g.auto_save == true
|
||||||
@ -194,7 +188,7 @@ return packer.startup(
|
|||||||
"karb94/neoscroll.nvim",
|
"karb94/neoscroll.nvim",
|
||||||
event = "WinScrolled",
|
event = "WinScrolled",
|
||||||
config = function()
|
config = function()
|
||||||
require("neoscroll").setup()
|
require "plugins.neoscroll"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +196,7 @@ return packer.startup(
|
|||||||
"Pocco81/TrueZen.nvim",
|
"Pocco81/TrueZen.nvim",
|
||||||
cmd = {"TZAtaraxis", "TZMinimalist", "TZFocus"},
|
cmd = {"TZAtaraxis", "TZMinimalist", "TZFocus"},
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.zenmode").config()
|
require "plugins.zenmode"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +206,7 @@ return packer.startup(
|
|||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
setup = function()
|
setup = function()
|
||||||
require("utils").blankline()
|
require "plugins.blankline"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user