nvim/lua/plugins.lua
2022-10-18 18:46:58 +02:00

115 lines
4.1 KiB
Lua

local function manage_plugins()
local plugins = {
["https://github.com/faerryn/plogins.nvim.git"] = {},
["https://github.com/tpope/vim-sensible.git"] = {},
["https://github.com/neovim/nvim-lspconfig.git"] = {},
["https://github.com/ojroques/nvim-hardline.git"] = {
packadd_hook = function()
require('hardline').setup()
end
},
["https://github.com/EdenEast/nightfox.nvim.git"] = {
packadd_hook = function()
require('nightfox').setup({
options = {
modules = {
gitgutter = true,
}
},
palettes = {
nightfox = {
bg0 = '#121212',
bg1 = '#161616',
bg2 = '#222222',
bg3 = '#282828',
bg4 = '#404040',
sel0 = "#2a2a2a",
sel1 = "#525253",
}
},
specs = {
nightfox = {
syntax = {
func = "red",
}
}
},
})
vim.o.termguicolors = true
vim.cmd("colorscheme nightfox")
end
},
-- COQ
["https://github.com/ms-jpq/coq_nvim.git"] = {},
["https://github.com/ms-jpq/coq.artifacts.git"] = {
packadd_after = { ["https://github.com/ms-jpq/coq_nvim.git"] = true }
},
-- LSP servers
["https://github.com/simrat39/rust-tools.nvim.git"] = {
packadd_after = { ["https://github.com/neovim/nvim-lspconfig.git"] = true,
["https://github.com/ms-jpq/coq_nvim.git"] = true},
packadd_hook = function()
local rt = require("rust-tools")
local coq = require("coq")
rt.setup(coq.lsp_ensure_capabilities({
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>",
rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a",
rt.code_action_group.code_action_group, { buffer = bufnr })
end,
},
}))
end
},
-- Git integration
["https://github.com/tpope/vim-fugitive.git"] = {},
["https://github.com/airblade/vim-gitgutter.git"] = {
packadd_after = { ["https://github.com/EdenEast/nightfox.nvim.git"] = true },
packadd_hook = function()
-- put sign in number column to avoid screen-shifting
vim.cmd('set signcolumn=number')
end
},
-- Syntax highlight
["https://github.com/bfrg/vim-cpp-modern.git"] = {},
}
local manager = require("plogins").manage(plugins)
vim.api.nvim_create_user_command("PloginsUpgrade",
manager.upgrade, {})
vim.api.nvim_create_user_command("PloginsAutoremove",
manager.autoremove, {})
end
local plogins_source = "https://github.com/faerryn/plogins.nvim.git"
local plogins_name = plogins_source:gsub("/", "%%")
local plogins_dir = ("%s/site/pack/plogins/opt/%s"):format((vim.fn.stdpath("data")),
plogins_name)
if not vim.loop.fs_stat(plogins_dir) then
vim.loop.spawn("git",
{ args = { "clone", "--depth", "1", plogins_source, plogins_dir } },
function(code, signal)
vim.defer_fn(function()
vim.cmd(("packadd %s"):format(vim.fn.fnameescape(plogins_name)))
manage_plugins()
end, 0)
end)
else
vim.cmd(("packadd %s"):format(vim.fn.fnameescape(plogins_name)))
manage_plugins()
end