From e3f222487a57b2f3f995628630cd9ae65c3a210b Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Fri, 22 May 2026 17:06:16 -0500 Subject: new super fancy loader more akin to lazy.nvim --- lua/tjk/colorscheme.lua | 63 -------------------------------------- lua/tjk/options.lua | 4 +++ lua/tjk/pluginloader.lua | 47 +++++++++++++++++++++++++++++ lua/tjk/plugins.lua | 61 ------------------------------------- lua/tjk/plugins/autoclose.lua | 7 +++++ lua/tjk/plugins/cmp.lua | 13 ++++++++ lua/tjk/plugins/colorizer.lua | 15 +++++++++ lua/tjk/plugins/colorscheme.lua | 67 +++++++++++++++++++++++++++++++++++++++++ lua/tjk/plugins/minitab.lua | 5 +++ lua/tjk/plugins/snacks.lua | 13 ++++++++ lua/tjk/plugins/treesitter.lua | 24 +++++++++++++++ lua/tjk/plugins/ui2.lua | 7 +++++ 12 files changed, 202 insertions(+), 124 deletions(-) delete mode 100644 lua/tjk/colorscheme.lua create mode 100644 lua/tjk/pluginloader.lua delete mode 100644 lua/tjk/plugins.lua create mode 100644 lua/tjk/plugins/autoclose.lua create mode 100644 lua/tjk/plugins/cmp.lua create mode 100644 lua/tjk/plugins/colorizer.lua create mode 100644 lua/tjk/plugins/colorscheme.lua create mode 100644 lua/tjk/plugins/minitab.lua create mode 100644 lua/tjk/plugins/snacks.lua create mode 100644 lua/tjk/plugins/treesitter.lua create mode 100644 lua/tjk/plugins/ui2.lua (limited to 'lua') diff --git a/lua/tjk/colorscheme.lua b/lua/tjk/colorscheme.lua deleted file mode 100644 index e4b9c8e..0000000 --- a/lua/tjk/colorscheme.lua +++ /dev/null @@ -1,63 +0,0 @@ --- use another colorscheme if running as root -if os.getenv "USER" == "root" then - vim.cmd.colorscheme "koehler" - return -end - --- use dark gruvbox variant -vim.o.background = "dark" - --- https://github.com/ellisonleao/gruvbox.nvim -require("gruvbox").setup { - italic = { - strings = false, - emphasis = true, - comments = false, - operators = false, - folds = true, - }, - invert_selection = true, -- swap fg w/ bg on select - contrast = "hard", -- preferred theme variant - palette_overrides = { - light0 = "#ffffff", -- use white instead of the default off-white for text - light1 = "#ffffff", - dark2 = "#363636", -- darker whitespace characters - }, - overrides = { - CursorLine = { bg = "#282828" }, -- dark0 (non hard) - Directory = { link = "GruvboxGreenBold" }, - -- treesitter overrides (more similar to builtin python syntax highlighting) - -- treesitter selectors can be overridden per language using @selector.language - ["@variable"] = { link = "GruvboxFg0" }, - ["@punctuation.bracket"] = { link = "GruvboxFg0" }, - ["@punctuation.delimiter"] = { link = "GruvboxFg0" }, - ["@keyword.import"] = { link = "GruvboxBlue" }, - ["@function"] = { link = "GruvboxAqua" }, - ["@function.method"] = { link = "GruvboxAqua" }, - ["@function.method"] = { link = "GruvboxAqua" }, - ["@attribute.builtin"] = { link = "GruvboxGreenBold" }, - ["@attribute"] = { link = "GruvboxGreenBold" }, - ["@operator"] = { link = "GruvboxRed" }, - ["@variable.member"] = { link = "GruvboxFg0" }, - ["@variable.parameter"] = { link = "GruvboxFg0" }, - ["@function.call"] = { link = "GruvboxPurple" }, - ["@function.method.call"] = { link = "GruvboxPurple" }, - -- rainbow delimiters colors - RainbowDelimiterRed = { fg = "#ff4433" }, - RainbowDelimiterYellow = { fg = "#ffff22" }, - RainbowDelimiterBlue = { fg = "#66f3ff" }, - RainbowDelimiterOrange = { fg = "#ffaa00" }, - RainbowDelimiterGreen = { fg = "#99ff44" }, - RainbowDelimiterViolet = { fg = "#aa00ff" }, - RainbowDelimiterCyan = { fg = "#22ddff" }, - -- TODO italic string start / end - --["@string_start"] = { italic = true }, - --["@string_end"] = { italic = true }, - }, -} - --- set colorscheme -vim.cmd.colorscheme "gruvbox" - --- fix todo comment highlighting (here instead of theme overrides since this replaces the bg w/ default) -vim.api.nvim_set_hl(0, "Todo", { fg = "#ffffff", bold = true }) diff --git a/lua/tjk/options.lua b/lua/tjk/options.lua index 7d6376f..321d85b 100644 --- a/lua/tjk/options.lua +++ b/lua/tjk/options.lua @@ -39,6 +39,10 @@ end}) -- ignore __pycache__ directories in file listings vim.opt.wildignore = { "__pycache__/", "*/__pycache__/" } +-- add builtin plugins +vim.cmd.packadd "nvim.undotree" +vim.cmd.packadd "nvim.difftool" + -- for running in tty if os.getenv "TERM" == "linux" then vim.cmd.colorscheme "vim" diff --git a/lua/tjk/pluginloader.lua b/lua/tjk/pluginloader.lua new file mode 100644 index 0000000..92ed0af --- /dev/null +++ b/lua/tjk/pluginloader.lua @@ -0,0 +1,47 @@ +local pluginsMod = "tjk.plugins" -- module containing plugin modules + +-- fancy plugin loader +function require_plugin(moduleName, source, setup, loadFn) + local ok, mod = pcall(require, moduleName) + if not ok then + if not source then + vim.notify("Failed to load plugin module without source " .. moduleName, vim.log.levels.ERROR) + return + end + vim.pack.add { source } + ok, mod = pcall(require, moduleName) + if not ok then + vim.notify(mod, vim.log.levels.ERROR) + return + end + end + if setup and mod.setup then + mod.setup(setup == true and {} or setup) + end + if loadFn then + loadFn() + end +end + +-- helper for handling dependencies and parsing module +function require_plugin_from_module(mod) + -- mod == true means it returned nothing + if mod == true or mod.enabled == false then + return + end + for _, dMod in ipairs(mod.dependencies or {}) do + require_plugin_from_module(dMod) + end + require_plugin(mod.moduleName or mod[1], mod.source or mod[2], mod.setup, mod.loadFn) + for _, dMod in ipairs(mod.dependents or {}) do + require_plugin_from_module(dMod) + end +end + +-- loop over plugins +local pluginsPath = vim.fn.stdpath("config") .. "/lua/" .. pluginsMod:gsub("%.", "/") +for _, f in ipairs(vim.fn.glob(pluginsPath .. "/*.lua", false, true)) do + local name = vim.fn.fnamemodify(f, ":t:r") + local modName = pluginsMod .. "." .. name + require_plugin_from_module(require(modName)) +end diff --git a/lua/tjk/plugins.lua b/lua/tjk/plugins.lua deleted file mode 100644 index 3feb0bc..0000000 --- a/lua/tjk/plugins.lua +++ /dev/null @@ -1,61 +0,0 @@ -vim.cmd.packadd "nvim.undotree" -vim.cmd.packadd "nvim.difftool" - --- https://github.com/m4xshen/autoclose.nvim -require("autoclose").setup { - options = { pair_spaces = true }, -} - --- TODO native cmp --- https://github.com/Saghen/blink.cmp -require("blink-cmp").setup { - keymap = { - preset = "super-tab", - [""] = { "select_prev", "fallback" }, - [""] = { "select_next", "fallback" }, - }, - cmdline = { enabled = false }, -} - --- https://github.com/catgoose/nvim-colorizer.lua -require("colorizer").setup { - lazy_load = true, - options = { - parsers = { - css = true, -- preset: enables names, hex, rgb, hsl, oklch, css_var - tailwind = { enable = true, update_names = true, lsp = true }, -- tailwind + lsp context - xterm = { enable = true }, -- xterm 256-color codes (#xNN, \e[38;5;NNNm) - xcolor = { enable = true }, -- LaTeX xcolor expressions (e.g. red!30) - }, - }, -} - --- https://git.tjkeller.xyz/minitab.nvim -require("minitab").setup() - --- https://github.com/nvim-treesitter/nvim-treesitter --- TODO "geigerzaehler/tree-sitter-jinja2", -- adds filetype for htmljinja, not recognized by ts by default. Requires gcc in path -require("nvim-treesitter.configs").setup { - highlight = { enable = true, disable = { "yaml", "dockerfile" } }, - --indent = { enable = true }, -- FIXME -} -vim.g._ts_force_sync_parsing = true -- #32660 - --- https://github.com/windwp/nvim-ts-autotag -require("nvim-ts-autotag").setup { - per_filetype = { ["html"] = { enable_close = true } }, -} - --- https://github.com/HiPhish/rainbow-delimiters.nvim ---require("rainbow-delimiters.setup").setup() - --- https://github.com/folke/snacks.nvim -require("snacks").setup { - indent = { - enabled = true, - only_scope = true, - animate = { enabled = false }, - scope = { enabled = false }, - }, - quickfile = { enabled = true }, -} diff --git a/lua/tjk/plugins/autoclose.lua b/lua/tjk/plugins/autoclose.lua new file mode 100644 index 0000000..f356f89 --- /dev/null +++ b/lua/tjk/plugins/autoclose.lua @@ -0,0 +1,7 @@ +return { + "autoclose", + "https://github.com/m4xshen/autoclose.nvim", + setup = { + options = { pair_spaces = true }, + }, +} diff --git a/lua/tjk/plugins/cmp.lua b/lua/tjk/plugins/cmp.lua new file mode 100644 index 0000000..6c87867 --- /dev/null +++ b/lua/tjk/plugins/cmp.lua @@ -0,0 +1,13 @@ +-- TODO replace with native cmp +return { + "blink-cmp", + { src = "https://github.com/Saghen/blink.cmp", version = "v1" }, + setup = { + keymap = { + preset = "super-tab", + [""] = { "select_prev", "fallback" }, + [""] = { "select_next", "fallback" }, + }, + cmdline = { enabled = false }, + }, +} diff --git a/lua/tjk/plugins/colorizer.lua b/lua/tjk/plugins/colorizer.lua new file mode 100644 index 0000000..120fbb8 --- /dev/null +++ b/lua/tjk/plugins/colorizer.lua @@ -0,0 +1,15 @@ +return { + "colorizer", + "https://github.com/catgoose/nvim-colorizer.lua", + setup = { + lazy_load = true, + options = { + parsers = { + css = true, -- preset: enables names, hex, rgb, hsl, oklch, css_var + tailwind = { enable = true, update_names = true, lsp = true }, -- tailwind + lsp context + xterm = { enable = true }, -- xterm 256-color codes (#xNN, \e[38;5;NNNm) + xcolor = { enable = true }, -- LaTeX xcolor expressions (e.g. red!30) + }, + }, + }, +} diff --git a/lua/tjk/plugins/colorscheme.lua b/lua/tjk/plugins/colorscheme.lua new file mode 100644 index 0000000..4a3756d --- /dev/null +++ b/lua/tjk/plugins/colorscheme.lua @@ -0,0 +1,67 @@ +-- use another colorscheme if running as root +if os.getenv "USER" == "root" then + vim.cmd.colorscheme "koehler" + return +end + +return { + "gruvbox", + "https://github.com/ellisonleao/gruvbox.nvim", + setup = { + italic = { + strings = false, + emphasis = true, + comments = false, + operators = false, + folds = true, + }, + invert_selection = true, -- swap fg w/ bg on select + contrast = "hard", -- preferred theme variant + palette_overrides = { + light0 = "#ffffff", -- use white instead of the default off-white for text + light1 = "#ffffff", + dark2 = "#363636", -- darker whitespace characters + }, + overrides = { + CursorLine = { bg = "#282828" }, -- dark0 (non hard) + Directory = { link = "GruvboxGreenBold" }, + -- treesitter overrides (more similar to builtin python syntax highlighting) + -- treesitter selectors can be overridden per language using @selector.language + ["@variable"] = { link = "GruvboxFg0" }, + ["@punctuation.bracket"] = { link = "GruvboxFg0" }, + ["@punctuation.delimiter"] = { link = "GruvboxFg0" }, + ["@keyword.import"] = { link = "GruvboxBlue" }, + ["@function"] = { link = "GruvboxAqua" }, + ["@function.method"] = { link = "GruvboxAqua" }, + ["@function.method"] = { link = "GruvboxAqua" }, + ["@attribute.builtin"] = { link = "GruvboxGreenBold" }, + ["@attribute"] = { link = "GruvboxGreenBold" }, + ["@operator"] = { link = "GruvboxRed" }, + ["@variable.member"] = { link = "GruvboxFg0" }, + ["@variable.parameter"] = { link = "GruvboxFg0" }, + ["@function.call"] = { link = "GruvboxPurple" }, + ["@function.method.call"] = { link = "GruvboxPurple" }, + -- rainbow delimiters colors + RainbowDelimiterRed = { fg = "#ff4433" }, + RainbowDelimiterYellow = { fg = "#ffff22" }, + RainbowDelimiterBlue = { fg = "#66f3ff" }, + RainbowDelimiterOrange = { fg = "#ffaa00" }, + RainbowDelimiterGreen = { fg = "#99ff44" }, + RainbowDelimiterViolet = { fg = "#aa00ff" }, + RainbowDelimiterCyan = { fg = "#22ddff" }, + -- TODO italic string start / end + --["@string_start"] = { italic = true }, + --["@string_end"] = { italic = true }, + }, + }, + loadFn = function() + -- use dark gruvbox variant + vim.o.background = "dark" + + -- set colorscheme + vim.cmd.colorscheme "gruvbox" + + -- fix todo comment highlighting (here instead of theme overrides since this replaces the bg w/ default) + vim.api.nvim_set_hl(0, "Todo", { fg = "#ffffff", bold = true }) + end, +} diff --git a/lua/tjk/plugins/minitab.lua b/lua/tjk/plugins/minitab.lua new file mode 100644 index 0000000..cdc6052 --- /dev/null +++ b/lua/tjk/plugins/minitab.lua @@ -0,0 +1,5 @@ +return { + "minitab", + "https://git.tjkeller.xyz/minitab.nvim", + setup = true, +} diff --git a/lua/tjk/plugins/snacks.lua b/lua/tjk/plugins/snacks.lua new file mode 100644 index 0000000..8444595 --- /dev/null +++ b/lua/tjk/plugins/snacks.lua @@ -0,0 +1,13 @@ +return { + "snacks", + "https://github.com/folke/snacks.nvim", + setup = { + indent = { + enabled = true, + only_scope = true, + animate = { enabled = false }, + scope = { enabled = false }, + }, + quickfile = { enabled = true }, + }, +} diff --git a/lua/tjk/plugins/treesitter.lua b/lua/tjk/plugins/treesitter.lua new file mode 100644 index 0000000..d35107b --- /dev/null +++ b/lua/tjk/plugins/treesitter.lua @@ -0,0 +1,24 @@ +return { + "nvim-treesitter.configs", + "https://github.com/nvim-treesitter/nvim-treesitter", + setup = { + highlight = { enable = true, disable = { "yaml", "dockerfile" } }, + --indent = { enable = true }, -- FIXME + }, + dependents = { + { + "nvim-ts-autotag", + "https://github.com/windwp/nvim-ts-autotag", + setup = { + per_filetype = { ["html"] = { enable_close = true } }, + }, + }, + { + "rainbow-delimiters.setup", + "https://github.com/HiPhish/rainbow-delimiters.nvim" + }, + }, + loadFn = function() + vim.g._ts_force_sync_parsing = true -- #32660 + end, +} diff --git a/lua/tjk/plugins/ui2.lua b/lua/tjk/plugins/ui2.lua new file mode 100644 index 0000000..5d1dc9e --- /dev/null +++ b/lua/tjk/plugins/ui2.lua @@ -0,0 +1,7 @@ +return { + "vim._core.ui2", + source = nil, + setup = { + enable = true, + }, +} -- cgit v1.2.3