mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-01 16:45:00 +02:00
Split plugin loading logic from the configuration (#796)
This commit is contained in:
parent
56f17cebd4
commit
6f9c521e22
3 changed files with 113 additions and 92 deletions
7
init.lua
7
init.lua
|
@ -4,9 +4,14 @@ if not status_ok then
|
||||||
print "something is wrong with your lv-config"
|
print "something is wrong with your lv-config"
|
||||||
print(error)
|
print(error)
|
||||||
end
|
end
|
||||||
|
|
||||||
require "keymappings"
|
require "keymappings"
|
||||||
require "plugins"
|
|
||||||
|
local plugins = require "plugins"
|
||||||
|
local plugin_loader = require("plugin-loader").init()
|
||||||
|
plugin_loader:load { plugins, O.user_plugins }
|
||||||
vim.g.colors_name = O.colorscheme -- Colorscheme must get called after plugins are loaded or it will break new installs.
|
vim.g.colors_name = O.colorscheme -- Colorscheme must get called after plugins are loaded or it will break new installs.
|
||||||
|
|
||||||
require "settings"
|
require "settings"
|
||||||
require "lv-utils"
|
require "lv-utils"
|
||||||
|
|
||||||
|
|
46
lua/plugin-loader.lua
Normal file
46
lua/plugin-loader.lua
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
local plugin_loader = {}
|
||||||
|
|
||||||
|
function plugin_loader:init()
|
||||||
|
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
|
||||||
|
execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
|
||||||
|
execute "packadd packer.nvim"
|
||||||
|
end
|
||||||
|
|
||||||
|
local packer_ok, packer = pcall(require, "packer")
|
||||||
|
if not packer_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
packer.init {
|
||||||
|
-- package_root = require("packer.util").join_paths(vim.fn.stdpath "data", "lvim", "pack"),
|
||||||
|
git = { clone_timeout = 300 },
|
||||||
|
display = {
|
||||||
|
open_fn = function()
|
||||||
|
return require("packer.util").float { border = "single" }
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
self.packer = packer
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function plugin_loader:load(configurations)
|
||||||
|
return self.packer.startup(function(use)
|
||||||
|
for _, plugins in ipairs(configurations) do
|
||||||
|
for _, plugin in ipairs(plugins) do
|
||||||
|
use(plugin)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
init = function()
|
||||||
|
return plugin_loader:init()
|
||||||
|
end,
|
||||||
|
}
|
152
lua/plugins.lua
152
lua/plugins.lua
|
@ -1,101 +1,76 @@
|
||||||
local execute = vim.api.nvim_command
|
return {
|
||||||
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
|
|
||||||
execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
|
|
||||||
execute "packadd packer.nvim"
|
|
||||||
end
|
|
||||||
|
|
||||||
local packer_ok, packer = pcall(require, "packer")
|
|
||||||
if not packer_ok then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
packer.init {
|
|
||||||
-- package_root = require("packer.util").join_paths(vim.fn.stdpath "data", "lvim", "pack"),
|
|
||||||
git = { clone_timeout = 300 },
|
|
||||||
display = {
|
|
||||||
open_fn = function()
|
|
||||||
return require("packer.util").float { border = "single" }
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return require("packer").startup(function(use)
|
|
||||||
-- Packer can manage itself as an optional plugin
|
-- Packer can manage itself as an optional plugin
|
||||||
use "wbthomason/packer.nvim"
|
{ "wbthomason/packer.nvim" },
|
||||||
|
|
||||||
-- TODO: refactor all of this (for now it works, but yes I know it could be wrapped in a simpler function)
|
-- TODO: refactor all of this (for now it works, but yes I know it could be wrapped in a simpler function)
|
||||||
use { "neovim/nvim-lspconfig" }
|
{ "neovim/nvim-lspconfig" },
|
||||||
use {
|
{
|
||||||
"kabouzeid/nvim-lspinstall",
|
"kabouzeid/nvim-lspinstall",
|
||||||
event = "VimEnter",
|
event = "VimEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("lspinstall").setup()
|
require("lspinstall").setup()
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
use { "nvim-lua/popup.nvim" }
|
{ "nvim-lua/popup.nvim" },
|
||||||
use { "nvim-lua/plenary.nvim" }
|
{ "nvim-lua/plenary.nvim" },
|
||||||
use { "tjdevries/astronauta.nvim" }
|
{ "tjdevries/astronauta.nvim" },
|
||||||
|
|
||||||
-- Telescope
|
-- Telescope
|
||||||
use {
|
{
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
config = [[require('core.telescope').setup()]],
|
config = [[require('core.telescope').setup()]],
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Autocomplete
|
-- Autocomplete
|
||||||
use {
|
{
|
||||||
"hrsh7th/nvim-compe",
|
"hrsh7th/nvim-compe",
|
||||||
-- event = "InsertEnter",
|
-- event = "InsertEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("core.compe").setup()
|
require("core.compe").setup()
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Autopairs
|
-- Autopairs
|
||||||
use {
|
{
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
-- event = "InsertEnter",
|
-- event = "InsertEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require "core.autopairs"
|
require "core.autopairs"
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Snippets
|
-- Snippets
|
||||||
|
|
||||||
use { "hrsh7th/vim-vsnip", event = "InsertEnter" }
|
{ "hrsh7th/vim-vsnip", event = "InsertEnter" },
|
||||||
use { "rafamadriz/friendly-snippets", event = "InsertEnter" }
|
{ "rafamadriz/friendly-snippets", event = "InsertEnter" },
|
||||||
|
|
||||||
-- Treesitter
|
-- Treesitter
|
||||||
use {
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
config = function()
|
config = function()
|
||||||
require("core.treesitter").setup()
|
require("core.treesitter").setup()
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Formatter.nvim
|
-- Formatter.nvim
|
||||||
use {
|
{
|
||||||
"mhartington/formatter.nvim",
|
"mhartington/formatter.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require "core.formatter"
|
require "core.formatter"
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Linter
|
-- Linter
|
||||||
use {
|
{
|
||||||
"mfussenegger/nvim-lint",
|
"mfussenegger/nvim-lint",
|
||||||
config = function()
|
config = function()
|
||||||
require("core.linter").setup()
|
require("core.linter").setup()
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- NvimTree
|
-- NvimTree
|
||||||
use {
|
{
|
||||||
"kyazdani42/nvim-tree.lua",
|
"kyazdani42/nvim-tree.lua",
|
||||||
-- event = "BufWinOpen",
|
-- event = "BufWinOpen",
|
||||||
-- cmd = "NvimTreeToggle",
|
-- cmd = "NvimTreeToggle",
|
||||||
|
@ -103,28 +78,28 @@ return require("packer").startup(function(use)
|
||||||
config = function()
|
config = function()
|
||||||
require("core.nvimtree").setup()
|
require("core.nvimtree").setup()
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
use {
|
{
|
||||||
"lewis6991/gitsigns.nvim",
|
"lewis6991/gitsigns.nvim",
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
require("core.gitsigns").setup()
|
require("core.gitsigns").setup()
|
||||||
end,
|
end,
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
}
|
},
|
||||||
|
|
||||||
-- whichkey
|
-- whichkey
|
||||||
use {
|
{
|
||||||
"folke/which-key.nvim",
|
"folke/which-key.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("core.which-key").setup()
|
require("core.which-key").setup()
|
||||||
end,
|
end,
|
||||||
event = "BufWinEnter",
|
event = "BufWinEnter",
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Comments
|
-- Comments
|
||||||
use {
|
{
|
||||||
"terrortylor/nvim-comment",
|
"terrortylor/nvim-comment",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = function()
|
||||||
|
@ -134,89 +109,89 @@ return require("packer").startup(function(use)
|
||||||
end
|
end
|
||||||
nvim_comment.setup()
|
nvim_comment.setup()
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- vim-rooter
|
-- vim-rooter
|
||||||
use {
|
{
|
||||||
"airblade/vim-rooter",
|
"airblade/vim-rooter",
|
||||||
config = function()
|
config = function()
|
||||||
vim.g.rooter_silent_chdir = 1
|
vim.g.rooter_silent_chdir = 1
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Icons
|
-- Icons
|
||||||
use { "kyazdani42/nvim-web-devicons" }
|
{ "kyazdani42/nvim-web-devicons" },
|
||||||
|
|
||||||
-- Status Line and Bufferline
|
-- Status Line and Bufferline
|
||||||
use {
|
{
|
||||||
"glepnir/galaxyline.nvim",
|
"glepnir/galaxyline.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require "core.galaxyline"
|
require "core.galaxyline"
|
||||||
end,
|
end,
|
||||||
event = "BufWinEnter",
|
event = "BufWinEnter",
|
||||||
disable = not O.plugin.galaxyline.active,
|
disable = not O.plugin.galaxyline.active,
|
||||||
}
|
},
|
||||||
|
|
||||||
use {
|
{
|
||||||
"romgrk/barbar.nvim",
|
"romgrk/barbar.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require "core.bufferline"
|
require "core.bufferline"
|
||||||
end,
|
end,
|
||||||
event = "BufWinEnter",
|
event = "BufWinEnter",
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Debugging
|
-- Debugging
|
||||||
use {
|
{
|
||||||
"mfussenegger/nvim-dap",
|
"mfussenegger/nvim-dap",
|
||||||
-- event = "BufWinEnter",
|
-- event = "BufWinEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("core.dap").setup()
|
require("core.dap").setup()
|
||||||
end,
|
end,
|
||||||
disable = not O.plugin.dap.active,
|
disable = not O.plugin.dap.active,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Debugger management
|
-- Debugger management
|
||||||
use {
|
{
|
||||||
"Pocco81/DAPInstall.nvim",
|
"Pocco81/DAPInstall.nvim",
|
||||||
-- event = "BufWinEnter",
|
-- event = "BufWinEnter",
|
||||||
-- event = "BufRead",
|
-- event = "BufRead",
|
||||||
disable = not O.plugin.dap.active,
|
disable = not O.plugin.dap.active,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Builtins, these do not load by default
|
-- Builtins, these do not load by default
|
||||||
|
|
||||||
-- Dashboard
|
-- Dashboard
|
||||||
use {
|
{
|
||||||
"ChristianChiarulli/dashboard-nvim",
|
"ChristianChiarulli/dashboard-nvim",
|
||||||
event = "BufWinEnter",
|
event = "BufWinEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("core.dashboard").setup()
|
require("core.dashboard").setup()
|
||||||
end,
|
end,
|
||||||
disable = not O.plugin.dashboard.active,
|
disable = not O.plugin.dashboard.active,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- TODO: remove in favor of akinsho/nvim-toggleterm.lua
|
-- TODO: remove in favor of akinsho/nvim-toggleterm.lua
|
||||||
-- Floating terminal
|
-- Floating terminal
|
||||||
-- use {
|
-- {
|
||||||
-- "numToStr/FTerm.nvim",
|
-- "numToStr/FTerm.nvim",
|
||||||
-- event = "BufWinEnter",
|
-- event = "BufWinEnter",
|
||||||
-- config = function()
|
-- config = function()
|
||||||
-- require("core.floatterm").setup()
|
-- require("core.floatterm").setup()
|
||||||
-- end,
|
-- end,
|
||||||
-- disable = not O.plugin.floatterm.active,
|
-- disable = not O.plugin.floatterm.active,
|
||||||
-- }
|
-- },
|
||||||
|
|
||||||
use {
|
{
|
||||||
"akinsho/nvim-toggleterm.lua",
|
"akinsho/nvim-toggleterm.lua",
|
||||||
event = "BufWinEnter",
|
event = "BufWinEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("core.terminal").setup()
|
require("core.terminal").setup()
|
||||||
end,
|
end,
|
||||||
disable = not O.plugin.terminal.active,
|
disable = not O.plugin.terminal.active,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Zen Mode
|
-- Zen Mode
|
||||||
use {
|
{
|
||||||
"folke/zen-mode.nvim",
|
"folke/zen-mode.nvim",
|
||||||
cmd = "ZenMode",
|
cmd = "ZenMode",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
|
@ -224,28 +199,28 @@ return require("packer").startup(function(use)
|
||||||
require("core.zen").setup()
|
require("core.zen").setup()
|
||||||
end,
|
end,
|
||||||
disable = not O.plugin.zen.active,
|
disable = not O.plugin.zen.active,
|
||||||
}
|
},
|
||||||
|
|
||||||
---------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- LANGUAGE SPECIFIC GOES HERE
|
-- LANGUAGE SPECIFIC GOES HERE
|
||||||
use {
|
{
|
||||||
"lervag/vimtex",
|
"lervag/vimtex",
|
||||||
ft = "tex",
|
ft = "tex",
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Rust tools
|
-- Rust tools
|
||||||
-- TODO: use lazy loading maybe?
|
-- TODO: use lazy loading maybe?
|
||||||
use {
|
{
|
||||||
"simrat39/rust-tools.nvim",
|
"simrat39/rust-tools.nvim",
|
||||||
disable = not O.lang.rust.rust_tools.active,
|
disable = not O.lang.rust.rust_tools.active,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Elixir
|
-- Elixir
|
||||||
use { "elixir-editors/vim-elixir", ft = { "elixir", "eelixir", "euphoria3" } }
|
{ "elixir-editors/vim-elixir", ft = { "elixir", "eelixir", "euphoria3" } },
|
||||||
|
|
||||||
-- Javascript / Typescript
|
-- Javascript / Typescript
|
||||||
use {
|
{
|
||||||
"jose-elias-alvarez/nvim-lsp-ts-utils",
|
"jose-elias-alvarez/nvim-lsp-ts-utils",
|
||||||
ft = {
|
ft = {
|
||||||
"javascript",
|
"javascript",
|
||||||
|
@ -255,23 +230,18 @@ return require("packer").startup(function(use)
|
||||||
"typescriptreact",
|
"typescriptreact",
|
||||||
"typescript.tsx",
|
"typescript.tsx",
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Java
|
-- Java
|
||||||
use {
|
{
|
||||||
"mfussenegger/nvim-jdtls",
|
"mfussenegger/nvim-jdtls",
|
||||||
-- ft = { "java" },
|
-- ft = { "java" },
|
||||||
disable = not O.lang.java.java_tools.active,
|
disable = not O.lang.java.java_tools.active,
|
||||||
}
|
},
|
||||||
|
|
||||||
-- Scala
|
-- Scala
|
||||||
use {
|
{
|
||||||
"scalameta/nvim-metals",
|
"scalameta/nvim-metals",
|
||||||
disable = not O.lang.scala.metals.active,
|
disable = not O.lang.scala.metals.active,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
-- Install user plugins
|
|
||||||
for _, plugin in pairs(O.user_plugins) do
|
|
||||||
packer.use(plugin)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue