cleanup init.lua and do a dependency snapshot

This commit is contained in:
Tony Blyler 2024-10-01 10:30:35 -04:00
parent 88aeb6ae5e
commit 386191c764
No known key found for this signature in database
2 changed files with 168 additions and 112 deletions

View file

@ -1,3 +1,5 @@
-- {{{ Setup mini.nvim's dep manager
-- Clone 'mini.nvim' manually in a way that it gets managed by 'mini.deps' -- Clone 'mini.nvim' manually in a way that it gets managed by 'mini.deps'
local path_package = vim.fn.stdpath('data') .. '/site/' local path_package = vim.fn.stdpath('data') .. '/site/'
local mini_path = path_package .. 'pack/deps/start/mini.nvim' local mini_path = path_package .. 'pack/deps/start/mini.nvim'
@ -13,16 +15,27 @@ if not vim.loop.fs_stat(mini_path) then
end end
-- Set up 'mini.deps' (customize to your liking) -- Set up 'mini.deps' (customize to your liking)
require('mini.deps').setup({ path = { package = path_package } }) require('mini.deps').setup({
path = {
package = path_package,
},
})
-- }}}
-- {{{ helper functions
-- Use 'mini.deps'. `now()` and `later()` are helpers for a safe two-stage -- Use 'mini.deps'. `now()` and `later()` are helpers for a safe two-stage
-- startup and are optional. -- startup and are optional.
local add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later local add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later
-- vim options local function colorscheme_exists(colorscheme)
local success, _ = pcall(vim.cmd, 'colorscheme ' .. colorscheme)
return success
end
-- }}}
-- {{{ vim options
now(function() now(function()
local opts = { local opts = {
termguicolors = true, -- enable 24 bit colors
-- tabs look like 4 spaces { -- tabs look like 4 spaces {
expandtab = true, expandtab = true,
tabstop = 4, tabstop = 4,
@ -39,17 +52,18 @@ now(function()
ruler = true, -- show ruler on page ruler = true, -- show ruler on page
lazyredraw = true, -- make large file bearable lazyredraw = true, -- make large file bearable
regexpengine = 1, -- make searching large files bearable regexpengine = 1, -- make searching large files bearable
background = 'dark' -- use dark theme foldmethod = 'marker', -- fold by using the parenthesis tags
} }
for opt, val in pairs(opts) do for opt, val in pairs(opts) do
vim.o[opt] = val vim.o[opt] = val
end end
end) end)
-- }}} vim options
-- color themes -- {{{ color themes
now(function() now(function()
-- gruvbox { -- {{{ gruvbox
add({ add({
source = 'ellisonleao/gruvbox.nvim', source = 'ellisonleao/gruvbox.nvim',
}) })
@ -57,77 +71,99 @@ now(function()
require('gruvbox').setup({ require('gruvbox').setup({
contrast = 'hard' contrast = 'hard'
}) })
-- } gruvbox vim.api.nvim_create_user_command(
'GruvboxDark',
function(opts)
vim.o.background = 'dark'
vim.cmd.colorscheme('gruvbox')
end,
{}
)
-- dracula { vim.api.nvim_create_user_command(
'GruvboxLight',
function(opts)
vim.o.background = 'light'
vim.cmd.colorscheme('gruvbox')
end,
{}
)
-- }}}
-- {{{ dracula
add({ add({
source = 'maxmx03/dracula.nvim', source = 'ssh://git@git.0xdad.com/tblyler/dracula-pro.vim.git',
checkout = '2f396b6ba988ad4b3961c2e40d1b9ae436b8c26c',
depends = {
'ssh://git@git.0xdad.com/tblyler/dracula-pro.nvim.git'
}
}) })
vim.api.nvim_create_user_command(
'DraculaDark',
function(opts)
vim.o.background = 'dark'
vim.cmd.colorscheme('dracula_pro_morbius')
end,
{}
)
local dracula = require('dracula') vim.api.nvim_create_user_command(
local draculapro = require('draculapro') 'DraculaLight',
function(opts)
vim.o.background = 'light'
vim.cmd.colorscheme('alucard')
end,
{}
)
-- }}}
draculapro.setup({ vim.o.background = 'dark'
theme = 'morbius' vim.o.termguicolors = true -- enable 24 bit colors
})
dracula.setup({ local color_priorities = {
dracula_pro = draculapro, 'dracula_pro_morbius',
colors = draculapro.colors 'gruvbox',
}) 'default',
}
-- } dracula for _, colorscheme in pairs(color_priorities) do
if colorscheme_exists(colorscheme) then
vim.cmd.colorscheme('gruvbox') vim.cmd.colorscheme(colorscheme)
end) break
end
-- mini.nvim plugins { end
-- safely execute immediately
now(function()
local animate = require('mini.animate')
local timing = animate.gen_timing.linear({ duration = duration, unit = 'total' })
animate.setup({
cursor = {
timing = timing
},
scroll = {
timing = timing
},
resize = {
timing = timing
},
open = {
timing = timing
},
close = {
timing = timing
}
})
end) end)
-- }}}
-- {{{ mini.nvim plugins
-- {{{ mini.nvim notify
now(function() now(function()
require('mini.notify').setup() require('mini.notify').setup()
vim.notify = require('mini.notify').make_notify() vim.notify = require('mini.notify').make_notify()
end) end)
-- }}}
-- {{{ eager
now(function() now(function()
local setups = {
icons = {},
tabline = {},
statusline = {},
}
for plugin, setup in pairs(setups) do
require('mini.' .. plugin).setup(setup)
end
end)
-- }}}
-- {{{ lazy
later(function()
local setups = { local setups = {
bufremove = {}, bufremove = {},
comment = {}, -- maybe later? comment = {},
completion = {}, completion = {},
cursorword = {}, cursorword = {},
icons = {}, -- vet me
jump = {}, jump = {},
jump2d = {}, jump2d = {},
pairs = {}, pairs = {},
pick = {}, -- vet and maybe later? pick = {},
tabline = {}, surround = {},
statusline = {},
surround = {}, -- maybe later?
trailspace = {}, trailspace = {},
} }
@ -135,6 +171,7 @@ now(function()
require('mini.' .. plugin).setup(setup) require('mini.' .. plugin).setup(setup)
end end
-- {{{ jump key mapping
local function jumpbefore() local function jumpbefore()
MiniJump2d.start({ MiniJump2d.start({
allowed_lines = { allowed_lines = {
@ -153,7 +190,9 @@ now(function()
vim.keymap.set('n', '<leader><leader>k', jumpbefore, { noremap = true, silent = true }) vim.keymap.set('n', '<leader><leader>k', jumpbefore, { noremap = true, silent = true })
vim.keymap.set('n', '<leader><leader>j', jumpafter, { noremap = true, silent = true }) vim.keymap.set('n', '<leader><leader>j', jumpafter, { noremap = true, silent = true })
-- }}}
-- {{{ buffer delete command
vim.api.nvim_create_user_command( vim.api.nvim_create_user_command(
'Bd', 'Bd',
function(opts) function(opts)
@ -161,7 +200,9 @@ now(function()
end, end,
{} {}
) )
-- }}}
-- {{{ whitespace fix command
vim.api.nvim_create_user_command( vim.api.nvim_create_user_command(
'FixWhitespace', 'FixWhitespace',
function(opts) function(opts)
@ -169,22 +210,19 @@ now(function()
end, end,
{} {}
) )
end) -- }}}
-- {{{ fzf-like control-P binding
vim.keymap.set('n', '<c-P>', MiniPick.builtin.files, {})
-- }}}
end)
-- }}}
-- }}}
-- {{{ Git
later(function() later(function()
local setups = {
}
for plugin, setup in pairs(setups) do
require('mini.' .. plugin).setup(setup)
end
end)
-- } mini.nvim plugins
-- non mini.nvim plugins {
-- Git {
now(function()
add({ add({
source = 'lewis6991/gitsigns.nvim', source = 'lewis6991/gitsigns.nvim',
}) })
@ -198,69 +236,75 @@ now(function()
}) })
add({ add({
source = "tpope/vim-fugitive", source = 'tpope/vim-fugitive',
}) })
end) end)
-- } Git -- }}}
-- fzf { -- {{{ which key
later(function()
add({
source = 'ibhagwan/fzf-lua'
})
require("fzf-lua").setup({})
vim.keymap.set("n", "<c-P>", require('fzf-lua').files, { desc = "Fzf Files" })
end)
-- }
-- which key {
later(function() later(function()
add({ add({
source = 'folke/which-key.nvim' source = 'folke/which-key.nvim'
}) })
end) end)
-- } -- }}}which key {
-- legacy stuff { -- {{{ surround -- old keybindings diehard, maybe migrate to mini.nvim surround some day
now(function() now(function()
add({ add({
source = 'tpope/vim-surround' source = 'tpope/vim-surround'
}) })
end) end)
-- } surround -- }}}
-- LSP { -- {{{ LSP jazz
later(function() later(function()
add({ add({
-- needed for LSP configuration setup using the builtin LSP implementation
source = 'neovim/nvim-lspconfig', source = 'neovim/nvim-lspconfig',
}) })
add({ add({
-- super convenient tool for installing/updating LSPs, use :Mason* commands
source = 'williamboman/mason.nvim', source = 'williamboman/mason.nvim',
}) })
add({ add({
source = 'williamboman/mason-lspconfig.nvim' -- bridges mason & lspconfig automatically
source = 'williamboman/mason-lspconfig.nvim',
})
add({
-- adds some nice :Lsp* commands
source = 'nanotee/nvim-lsp-basics',
})
add({
-- provides nice "diagnostics" output
source = 'folke/trouble.nvim'
}) })
-- only perform these mappings if an LSP is attached
local on_attach = function(client, buffnr) local on_attach = function(client, buffnr)
local lsp_key = function(lhs, rhs, desc) local lsp_key = function(lhs, rhs, desc)
vim.keymap.set('n', lhs, rhs, { silent = true, buffer = buffnr, desc = desc }) vim.keymap.set('n', lhs, rhs, { silent = true, buffer = buffnr, desc = desc })
end end
lsp_key("<leader>lr", vim.lsp.buf.rename, "Rename symbol") lsp_key('<leader>lr', vim.lsp.buf.rename, 'Rename symbol')
lsp_key("<leader>la", vim.lsp.buf.code_action, "Code action") lsp_key('<leader>la', vim.lsp.buf.code_action, 'Code action')
lsp_key("<leader>ld", vim.lsp.buf.type_definition, "Type definition") lsp_key('<leader>ld', vim.lsp.buf.type_definition, 'Type definition')
lsp_key("gd", vim.lsp.buf.definition, "Goto Definition") lsp_key('gd', vim.lsp.buf.definition, 'Goto Definition')
lsp_key("gr", vim.lsp.buf.references, "Goto References") lsp_key('gr', vim.lsp.buf.references, 'Goto References')
lsp_key("gI", vim.lsp.buf.implementation, "Goto Implementation") lsp_key('gI', vim.lsp.buf.implementation, 'Goto Implementation')
lsp_key("gD", vim.lsp.buf.declaration, "Goto Declaration") lsp_key('gD', vim.lsp.buf.declaration, 'Goto Declaration')
-- setup :Lsp* commands
local basics = require('lsp_basics')
basics.make_lsp_commands(client, buffnr)
basics.make_lsp_mappings(client, buffnr)
end end
require("mason").setup() require('mason').setup()
require("mason-lspconfig").setup({ require('mason-lspconfig').setup({
-- automatically register LSPs as they're installed with their defaults
-- read documentation for one-off configurations if an LSP needs/wants non-default configuration
handlers = { handlers = {
function (server_name) function (server_name)
require('lspconfig')[server_name].setup({ require('lspconfig')[server_name].setup({
@ -277,17 +321,14 @@ later(function()
}) })
end end
add({
source = 'folke/trouble.nvim'
})
require('trouble').setup() require('trouble').setup()
vim.keymap.set('n', '<leader>xx', '<cmd>Trouble diagnostics toggle<cr>', { noremap = true, silent = true }) vim.keymap.set('n', '<leader>xx', '<cmd>Trouble diagnostics toggle<cr>', { noremap = true, silent = true })
vim.keymap.set('n', '<leader>xd', '<cmd>Trouble diagnostics toggle filter.buf=0<cr>', { noremap = true, silent = true }) vim.keymap.set('n', '<leader>xd', '<cmd>Trouble diagnostics toggle filter.buf=0<cr>', { noremap = true, silent = true })
end) end)
-- } LSP -- }}}
-- treesitter { -- {{{ treesitter
later(function() later(function()
add({ add({
source = 'nvim-treesitter/nvim-treesitter', source = 'nvim-treesitter/nvim-treesitter',
@ -362,20 +403,19 @@ later(function()
incremental_selection = { enable = true }, incremental_selection = { enable = true },
}) })
-- show indentations -- show indentations how I like them, each layer of indentation etc
add({ add({
source = 'lukas-reineke/indent-blankline.nvim' source = 'lukas-reineke/indent-blankline.nvim'
}) })
require("ibl").setup({ require('ibl').setup({
indent = { indent = {
char = "", char = '',
highlight = { "Label" }, highlight = { 'Label' },
}, },
scope = { scope = {
highlight = { "Function" }, highlight = { 'Function' },
} }
}) })
end) end)
-- } treesitter -- }}}
-- } non mini.nvim plugins

View file

@ -0,0 +1,16 @@
return {
["dracula-pro.vim.git"] = "f4c019956a9fc9054ffc02553920519e3beadc21",
["gitsigns.nvim"] = "863903631e676b33e8be2acb17512fdc1b80b4fb",
["gruvbox.nvim"] = "7a1b23e4edf73a39642e77508ee6b9cbb8c60f9e",
["indent-blankline.nvim"] = "18603eb949eba08300799f64027af11ef922283f",
["mason-lspconfig.nvim"] = "25c11854aa25558ee6c03432edfa0df0217324be",
["mason.nvim"] = "e2f7f9044ec30067bc11800a9e266664b88cda22",
["mini.nvim"] = "848c5e8f428faf843051768e0d56104cd02aea1f",
["nvim-lsp-basics"] = "632714bd3ab355eb6e725b5a78cd8730f12d14d2",
["nvim-lspconfig"] = "0678aa439b82965daf03679cd146e84f10e299c3",
["nvim-treesitter"] = "d1e1f17cea23f14cbe230635b9bb654a835f02d7",
["trouble.nvim"] = "6efc446226679fda0547c0fd6a7892fd5f5b15d8",
["vim-fugitive"] = "d4877e54cef67f5af4f950935b1ade19ed6b7370",
["vim-surround"] = "3d188ed2113431cf8dac77be61b842acb64433d9",
["which-key.nvim"] = "fb070344402cfc662299d9914f5546d840a22126"
}