Skip to content

Comments

prise plugin system: initial plugin support for prise #85

Open
jossephus wants to merge 8 commits intorockorager:mainfrom
jossephus:feat/add-plugin-system
Open

prise plugin system: initial plugin support for prise #85
jossephus wants to merge 8 commits intorockorager:mainfrom
jossephus:feat/add-plugin-system

Conversation

@jossephus
Copy link
Contributor

@jossephus jossephus commented Jan 11, 2026

This is my attempt to add plugin support to prise. Its heavily inspired by how lazy.nvim configures plugins and how plugins work in Neovim.

a sample theme switcher plugin is available at https://github.com/jossephus/prise-theme-switcher and you can see the video below to see it in action.

Plugin System for Prise

Adds plugin support inspired by lazy.nvim's configuration style.

Features

  • Remote plugins from GitHub (username/repo format)
  • Local plugins (./path, ~/path, /absolute/path)
  • Lazy loading via event or keys triggers

Plugin Directory

Plugins are cloned to ~/.local/share/prise/plugins/

Configuration Example

plugins = {
  -- Remote plugin (cloned from GitHub)
  { "username/prise-catppuccin" },

  -- Local plugin
  { "./local-plugin" },

  -- Full spec
  {
    "username/prise-git-status",
    branch = "main",
    lazy = true,
    event = { "UI_READY" },
    keys = { "<leader>g" },
    opts = { show_branch = true },
    config = function(plugin, opts, user_config)
      plugin.setup(opts, user_config)
    end,
  },
}

Writing Plugins

Plugins follow a simple Lua module pattern. Place your plugin code in lua//init.lua or lua/.lua.

Minimal plugin:

local M = {}

function M.setup(opts, user_config)
    -- opts: table passed via plugin spec's `opts` field
    -- user_config: reference to the full prise config
end

return M

Directory structure:

my-prise-plugin/
└── lua/
└── my-prise-plugin/
└── init.lua -- or just lua/my-prise-plugin.lua

Future Work

  • Documentation
  • Maybe add lock-file for reproducibility
  • Add hooks in many prise features so it can be used by third party plugins.

Here is a video, using a sample simple https://github.com/jossephus/prise-theme-switcher in prise.

output.mp4

and the code needed to include this plugin in my init.lua is the following

local config = {
  plugins = {
    {
      "./examples/prise-mood-ring",
      lazy = false,
      opts = {
        show_git_status = true,
        show_panes = true,
      },
    },
    {
      "jossephus/prise-theme-switcher",
      lazy = false,
      opts = {
        show_theme_name = true,
      },
      config = function(plugin, opts, user_config)
        plugin.setup(opts, user_config)
        user_config.keybinds["<leader>x"] = plugin.cycle_next
        user_config.keybinds["<leader>X"] = plugin.cycle_prev
      end,
    },
  },
}

and the following part in tab_bar.render so we can show the current theme in tab bar as shown in the video

    local theme_switcher = require("prise-theme-switcher")
      if theme_switcher then
        local formatted, color = theme_switcher.format()
        if formatted and formatted ~= "" then
          table.insert(right_parts, {
            text = formatted,
            style = { fg = color, bold = true },
          })
        end
      end

initial working amp thread: https://ampcode.com/threads/T-019ba5f4-93c1-7378-887a-d8c3dd1305f9

@jossephus jossephus force-pushed the feat/add-plugin-system branch from 6811334 to d7bfbb2 Compare January 11, 2026 15:03
@jossephus
Copy link
Contributor Author

This PR is only POC, feel free to close it since I may have too many unhandled things.

@rockorager
Copy link
Owner

This. Is. Amazing. I am all for this, and I'm fine putting it out in pieces if you prefer that - prise is alpha, after all!

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR adds a solid plugin system foundation with good Lua/Zig integration. The test coverage for the Lua side is thorough.

Key issues to address:

  1. TigerStyle violation: ensurePlugin is 136 lines (limit: 70). Split into smaller helper functions.

  2. Blocking git operations: std.process.Child.run will freeze the UI during clone/fetch. Consider async execution or user feedback.

  3. Redundant code: load_for_event() iterates all specs unnecessarily since events are already indexed during setup.

Minor:

  • Comment in matcherKeyToString says 11 chars overhead but it's actually 10
  • Magic number 512 for URL buffer should be a named constant

The Lua plugin manager is well-structured with proper error handling and EmmyLua annotations. The hook system and lazy loading implementation look correct.


Review thread: https://ampcode.com/threads/T-019bafe2-c320-76dc-b898-2a5baaaab386

@jossephus
Copy link
Contributor Author

jossephus commented Jan 12, 2026

with the addition of async cloning i couldnt resist but work on a status modal for cloning plugins. plugin system is looking better now.

image image

- fix dangling memory leak risk
- fix a timer leak
- fix callback queue issues in plugins.lua
- properly update git clone status for 'clone' and 'update'
@jossephus jossephus force-pushed the feat/add-plugin-system branch from 3890977 to 912329d Compare January 13, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants