WIP: Untested migration to Lazy.nvim

This commit is contained in:
ViViDboarder 2023-06-07 14:09:32 -07:00
parent 2e95001b5b
commit 9582927d6d

View File

@ -1,11 +1,19 @@
-- Install packer
local utils = require("utils") local utils = require("utils")
local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim" -- Lazy requires v0.8+
local packer_bootstrap = ""
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then -- Install Lazy.nvim
packer_bootstrap = vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path }) local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end end
vim.cmd("packadd packer.nvim") vim.opt.rtp:prepend(lazypath)
-- Configures dark-notify to use colors from my environment -- Configures dark-notify to use colors from my environment
local function config_dark_notify() local function config_dark_notify()
@ -17,135 +25,98 @@ local function config_dark_notify()
}) })
end end
local packer = require("packer")
local packer_util = require("packer.util")
local use = packer.use
packer.init({
-- Always load default
snapshot = utils.map_version_rule({
[">=0.9.0"] = "latest-0.9",
[">=0.8.0"] = "latest-0.8",
[">=0.7.0"] = "latest-0.7",
[">=0.5.0"] = "latest",
}),
snapshot_path = packer_util.join_paths(vim.fn.stdpath("config"), "packer_snapshots"),
display = {
open_fn = function()
return packer_util.float({ border = "single" })
end,
},
})
-- Load things faster!
if vim.fn.has("nvim-0.9.0") == 1 then if vim.fn.has("nvim-0.9.0") == 1 then
-- Not needed on nvim 0.9+
vim.loader.enable() vim.loader.enable()
else
use({
"lewis6991/impatient.nvim",
config = [[require('impatient')]],
tag = utils.map_version_rule({
[">=0.7.0"] = utils.nil_val,
[">0.6.0"] = "v0.2",
[">=0.5.0"] = "v0.1",
}),
})
end end
-- Let Packer manage and lazyload itself require("lazy").setup({
use({ {
"wbthomason/packer.nvim", -- Load faster!
cmd = { "lewis6991/impatient.nvim",
"PackerClean", config = function()
"PackerCompile", require("impatient")
"PackerInstall", end,
"PackerLoad", enabled = vim.fn.has("nvim-0.9.0") ~= 1,
"PackerProfile", lazy = false,
"PackerSnapshot", priority = 1001,
"PackerSnapshotDelete",
"PackerSnapshotRollback",
"PackerStatus",
"PackerSync",
"PackerUpdate",
}, },
config = [[require("plugins")]], {
}) "mhinz/vim-startify",
config = function()
-- Colorschemes require("utils").require_with_local("plugins.startify")
use({ end,
"vim-scripts/wombat256.vim", priority = 100,
},
-- Colorschemes
{ {
"ViViDboarder/wombat.nvim", "ViViDboarder/wombat.nvim",
requires = { dependencies = {
{
"rktjmp/lush.nvim", "rktjmp/lush.nvim",
tag = utils.map_version_rule({
[">=0.7.0"] = utils.nil_val,
[">=0.5.0"] = "v1.0.1",
}),
}, },
lazy = false,
priority = 1000,
}, },
{
"ViViDboarder/wombuddy.nvim",
dependencies = {
"tjdevries/colorbuddy.vim",
}, },
{ "ViViDboarder/wombuddy.nvim", requires = "tjdevries/colorbuddy.vim" }, lazy = false,
priority = 1000,
},
{
"ishan9299/nvim-solarized-lua", "ishan9299/nvim-solarized-lua",
lazy = false,
priority = 1000,
},
{ {
"folke/tokyonight.nvim", "folke/tokyonight.nvim",
run = 'fish -c \'echo "set --path --prepend fish_themes_path "(pwd)"/extras" > ~/.config/fish/conf.d/tokyonight.fish\' || true', -- luacheck: no max line length -- TODO: Maybe not do this if already present?
build = 'fish -c \'echo "set --path --prepend fish_themes_path "(pwd)"/extras" > ~/.config/fish/conf.d/tokyonight.fish\' || true', -- luacheck: no max line length
}, },
}) {
-- Auto and ends to some ifs and dos
use("tpope/vim-endwise")
-- Unix commands from vim? Yup!
use("tpope/vim-eunuch")
-- Adds repeats for custom motions
use("tpope/vim-repeat")
-- Readline shortcuts
use("tpope/vim-rsi")
-- Surround motions
use("tpope/vim-surround")
-- Better netrw
use("tpope/vim-vinegar")
-- Easier jumping to lines
use("vim-scripts/file-line")
-- Auto ctags generation
use("ludovicchabant/vim-gutentags")
-- Make it easier to discover some of my keymaps
use({
"folke/which-key.nvim", "folke/which-key.nvim",
config = function() config = function()
require("plugins.whichkey").configure() require("plugins.whichkey").configure()
end, end,
}) lazy = true,
},
-- Better commenting -- Auto and ends to some ifs and dos
use({ "tpope/vim-endwise",
-- Unix commands from vim? Yup!
"tpope/vim-eunuch",
-- Adds repeats for custom motions
"tpope/vim-repeat",
-- Readline shortcuts
"tpope/vim-rsi",
-- Surround motions
"tpope/vim-surround",
-- Better netrw
"tpope/vim-vinegar",
-- Easier jumping to lines
"vim-scripts/file-line",
-- Auto ctags generation
"ludovicchabant/vim-gutentags",
{
-- Better commenting
"tomtom/tcomment_vim", "tomtom/tcomment_vim",
config = function() config = function()
-- TODO: use which-key for mapping
vim.api.nvim_set_keymap("n", "//", ":TComment<CR>", { silent = true, noremap = true }) vim.api.nvim_set_keymap("n", "//", ":TComment<CR>", { silent = true, noremap = true })
vim.api.nvim_set_keymap("v", "//", ":TCommentBlock<CR>", { silent = true, noremap = true }) vim.api.nvim_set_keymap("v", "//", ":TCommentBlock<CR>", { silent = true, noremap = true })
end, end,
}) },
-- Allow wrapping and joining of arguments across multiple lines {
use({ -- Allow wrapping and joining of arguments across multiple lines
"FooSoft/vim-argwrap", "FooSoft/vim-argwrap",
config = function() config = function()
vim.api.nvim_set_keymap("n", "<Leader>a", "<cmd>ArgWrap<CR>", { silent = true, noremap = true }) vim.api.nvim_set_keymap("n", "<Leader>a", "<cmd>ArgWrap<CR>", { silent = true, noremap = true })
end, end,
}) },
{
-- Adds git operations to vim -- Adds git operations to vim
use({
"tpope/vim-fugitive", "tpope/vim-fugitive",
config = function() config = function()
local opts = { silent = true, noremap = true } local opts = { silent = true, noremap = true }
@ -155,76 +126,63 @@ use({
vim.api.nvim_set_keymap("n", "gs", "<cmd>Git<CR>", opts) vim.api.nvim_set_keymap("n", "gs", "<cmd>Git<CR>", opts)
vim.api.nvim_set_keymap("n", "gw", "<cmd>Git write<CR>", opts) vim.api.nvim_set_keymap("n", "gw", "<cmd>Git write<CR>", opts)
end, end,
}) },
{
-- Quick toggling of Location and Quickfix lists -- Quick toggling of Location and Quickfix lists
use({
"milkypostman/vim-togglelist", "milkypostman/vim-togglelist",
config = function() config = function()
vim.api.nvim_set_keymap("n", "<F6>", ":call ToggleQuickfixList()<CR>", { silent = true, noremap = true }) vim.api.nvim_set_keymap("n", "<F6>", ":call ToggleQuickfixList()<CR>", { silent = true, noremap = true })
vim.api.nvim_set_keymap("n", "<F7>", ":call ToggleLocationList()<CR>", { silent = true, noremap = true }) vim.api.nvim_set_keymap("n", "<F7>", ":call ToggleLocationList()<CR>", { silent = true, noremap = true })
end, end,
}) },
{
-- Find text everywhere! -- Find text everywhere!
use({
"mhinz/vim-grepper", "mhinz/vim-grepper",
config = function() config = function()
require("plugins.grepper") require("plugins.grepper")
end, end,
}) },
{
-- Highlight inline colors -- Highlight inline colors
use({
"norcalli/nvim-colorizer.lua", "norcalli/nvim-colorizer.lua",
config = function() config = function()
require("colorizer").setup() require("colorizer").setup()
end, end,
}) },
-- Status line
-- Custom status line {
use({ -- Custom status line
"SmiteshP/nvim-gps", "SmiteshP/nvim-gps",
requires = "nvim-treesitter/nvim-treesitter", dependencies = { "nvim-treesitter/nvim-treesitter" },
disable = vim.fn.has("nvim-0.7.0") == 1, enabled = vim.fn.has("nvim-0.7.0") ~= 1,
}) lazy = true,
-- Replaces gps for 0.7+ },
use({ {
-- Replaces gps for 0.7+
"SmiteshP/nvim-navic", "SmiteshP/nvim-navic",
requires = "neovim/nvim-lspconfig", dependencies = { "neovim/nvim-lspconfig" },
disable = vim.fn.has("nvim-0.7.0") ~= 1, enabled = vim.fn.has("nvim-0.7.0") == 1,
}) lazy = true,
},
use({ {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
config = function() config = function()
require("plugins.lualine").config_lualine() require("plugins.lualine").config_lualine()
end, end,
after = vim.fn.has("nvim-0.7.0") == 1 and "nvim-navic" or "nvim-gps", },
}) {
-- On Mac, update colors when dark mode changes
use({
"cormacrelf/dark-notify", "cormacrelf/dark-notify",
disable = not vim.g.is_mac, enabled = vim.g.is_mac,
-- Download latest release on install -- Download latest release on install
run = "curl -s https://api.github.com/repos/cormacrelf/dark-notify/releases/latest | jq '.assets[].browser_download_url' | xargs curl -Ls | tar xz -C ~/.local/bin/", -- luacheck: no max line length build = "curl -s https://api.github.com/repos/cormacrelf/dark-notify/releases/latest | jq '.assets[].browser_download_url' | xargs curl -Ls | tar xz -C ~/.local/bin/", -- luacheck: no max line length
config = config_dark_notify, config = config_dark_notify,
requires = "nvim-lualine/lualine.nvim", dependencies = {
}) "nvim-lualine/lualine.nvim",
},
-- Custom start screen },
use({ -- LSP
"mhinz/vim-startify", {
config = function() -- Configure language servers
require("utils").require_with_local("plugins.startify")
end,
})
-- LSP
-- Configure language servers
use({
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
tag = utils.map_version_rule({ tag = utils.map_version_rule({
-- [">=0.8.0"] = utils.nil_val, -- [">=0.8.0"] = utils.nil_val,
@ -232,40 +190,37 @@ use({
[">=0.6.1"] = "v0.1.2", [">=0.6.1"] = "v0.1.2",
[">=0.6.0"] = "v0.1.0", [">=0.6.0"] = "v0.1.0",
}), }),
}) },
{
-- Install language servers -- Install language servers
use({
"williamboman/mason.nvim", "williamboman/mason.nvim",
requires = { dependencies = {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
}, },
-- Only supports >=0.7.0 -- Only supports >=0.7.0
disable = vim.fn.has("nvim-0.7.0") ~= 1, enabled = vim.fn.has("nvim-0.7.0") == 1,
}) },
{
-- Lua dev for vim -- Lua dev for vim
use({
"folke/neodev.nvim", "folke/neodev.nvim",
requires = "neovim/nvim-lspconfig", dependencies = { "neovim/nvim-lspconfig" },
}) },
-- Better display of lsp diagnostics
-- Better display of lsp diagnostics "folke/trouble.nvim",
use("folke/trouble.nvim") {
-- Incremental lsp rename view
-- Incremental lsp rename view
use({
"smjonas/inc-rename.nvim", "smjonas/inc-rename.nvim",
--[[
config = function() config = function()
require("inc_rename").setup() require("inc_rename").setup()
end, end,
--]]
-- Only supports >=0.8.0 -- Only supports >=0.8.0
disable = vim.fn.has("nvim-0.8.0") ~= 1, enabled = vim.fn.has("nvim-0.8.0") == 1,
}) },
{
-- Generic linter/formatters in diagnostics API -- Generic linter/formatters in diagnostics API
use({
"jose-elias-alvarez/null-ls.nvim", "jose-elias-alvarez/null-ls.nvim",
branch = utils.map_version_rule({ branch = utils.map_version_rule({
[">=0.8.0"] = utils.nil_val, [">=0.8.0"] = utils.nil_val,
@ -279,30 +234,34 @@ use({
[">=0.5.1"] = "739a98c12bedaa2430c4a3c08d1d22ad6c16513e", [">=0.5.1"] = "739a98c12bedaa2430c4a3c08d1d22ad6c16513e",
[">=0.5.0"] = "3e7390735501d0507bf2c2b5c2e7a16f58deeb81", [">=0.5.0"] = "3e7390735501d0507bf2c2b5c2e7a16f58deeb81",
}), }),
requires = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, dependencies = {
}) "nvim-lua/plenary.nvim",
"neovim/nvim-lspconfig",
-- Writing },
-- abolish/pencil },
use({ -- Writing
{
-- abolish/pencil
"preservim/vim-pencil", "preservim/vim-pencil",
cmd = { "Pencil" }, cmd = { "Pencil" },
}) },
use({ {
"preservim/vim-textobj-sentence", "preservim/vim-textobj-sentence",
requires = "kana/vim-textobj-user", dependencies = { "kana/vim-textobj-user" },
}) },
use({ {
"junegunn/goyo.vim", "junegunn/goyo.vim",
cmd = { "Goyo", "Zen" }, cmd = { "Goyo", "Zen" },
config = [[require("plugins.goyo-limelight")]], config = function()
requires = { "junegunn/limelight.vim", cmd = "Limelight" }, require("plugins.goyo-limelight")
}) end,
dependencies = { "junegunn/limelight.vim", cmd = "Limelight" },
},
-- Treesitter -- Treesitter
use({ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
run = ":TSUpdate", build = ":TSUpdate",
commit = utils.map_version_rule({ commit = utils.map_version_rule({
[">=0.8.0"] = utils.nil_val, [">=0.8.0"] = utils.nil_val,
[">=0.7.0"] = "4cccb6f494eb255b32a290d37c35ca12584c74d0", [">=0.7.0"] = "4cccb6f494eb255b32a290d37c35ca12584c74d0",
@ -311,18 +270,18 @@ use({
config = function() config = function()
require("utils").require_with_local("plugins.treesitter").setup() require("utils").require_with_local("plugins.treesitter").setup()
end, end,
}) },
use({ {
"nvim-treesitter/nvim-treesitter-refactor", "nvim-treesitter/nvim-treesitter-refactor",
requires = "nvim-treesitter/nvim-treesitter", dependencies = { "nvim-treesitter/nvim-treesitter" },
}) },
use({ {
"nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter/nvim-treesitter-textobjects",
requires = "nvim-treesitter/nvim-treesitter", dependencies = { "nvim-treesitter/nvim-treesitter" },
}) },
-- Completion {
use({ -- Completion
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
config = function() config = function()
require("plugins.completion").config_cmp() require("plugins.completion").config_cmp()
@ -331,34 +290,29 @@ use({
[">=0.7.0"] = utils.nil_val, [">=0.7.0"] = utils.nil_val,
[">=0.5.0"] = "bba6fb67fdafc0af7c5454058dfbabc2182741f4", [">=0.5.0"] = "bba6fb67fdafc0af7c5454058dfbabc2182741f4",
}), }),
requires = { dependencies = {
{ "hrsh7th/cmp-nvim-lsp", after = "nvim-cmp" }, "hrsh7th/cmp-nvim-lsp",
{ "hrsh7th/cmp-buffer", after = "nvim-cmp" }, "hrsh7th/cmp-buffer",
{ "f3fora/cmp-spell", after = "nvim-cmp" }, "f3fora/cmp-spell",
{ {
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
after = "nvim-cmp", dependencies = {
commit = utils.map_version_rule({
[">0.7.0"] = utils.nil_val,
[">=0.5.0"] = "b10829736542e7cc9291e60bab134df1273165c9",
}),
},
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
}, },
},
},
event = "InsertEnter *", event = "InsertEnter *",
}) },
-- Add snippets
-- Add snippets {
use({
"rafamadriz/friendly-snippets", "rafamadriz/friendly-snippets",
requires = "L3MON4D3/LuaSnip", dependencies = { "L3MON4D3/LuaSnip" },
after = "LuaSnip", -- after = "LuaSnip",
config = function() config = function()
require("luasnip.loaders.from_vscode").load() require("luasnip.loaders.from_vscode").load()
end, end,
}) },
{
use({
"ray-x/lsp_signature.nvim", "ray-x/lsp_signature.nvim",
config = function() config = function()
require("lsp_signature").setup({ require("lsp_signature").setup({
@ -369,12 +323,11 @@ use({
hint_enable = false, hint_enable = false,
}) })
end, end,
}) },
{
-- Fuzzy Finder -- Fuzzy Finder
use({
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
requires = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"nvim-lua/popup.nvim", "nvim-lua/popup.nvim",
"nvim-telescope/telescope-file-browser.nvim", "nvim-telescope/telescope-file-browser.nvim",
@ -389,13 +342,12 @@ use({
config = function() config = function()
require("plugins.telescope") require("plugins.telescope")
end, end,
}) },
-- Filetypes
-- Filetypes "ViViDboarder/vim-forcedotcom",
use("ViViDboarder/vim-forcedotcom") "rust-lang/rust.vim",
use("rust-lang/rust.vim") "hsanson/vim-android",
use("hsanson/vim-android") {
use({
"sheerun/vim-polyglot", "sheerun/vim-polyglot",
config = function() config = function()
vim.cmd([[ vim.cmd([[
@ -405,34 +357,33 @@ use({
augroup end augroup end
]]) ]])
end, end,
}) },
{
-- Debuging nvim config -- Debuging nvim config
use({
"tweekmonster/startuptime.vim", "tweekmonster/startuptime.vim",
cmd = { "StartupTime" }, cmd = { "StartupTime" },
}) },
{
-- Fancy todo highlighting -- Fancy todo highlighting
use({
"folke/todo-comments.nvim", "folke/todo-comments.nvim",
requires = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
}, },
config = function() config = function()
require("plugins.todo") require("plugins.todo")
end, end,
}) },
{
-- Fancy notifications -- Fancy notifications
use({
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
config = function() config = function()
require("plugins.notify") require("plugins.notify")
end, end,
},
}, {
-- Use version specific lockfiles
lockfile = vim.fn.stdpath("config") .. "/lazy-lock-" .. utils.map_version_rule({
[">=0.9.0"] = "0.9",
[">=0.8.0"] = "0.8",
}) .. ".json",
}) })
-- Auto sync after bootstrapping on a fresh box
if packer_bootstrap ~= "" then
packer.sync()
end