diff --git a/README.md b/README.md
index 80a7a66..7a153d3 100755
--- a/README.md
+++ b/README.md
@@ -1,144 +1,101 @@
-
-
-
+# rocks-tui.nvim
-
+**A Terminal User Interface (TUI) for `rocks.nvim` to enhance Neovim plugin management.**
-[](https://github.com/Pakrohk-DotFiles/NvPak/blob/main/LICENSE)
-[](https://github.com/Pakrohk-DotFiles/NvPak/graphs/commit-activity)
-[](https://github.com/neovim/neovim)
-[](https://github.com/Pakrohk)
-[](https://github.com/Pakrohk-DotFiles/NvPak/issues)
+`rocks-tui.nvim` (or simply `rocks-tui`) provides an interactive and visual way to manage your Neovim plugins when using the [`rocks.nvim`](https://github.com/nvim-neorocks/rocks.nvim) package manager. It aims to simplify common plugin management tasks like discovery, installation, updates, and removal, drawing inspiration from user-friendly package manager interfaces.
-# What is the purpose of the NvPak project? â¨
+## Features
-Maybe you have tried to configure Neovim multiple times over the past few years. Neovim has undergone many changes, and every time, you had to follow new defaults to reach the minimum configuration and start writing your configuration for Neovim. The goal of the nvpak project is to provide these defaults.
+- **Plugin Manager View:**
+ - List installed plugins with their versions and status.
+ - Update individual plugins or all plugins.
+ - Remove plugins.
+ - Trigger `:Rocks sync` to synchronize with your `rocks.toml`.
+ - Quickly view `rocks.nvim` logs.
+- **Plugin Search View:**
+ - Search for new plugins (interactively prompts for query).
+ - Display search results with plugin names and descriptions.
+ - Install plugins directly from the search results (with optional version specification).
+- **Installation Progress View:**
+ - Visualize the progress of plugin installations and updates.
+ - Shows current operation, overall progress bar, and detailed status (conceptual, relies on `rocks.nvim` providing data).
+- **Configurable:**
+ - Customize key mappings for all TUI windows.
+ - Adjust basic UI elements like window borders, sizes (as ratios), and titles.
+- **Built with Lua and Neovim API:** Leverages floating windows and other Neovim UI primitives.
-Now you can configure only what you need by forking nvpak without any add-ons. Please note that nvpak is not a Neovim configuration and not in competition with other configurations such as NvChad or LazyVim. If you need a complete Neovim setup without any configuration, then this GitHub repository is not for you.
+## Prerequisites
-# Why is the name of the project NvPak? đ
+- [Neovim](https://neovim.io/) (Version 0.8+ recommended, 0.10+ for best compatibility with underlying APIs)
+- [`rocks.nvim`](https://github.com/nvim-neorocks/rocks.nvim) installed and configured in your Neovim setup.
-"nv" stands for Neovim and "Pak" is derived from the Persian word "ٞاڊ" meaning "clean," which represents brightness and simplicity, contrary to complexity and disorder.
+## Installation
-
+Once this plugin is published to a repository accessible by `rocks.nvim` (e.g., LuaRocks or a community repository):
-## Requirements đ
-
-In order to make the best use of this config, you must meet the following prerequisites.
-
-- `neovim v0.8.0` and later versions or `neovide v0.10.3` and later Version
-- `unzip`
-- `curl`
-- `ripgrep` or `fd` for [Fuzzy Finder Telescope](https://github.com/BurntSushi/ripgrep)
-- For clipboard support:
- - `xclip` or `xsel` for Xorg
- - `wl-clipboard` for Wayland
-- `git`
-- If you are a Python developer, `pynvim`
-- `bash` or `dash` for Unix-based systems
-- `PowerShell v5.1` or later for Windows
-- Only for Windows: `Scoop.sh`
-- Install [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts) for better icon support.
-
-### Screenshots đˇ
-
-
-
-Show
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Installation đť
-## Unix đ§
-bash
-```bash
-git clone --depth 1 https://github.com/Pakrohk-DotFiles/NvPak.git ~/.config/nvim && nvim
+```vim
+:Rocks install your-repo-user/rocks-tui.nvim
```
-## Windows đŞ
-powershell
-```powershell
-bucket add extras
-scoop install lazygit
-(git clone --depth 1 https://github.com/Pakrohk-DotFiles/NvPak.git ~\AppData\Local\nvim\) -and (nvim)
+(Replace `your-repo-user/rocks-tui.nvim` with the actual rock name.)
+
+For local development or testing:
+1. Clone this repository:
+ ```sh
+ git clone https://github.com/your-username/rocks-tui.nvim.git somewhere/rocks-tui.nvim
+ ```
+2. Add it to your Neovim runtime path. For example, if using a packer-like structure or manually managing paths:
+ Ensure `somewhere/rocks-tui.nvim` is in your `&runtimepath`.
+
+## Basic Usage
+
+The plugin provides several commands to access its features:
+
+- **`:RocksTUI`**: Opens the main plugin manager window. Here you can see your installed plugins and manage them.
+- **`:RocksTUISearch`**: Opens the plugin search interface. Enter a query to find new plugins.
+- **`:RocksTUIProgress`**: Manually opens the installation progress window. This window also attempts to open automatically during installations initiated by `rocks-tui`.
+- **`:RocksTUISetup`**: Allows you to re-apply your configuration (useful for testing changes without restarting Neovim).
+
+Refer to the help file (`:help rocks-tui`) for detailed information on key mappings within each window.
+
+## Configuration
+
+You can customize `rocks-tui` by calling the `setup` function in your Neovim configuration (e.g., `init.lua` or a dedicated plugin configuration file).
+
+```lua
+require('rocks-tui').setup({
+ -- ui = {
+ -- manager_window = {
+ -- border = "single", -- "none", "single", "double", "rounded", "solid", "shadow"
+ -- width_ratio = 0.75,
+ -- title = "My Plugin Manager"
+ -- },
+ -- search_window = {
+ -- border = "solid",
+ -- }
+ -- },
+ -- keymaps = {
+ -- manager_close = "",
+ -- manager_refresh = "R",
+ -- search_install_selected = "",
+ -- progress_close = "",
+ -- }
+})
```
-### Notes:
-
-You need to have git installed first.
-On Unix,nvim command-line executable should be installed. \
-If it is not installed, you can install it using your system's **package manager**.\
-On Windows, you need to have scoop installed first. \
-Then, install lazygit by running scoop install lazygit.\
-Afterwards, run the remaining commands sequentially.
-
-The --depth 1 option of the git clone command fetches only the latest changes from the repository and does not retrieve the entire history.\
-This reduces the download time.\
-The \ character in Windows is used to continue a command on a new line.
-
-
-# Usage: đ
-
-If the software plugins are not installed automatically after the first run, follow these steps:
-
-Run the following command inside nvim:
-
-```
-:Lazy sync
-```
-
-Restart nvim.
-
-Enjoy!
-
-
-
-
-
-# Contributing đ¤
-
-
-If you're interested in contributing to the project, we welcome your help in fixing bugs and adding new features.\
- Here's how you can get started:
-
-Check the [Projects](https://github.com/EvolveBeyond/NvPak/projects) section to see if there are any open issues or features that you'd like to work on. \
-If you have an idea for a new feature or improvement, feel free to suggest it and discuss it with the [NvPak](https://github.com/EvolveBeyond/NvPak) team.
-
-Fork the NvPak repository to your own GitHub account.\
-Make your changes and commit them to your forked repository. Please make sure to follow the project's coding standards and best practices, and write clear and concise commit messages.
-
-Submit a pull request from your forked repository to the main NvPak repository.\
- Your changes will be reviewed by the NvPak team, who may provide feedback and request changes if necessary.\
-Once your changes are approved, they will be merged into the main NvPak repository and will be available to all users.
-
-By contributing to NvPak, you'll be helping to improve the project for all users, and you'll have the opportunity to learn and collaborate with other developers.
-
- Thank you for considering contributing to NvPak!
-
-
-you can find the list of contributors on the [contributors page](https://github.com/nooob-developer/NvPak/graphs/contributors).
+If `setup()` is not called, the plugin will use its default configuration.
+See `:help rocks-tui-default-configuration` for the full list of default options.
-## Team
-
-
-
+## Current Status & Limitations
+- **Search Functionality:** The current search results are based on placeholder data within `core.lua`. Full integration with `rocks.nvim`'s search capabilities (e.g., parsing `:Rocks search ` output or using a Lua API if available) is needed for actual plugin discovery.
+- **Progress Visualization:** The progress UI is functional, but the data feeding into it from `core.lua` is conceptual (simulated). Real-time progress updates depend on `rocks.nvim` providing events or a detailed API for progress, or on more complex wrapping of `rocks.nvim` commands.
+- **Error Handling:** Basic error handling is in place, but can be made more robust.
+- **Modularity:** The plugin is designed with modularity in mind, but further refinements can always be made.
+## Contributing
+Contributions are welcome! If you have ideas for improvements, new features, or bug fixes, please feel free to open an issue or submit a pull request.
+## License
+This plugin is licensed under [LICENSE_TYPE_HERE - e.g., MIT, GPLv3]. (Developer: Please choose and add a license file).
diff --git a/doc/rocks-tui.txt b/doc/rocks-tui.txt
new file mode 100644
index 0000000..81448a6
--- /dev/null
+++ b/doc/rocks-tui.txt
@@ -0,0 +1,191 @@
+*rocks-tui.txt* Plugin for managing Neovim plugins with rocks.nvim
+
+CONTENTS *rocks-tui-contents*
+
+1. Introduction |rocks-tui-introduction|
+2. Installation |rocks-tui-installation|
+3. Usage |rocks-tui-usage|
+ 3.1 Plugin Manager |rocks-tui-usage-manager|
+ 3.2 Plugin Search |rocks-tui-usage-search|
+ 3.3 Progress View |rocks-tui-usage-progress|
+4. Configuration |rocks-tui-configuration|
+ 4.1 Default Config |rocks-tui-default-configuration|
+5. Commands |rocks-tui-commands|
+6. Mappings |rocks-tui-mappings|
+
+==============================================================================
+1. Introduction *rocks-tui-introduction*
+
+rocks-tui is a Lua-based TUI (Terminal User Interface) / Wrapper for
+|rocks.nvim| that aims to enhance the user experience of managing Neovim
+plugins. It provides a more interactive, visual, and intuitive way to
+discover, install, update, and remove plugins.
+
+==============================================================================
+2. Installation *rocks-tui-installation*
+
+Prerequisites:
+- Neovim >= 0.8 (or higher, depending on API usage, 0.10+ recommended)
+- |rocks.nvim| installed and configured.
+
+Using |rocks.nvim| (once this plugin is published, name might vary e.g., rocks-tui.nvim):
+>
+ :Rocks install owner/rocks-tui
+<
+Alternatively, clone this repository and add it to your runtime path using your
+preferred method if developing or testing locally.
+
+==============================================================================
+3. Usage *rocks-tui-usage*
+
+This plugin provides commands to open different TUI views. See
+|rocks-tui-commands| for a list of commands.
+
+------------------------------------------------------------------------------
+3.1 Plugin Manager *rocks-tui-usage-manager*
+
+Command: |:RocksTUI|
+
+This view lists all plugins currently managed by |rocks.nvim| (as understood
+by this TUI, typically from `rocks.toml` via `core.get_installed_plugins`).
+You can perform actions like:
+- Refreshing the list.
+- Updating a selected plugin.
+- Removing a selected plugin.
+- Updating all plugins.
+- Triggering a `:Rocks sync`.
+- Viewing `rocks.nvim` logs.
+
+Default key mappings are listed under |rocks-tui-mappings|.
+
+------------------------------------------------------------------------------
+3.2 Plugin Search *rocks-tui-usage-search*
+
+Command: |:RocksTUISearch|
+
+This interface allows you to search for plugins.
+1. You will be prompted to enter a search query (e.g., plugin name).
+2. Results (currently illustrative, pending full `rocks.nvim` search API
+ integration) are displayed in a new window.
+3. You can select a plugin from the results to install it. You'll be prompted
+ to confirm and can optionally specify a version (e.g., `dev`, `1.2.3`).
+
+Default key mappings are listed under |rocks-tui-mappings|.
+
+------------------------------------------------------------------------------
+3.3 Progress View *rocks-tui-usage-progress*
+
+Command: |:RocksTUIProgress|
+
+This window displays the progress of ongoing `rocks.nvim` operations, such as
+installing or updating plugins. It shows:
+- The current operation.
+- Overall progress (if available).
+- Number of plugins processed out of the total.
+- A text-based progress bar.
+- Detailed status per plugin (conceptual, depends on `core.lua` feeding data).
+- Log messages related to the operation.
+
+This window is intended to be opened automatically by operations like
+installing from the search view, but can also be opened manually.
+
+Default key mappings are listed under |rocks-tui-mappings|.
+
+==============================================================================
+4. Configuration *rocks-tui-configuration*
+
+The plugin can be configured by calling the `setup` function in your Neovim
+configuration (e.g., `init.lua`):
+>
+ require('rocks-tui').setup({
+ -- Example: Change the border of the manager window
+ -- ui = {
+ -- manager_window = {
+ -- border = "single",
+ -- }
+ -- },
+ -- Example: Change some keymaps
+ -- keymaps = {
+ -- manager_close = "",
+ -- search_install_selected = "",
+ -- }
+ })
+<
+If `setup` is not called, default configurations will be used.
+
+------------------------------------------------------------------------------
+4.1 Default Configuration *rocks-tui-default-configuration*
+
+The default configuration structure is as follows:
+(Note: This is a representation. Refer to `lua/rocks-tui/config.lua` for the
+exact defaults at the time of use.)
+>
+ {
+ keymaps = {
+ manager_close = "q",
+ manager_refresh = "r",
+ manager_update_selected = "u",
+ manager_remove_selected = "R",
+ manager_update_all = "U",
+ manager_sync = "s",
+ manager_view_log = "l",
+ search_close = "q",
+ search_install_selected = "i",
+ progress_close = "q",
+ },
+ ui = {
+ manager_window = { border = "rounded", width_ratio = 0.8, height_ratio = 0.7, title = "rocks.nvim TUI - Manager" },
+ search_window = { border = "rounded", width_ratio = 0.8, height_ratio = 0.7, title = "Plugin Search Results" },
+ progress_window = { border = "double", width_ratio = 0.7, height_ratio = 0.5, title = "Installation Progress", zindex = 100 },
+ }
+ }
+<
+
+==============================================================================
+5. Commands *rocks-tui-commands*
+
+All commands are exposed via `vim.api.nvim_create_user_command`.
+
+*:RocksTUI*
+ Opens the main TUI window for managing installed plugins.
+ See |rocks-tui-usage-manager|.
+
+*:RocksTUISearch*
+ Opens the plugin search interface.
+ See |rocks-tui-usage-search|.
+
+*:RocksTUIProgress*
+ Shows the progress of the current `rocks.nvim` installation or sync process.
+ Can be opened manually if needed. See |rocks-tui-usage-progress|.
+
+*:RocksTUISetup [{args}]*
+ A command to call the setup function, primarily for testing or re-applying
+ configuration. Arguments are not currently parsed but are passed to the
+ setup function if provided. Example: `:RocksTUISetup { ui = { manager_window = { border = 'solid' } } }` (The argument needs to be valid Lua).
+
+==============================================================================
+6. Mappings *rocks-tui-mappings*
+
+Default key mappings are defined in `lua/rocks-tui/config.lua` and can be
+overridden via the `setup` function. These mappings are local to the
+respective TUI windows.
+
+*Plugin Manager Window Mappings (|:RocksTUI|):*
+ `q` : Close window (default: `keymaps.manager_close`)
+ `r` : Refresh plugin list (default: `keymaps.manager_refresh`)
+ `u` : Update selected plugin (default: `keymaps.manager_update_selected`)
+ `R` : Remove selected plugin (default: `keymaps.manager_remove_selected`)
+ `U` : Update all plugins (default: `keymaps.manager_update_all`)
+ `s` : Sync with `rocks.toml` (runs `:Rocks sync`) (default: `keymaps.manager_sync`)
+ `l` : View `rocks.nvim` logs (runs `:Rocks log`) (default: `keymaps.manager_view_log`)
+
+*Search Results Window Mappings (|:RocksTUISearch|):*
+ `q` : Close window (default: `keymaps.search_close`)
+ `i` : Install selected plugin (default: `keymaps.search_install_selected`)
+
+*Progress Window Mappings (|:RocksTUIProgress|):*
+ `q` : Close window (default: `keymaps.progress_close`)
+
+Refer to |rocks-tui-default-configuration| for the default key values.
+
+vim:tw=78:ts=8:ft=help:norl:
diff --git a/lua/rocks-tui/config.lua b/lua/rocks-tui/config.lua
new file mode 100644
index 0000000..8eeb91a
--- /dev/null
+++ b/lua/rocks-tui/config.lua
@@ -0,0 +1,65 @@
+-- Configuration module for rocks-tui
+local M = {}
+
+local default_config = {
+ keymaps = {
+ -- Plugin Manager Window
+ manager_close = "q",
+ manager_refresh = "r",
+ manager_update_selected = "u",
+ manager_remove_selected = "R",
+ manager_update_all = "U",
+ manager_sync = "s",
+ manager_view_log = "l",
+ -- Search Results Window
+ search_close = "q",
+ search_install_selected = "i",
+ -- Progress Window
+ progress_close = "q",
+ },
+ ui = {
+ manager_window = {
+ border = "rounded", -- "none", "single", "double", "rounded", "solid", "shadow"
+ width_ratio = 0.8, -- Ratio of editor width
+ height_ratio = 0.7, -- Ratio of editor height
+ title = "rocks.nvim TUI - Manager",
+ },
+ search_window = {
+ border = "rounded",
+ width_ratio = 0.8,
+ height_ratio = 0.7,
+ title = "Plugin Search Results",
+ },
+ progress_window = {
+ border = "double",
+ width_ratio = 0.7,
+ height_ratio = 0.5,
+ title = "Installation Progress",
+ zindex = 100,
+ },
+ -- Common highlight groups (can be overridden by user's theme if not set)
+ -- Normal = "NormalFloat",
+ -- FloatBorder = "FloatBorder",
+ }
+}
+
+local current_config = vim.deepcopy(default_config)
+
+--- Merges user configuration with defaults.
+--- @param user_config table User-provided configuration table.
+function M.setup(user_config)
+ if user_config and type(user_config) == "table" then
+ current_config = vim.tbl_deep_extend("force", vim.deepcopy(default_config), user_config)
+ else
+ current_config = vim.deepcopy(default_config) -- Reset if invalid config
+ end
+ -- Basic validation could be added here if needed
+end
+
+--- Returns the current configuration table.
+--- @return table
+function M.get_config()
+ return current_config
+end
+
+return M
diff --git a/lua/rocks-tui/core.lua b/lua/rocks-tui/core.lua
new file mode 100644
index 0000000..08fec6f
--- /dev/null
+++ b/lua/rocks-tui/core.lua
@@ -0,0 +1,301 @@
+-- Core module for interacting with rocks.nvim
+local M = {}
+
+local rocks_api = nil
+local rocks_available = false
+
+-- Attempt to load rocks.nvim API
+local status_ok, rocks = pcall(require, "rocks")
+if status_ok then
+ rocks_api = rocks
+ rocks_available = true
+ vim.notify("Successfully loaded rocks.nvim API", vim.log.levels.INFO)
+else
+ vim.notify("Failed to load rocks.nvim API. rocks-tui may not function correctly.", vim.log.levels.ERROR)
+end
+
+--- Checks if rocks.nvim is available
+--- @return boolean
+function M.is_rocks_available()
+ return rocks_available
+end
+
+--- Gets the loaded rocks.nvim API
+--- @return table|nil
+function M.get_rocks_api()
+ return rocks_api
+end
+
+--- Get installed plugins
+-- This is a placeholder. We need to figure out how rocks.nvim stores this.
+-- It might be by reading rocks.toml or using an API function.
+--- @return table List of installed plugins (e.g., { {name="plugin1", version="1.0.0"}, ...})
+function M.get_installed_plugins()
+ if not rocks_available then
+ vim.notify("rocks.nvim not available", vim.log.levels.ERROR)
+ return {}
+ end
+
+ -- Placeholder implementation
+ -- Try to find a function in rocks_api or parse rocks.toml
+ -- For now, return dummy data
+ vim.notify("M.get_installed_plugins() called - Placeholder implementation", vim.log.levels.WARN)
+
+ -- Example of how one might try to use the API if it exists
+ -- if rocks_api and rocks_api.list_installed then
+ -- return rocks_api.list_installed()
+ -- end
+
+ -- Fallback: try to read rocks.toml
+ -- local toml_path = vim.fn.stdpath("config") .. "/rocks.toml" -- This path might be wrong
+ -- local toml_content = read_file(toml_path) -- This would need a helper
+ -- if toml_content then
+ -- -- parse toml_content
+ -- end
+
+ return {
+ { name = "plenary.nvim", version = "scm", status = "pinned" },
+ { name = "telescope.nvim", version = "0.1.5", status = "ok" },
+ }
+end
+
+--- Search for plugins
+-- Placeholder: rocks.nvim might have a search API, or we might need to parse command output
+--- @param query string Search query
+--- @return table List of search results
+function M.search_plugins(query)
+ if not rocks_available then
+ vim.notify("rocks.nvim not available", vim.log.levels.ERROR)
+ return {}
+ end
+ vim.notify("M.search_plugins() called with query: " .. query .. " - Placeholder implementation", vim.log.levels.WARN)
+
+ -- Example: if rocks_api and rocks_api.search then
+ -- return rocks_api.search(query)
+ -- end
+
+ -- Fallback: use :Rocks search and parse output (complex)
+ -- vim.cmd("Rocks search " .. query)
+ -- Need a way to capture and parse this output.
+
+ return {
+ { name = "nvim-cmp", description = "A completion plugin for neovim" },
+ { name = "lualine.nvim", description = "A blazing fast and easy to configure neovim statusline" },
+ }
+end
+
+--- Install a plugin
+--- @param plugin_name_or_url string Name or URL of the plugin
+--- @param version string|nil Optional version
+--- @return boolean Success status
+function M.install_plugin(plugin_name_or_url, version)
+ if not rocks_available then
+ vim.notify("rocks.nvim not available", vim.log.levels.ERROR)
+ return false
+ end
+ vim.notify("M.install_plugin() called for: " .. plugin_name_or_url .. (version and ("@"..version) or ""), vim.log.levels.INFO)
+
+ local cmd = "Rocks install " .. plugin_name_or_url
+ if version then
+ cmd = cmd .. " " .. version
+ end
+
+ -- This is a simplified call. Real implementation needs to handle async nature,
+ -- progress, and errors from rocks.nvim.
+ local status, err = pcall(vim.cmd, cmd)
+ if not status then
+ vim.notify("Error installing plugin: " .. err, vim.log.levels.ERROR)
+ return false
+ else
+ vim.notify("Plugin installation initiated for: " .. plugin_name_or_url, vim.log.levels.INFO)
+ -- Ideally, we'd get more detailed feedback from rocks.nvim
+ return true
+ end
+end
+
+--- Update a specific plugin
+--- @param plugin_name string Name of the plugin to update
+--- @return boolean Success status
+function M.update_plugin(plugin_name)
+ if not rocks_available then
+ vim.notify("rocks.nvim not available", vim.log.levels.ERROR)
+ return false
+ end
+ vim.notify("M.update_plugin() called for: " .. plugin_name, vim.log.levels.INFO)
+
+ local cmd = "Rocks update " .. plugin_name
+ local status, err = pcall(vim.cmd, cmd)
+ if not status then
+ vim.notify("Error updating plugin: " .. err, vim.log.levels.ERROR)
+ return false
+ else
+ vim.notify("Plugin update initiated for: " .. plugin_name, vim.log.levels.INFO)
+ return true
+ end
+end
+
+--- Update all plugins
+--- @return boolean Success status
+function M.update_all_plugins()
+ if not rocks_available then
+ vim.notify("rocks.nvim not available", vim.log.levels.ERROR)
+ return false
+ end
+ vim.notify("M.update_all_plugins() called", vim.log.levels.INFO)
+
+ local cmd = "Rocks update"
+ local status, err = pcall(vim.cmd, cmd)
+ if not status then
+ vim.notify("Error updating all plugins: " .. err, vim.log.levels.ERROR)
+ return false
+ else
+ vim.notify("Updating all plugins initiated.", vim.log.levels.INFO)
+ return true
+ end
+end
+
+--- Remove (prune) a plugin
+--- @param plugin_name string Name of the plugin to remove
+--- @return boolean Success status
+function M.remove_plugin(plugin_name)
+ if not rocks_available then
+ vim.notify("rocks.nvim not available", vim.log.levels.ERROR)
+ return false
+ end
+ vim.notify("M.remove_plugin() called for: " .. plugin_name, vim.log.levels.INFO)
+
+ local cmd = "Rocks prune " .. plugin_name
+ local status, err = pcall(vim.cmd, cmd)
+ if not status then
+ vim.notify("Error removing plugin: " .. err, vim.log.levels.ERROR)
+ return false
+ else
+ vim.notify("Plugin removal initiated for: " .. plugin_name, vim.log.levels.INFO)
+ return true
+ end
+end
+
+--- Get logs from rocks.nvim
+-- This function will attempt to open the logs using the :Rocks log command.
+function M.view_log()
+ if not rocks_available then
+ vim.notify("rocks.nvim not available. Cannot show logs.", vim.log.levels.ERROR)
+ return
+ end
+
+ vim.notify("Attempting to open rocks.nvim log...", vim.log.levels.INFO)
+ local status_ok, err = pcall(vim.cmd, "Rocks log")
+ if not status_ok then
+ vim.notify("Failed to open rocks.nvim log: " .. (err or "Unknown error"), vim.log.levels.ERROR)
+ else
+ vim.notify("rocks.nvim log command executed. It should open in a new buffer/split.", vim.log.levels.INFO)
+ end
+end
+
+-- TODO:
+-- - Explore the actual `rocks_api` table to find available functions.
+-- This might involve printing its contents or using `vim.inspect`.
+-- - Implement robust parsing for `rocks.toml` if direct API calls for listing plugins are not available.
+-- - Develop strategies for handling asynchronous operations from `rocks.nvim`.
+-- This will be crucial for progress updates. `vim.loop.spawn` or `vim.fn.jobstart`
+-- might be needed if we are calling `rocks.nvim` CLI commands directly for some operations.
+-- - Add functions for `sync`, `pin`, `unpin`.
+
+-- #############################################################################
+-- Progress Reporting (Conceptual)
+-- #############################################################################
+
+-- This function would be called by rocks.nvim hooks or by wrappers around
+-- rocks.nvim commands if we were parsing output.
+local function report_progress_to_ui(data)
+ -- Ensure ui module is loaded to avoid errors if it's not yet used
+ local ui_status_ok, ui = pcall(require, "rocks-tui.ui")
+ if ui_status_ok then
+ -- Schedule the UI update to run in the main Neovim loop
+ -- This is important if the progress reporting comes from an async callback
+ vim.schedule(function()
+ ui.update_installation_progress(data)
+ end)
+ else
+ vim.notify("rocks-tui.ui module not found for progress update.", vim.log.levels.ERROR)
+ end
+end
+
+-- Example of how a wrapped command might work (very simplified):
+local function example_install_with_progress(plugin_name)
+ report_progress_to_ui({
+ overall_progress = 0.1,
+ current_operation = "Starting install for " .. plugin_name,
+ plugins_processed = 0, -- Assuming this is part of a batch
+ total_plugins = 1, -- Assuming this is part of a batch
+ detailed_statuses = {{ name = plugin_name, status = "pending" }}
+ })
+
+ -- Simulate some work
+ -- In reality, this would be vim.fn.jobstart() or similar, with event handlers
+ -- that call report_progress_to_ui on stdout/stderr or on exit.
+ vim.defer_fn(function()
+ report_progress_to_ui({
+ overall_progress = 0.5,
+ current_operation = "Downloading " .. plugin_name .. "...",
+ plugins_processed = 0,
+ total_plugins = 1,
+ detailed_statuses = {{ name = plugin_name, status = "downloading" }}
+ })
+ end, 500)
+
+ vim.defer_fn(function()
+ report_progress_to_ui({
+ overall_progress = 1.0,
+ current_operation = "Finished installing " .. plugin_name,
+ plugins_processed = 1,
+ total_plugins = 1,
+ detailed_statuses = {{ name = plugin_name, status = "installed" }}
+ })
+ -- Maybe close progress window automatically after a short delay if it's the last one
+ -- vim.defer_fn(function()
+ -- local ui = require('rocks-tui.ui')
+ -- if ui then ui.close_installation_progress_window() end
+ -- end, 2000)
+ end, 1500)
+
+ -- The actual vim.cmd or API call would go here.
+ -- For now, this is just a placeholder for the concept.
+ vim.notify("Conceptual install for " .. plugin_name .. " (with progress) finished.", vim.log.levels.INFO)
+end
+
+-- Replace M.install_plugin with a version that could conceptually report progress
+-- This is a simplified example. A real implementation would need to properly manage
+-- async jobs and parse their output or use rocks.nvim's Lua API events if available.
+function M.install_plugin(plugin_name_or_url, version)
+ if not rocks_available then
+ vim.notify("rocks.nvim not available", vim.log.levels.ERROR)
+ return false
+ end
+ vim.notify("M.install_plugin() called for: " .. plugin_name_or_url .. (version and ("@"..version) or ""), vim.log.levels.INFO)
+
+ -- Open the progress window when an install starts
+ local ui_status_ok, ui = pcall(require, "rocks-tui.ui")
+ if ui_status_ok then
+ vim.schedule(function() ui.open_installation_progress_window() end)
+ end
+
+ -- Call the example conceptual function (or a real one later)
+ example_install_with_progress(plugin_name_or_url)
+ -- The actual command would be here, and its output/events would drive report_progress_to_ui
+ -- For example:
+ -- local cmd = "Rocks install " .. plugin_name_or_url
+ -- if version then
+ -- cmd = cmd .. " " .. version
+ -- end
+ -- vim.fn.jobstart(cmd, { on_stdout = ..., on_stderr = ..., on_exit = ...})
+
+ return true -- Assuming initiation is success for now
+end
+
+
+-- Similar wrappers would be needed for update_plugin, update_all_plugins, remove_plugin,
+-- and a new function for :Rocks sync.
+
+
+return M
diff --git a/lua/rocks-tui/init.lua b/lua/rocks-tui/init.lua
new file mode 100644
index 0000000..2d237b2
--- /dev/null
+++ b/lua/rocks-tui/init.lua
@@ -0,0 +1,19 @@
+-- Main module for rocks-tui
+local M = {}
+
+local config_module = require('rocks-tui.config')
+
+--- Setup function for the rocks-tui plugin.
+--- Users can call this from their Neovim configuration.
+--- @param user_config table|nil User configuration to override defaults.
+function M.setup(user_config)
+ config_module.setup(user_config)
+ vim.notify("rocks-tui setup complete.", vim.log.levels.INFO)
+end
+
+--- Returns the current configuration, mainly for internal use or debugging.
+function M.get_current_config()
+ return config_module.get_config()
+end
+
+return M
diff --git a/lua/rocks-tui/ui.lua b/lua/rocks-tui/ui.lua
new file mode 100644
index 0000000..d376a17
--- /dev/null
+++ b/lua/rocks-tui/ui.lua
@@ -0,0 +1,463 @@
+-- UI Module for rocks-tui
+local M = {}
+
+local core = require('rocks-tui.core')
+local config_module = require('rocks-tui.config')
+
+local api = vim.api
+local fn = vim.fn
+
+local current_bufnr = nil
+local current_winid = nil
+
+local installed_plugins_cache = {}
+
+--- Close the current TUI window
+local function close_window()
+ if current_winid and api.nvim_win_is_valid(current_winid) then
+ api.nvim_win_close(current_winid, true)
+ end
+ if current_bufnr and api.nvim_buf_is_valid(current_bufnr) then
+ -- Can't delete if it's the current buffer, ensure it's not
+ -- api.nvim_buf_delete(current_bufnr, { force = true })
+ end
+ current_bufnr = nil
+ current_winid = nil
+end
+
+--- Refresh the content of the plugin list window
+local function refresh_plugin_list()
+ if not (current_bufnr and api.nvim_buf_is_valid(current_bufnr)) then
+ return
+ end
+
+ installed_plugins_cache = core.get_installed_plugins() -- Fetch fresh data
+
+ local lines = { "Installed Plugins (rocks-tui)", "---------------------------------" }
+ if #installed_plugins_cache == 0 then
+ table.insert(lines, "No plugins found or rocks.nvim not fully initialized.")
+ table.insert(lines, "Try running :Rocks sync")
+ else
+ for i, plugin in ipairs(installed_plugins_cache) do
+ local status = plugin.status or "N/A"
+ local version = plugin.version or "N/A"
+ table.insert(lines, string.format("%d. %-30s [%-10s] (%s)", i, plugin.name, version, status))
+ end
+ end
+ table.insert(lines, "---------------------------------")
+ table.insert(lines, "Mappings: (q)uit, (r)efresh, (l)ogs")
+ table.insert(lines, " (u)pdate sel, (R)emove sel, (U)pdate All, (s)ync")
+
+
+ api.nvim_buf_set_option(current_bufnr, "modifiable", true)
+ api.nvim_buf_set_lines(current_bufnr, 0, -1, false, lines)
+ api.nvim_buf_set_option(current_bufnr, "modifiable", false)
+end
+
+--- Handle actions on a selected plugin
+local function handle_plugin_action(action)
+ local line_nr = api.nvim_win_get_cursor(0)[1]
+ -- Assuming header lines, adjust index accordingly
+ -- Header: 2 lines, content starts at line 3. So index is line_nr - 2.
+ local plugin_index = line_nr - 2
+
+ if plugin_index > 0 and plugin_index <= #installed_plugins_cache then
+ local plugin = installed_plugins_cache[plugin_index]
+ if not plugin then
+ vim.notify("Could not get plugin at line " .. line_nr, vim.log.levels.ERROR)
+ return
+ end
+
+ if action == "update" then
+ vim.notify(string.format("Updating %s...", plugin.name))
+ core.update_plugin(plugin.name)
+ -- Ideally, rocks.nvim would trigger an event or we'd have a callback
+ -- For now, manual refresh or timed refresh might be needed.
+ vim.defer_fn(refresh_plugin_list, 1000) -- Refresh after a delay
+ elseif action == "remove" then
+ fn.input(string.format("Really remove %s? [y/N]: ", plugin.name)):request(function(input)
+ if input and string.lower(input) == "y" then
+ vim.notify(string.format("Removing %s...", plugin.name))
+ core.remove_plugin(plugin.name)
+ vim.defer_fn(refresh_plugin_list, 1000)
+ else
+ vim.notify("Removal cancelled.", vim.log.levels.INFO)
+ end
+ end)
+ else
+ vim.notify("Unknown action: " .. action, vim.log.levels.WARN)
+ end
+ else
+ vim.notify("No plugin selected or invalid line.", vim.log.levels.WARN)
+ end
+end
+
+--- Setup key mappings for the TUI window
+local function setup_tui_mappings(bufnr)
+ local cfg = config_module.get_config()
+ local keymaps = cfg.keymaps
+
+ local map_opts = { noremap = true, silent = true, nowait = true }
+
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.manager_close, "lua require('rocks-tui.ui').close_managed_window()", map_opts)
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.manager_refresh, "lua require('rocks-tui.ui').refresh_ui()", map_opts)
+
+ -- Actions on selected plugin
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.manager_update_selected, "lua require('rocks-tui.ui').trigger_plugin_action('update')", map_opts)
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.manager_remove_selected, "lua require('rocks-tui.ui').trigger_plugin_action('remove')", map_opts)
+
+ -- Global actions
+ local update_all_cmd = string.format("lua require('rocks-tui.core').update_all_plugins()lua vim.defer_fn(require('rocks-tui.ui').refresh_ui, 1000)")
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.manager_update_all, update_all_cmd, vim.tbl_extend("force", map_opts, {desc = "Update All Plugins"}))
+
+ local sync_cmd = string.format("Rocks synclua vim.defer_fn(require('rocks-tui.ui').refresh_ui, 1000)")
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.manager_sync, sync_cmd, vim.tbl_extend("force", map_opts, {desc = "Sync with rocks.toml"}))
+
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.manager_view_log, "lua require('rocks-tui.core').view_log()", vim.tbl_extend("force", map_opts, {desc = "View rocks.nvim Logs"}))
+end
+
+--- Public function to be called by keymaps for actions
+function M.trigger_plugin_action(action_name)
+ handle_plugin_action(action_name)
+end
+
+--- Public function to be called by keymap for closing
+function M.close_managed_window()
+ close_window()
+end
+
+--- Public function to be called by keymap for refreshing
+function M.refresh_ui()
+ refresh_plugin_list()
+ vim.notify("Plugin list refreshed.", vim.log.levels.INFO)
+end
+
+
+--- Open the plugin management window
+function M.open_plugin_manager()
+ if current_winid and api.nvim_win_is_valid(current_winid) then
+ api.nvim_set_current_win(current_winid)
+ return
+ end
+
+ current_bufnr = api.nvim_create_buf(false, true) -- false: not listed, true: scratch
+ api.nvim_buf_set_option(current_bufnr, "bufhidden", "wipe")
+ api.nvim_buf_set_option(current_bufnr, "buftype", "nofile")
+ api.nvim_buf_set_option(current_bufnr, "swapfile", false)
+ api.nvim_buf_set_option(current_bufnr, "filetype", "RocksTUI") -- For potential syntax highlighting or ftplugins
+
+ local cfg = config_module.get_config().ui.manager_window
+ local editor_cols = api.nvim_get_option("columns")
+ local editor_lines = api.nvim_get_option("lines")
+
+ local width = math.floor(editor_cols * cfg.width_ratio)
+ local height = math.floor(editor_lines * cfg.height_ratio)
+ local row = math.floor((editor_lines - height) / 2)
+ local col = math.floor((editor_cols - width) / 2)
+
+ local win_opts = {
+ relative = "editor",
+ width = width,
+ height = height,
+ row = row,
+ col = col,
+ style = "minimal",
+ border = cfg.border,
+ title = cfg.title,
+ title_pos = "center",
+ }
+
+ current_winid = api.nvim_open_win(current_bufnr, true, win_opts)
+ -- local winhl = string.format("Normal:%s,FloatBorder:%s",
+ -- config_module.get_config().ui.Normal or "NormalFloat",
+ -- config_module.get_config().ui.FloatBorder or "FloatBorder")
+ -- api.nvim_win_set_option(current_winid, "winhl", winhl)
+ -- It's often better to let users theme these via global highlights like NormalFloat, FloatBorder
+
+ refresh_plugin_list()
+ setup_tui_mappings(current_bufnr)
+end
+
+
+-- Placeholder for other UI components (Search, Progress)
+local search_winid = nil
+local search_bufnr = nil
+local search_results_cache = {}
+
+--- Close the current search window
+local function close_search_window()
+ if search_winid and api.nvim_win_is_valid(search_winid) then
+ api.nvim_win_close(search_winid, true)
+ end
+ search_winid = nil
+ -- search_bufnr = nil -- Optional: clear buffer too
+end
+
+--- Refresh the content of the search results window
+local function refresh_search_results_list(query)
+ if not (search_bufnr and api.nvim_buf_is_valid(search_bufnr)) then
+ return
+ end
+
+ search_results_cache = core.search_plugins(query or "") -- Fetch fresh data
+
+ local lines = { string.format("Search Results for '%s' (rocks-tui)", query or ""), "---------------------------------" }
+ if #search_results_cache == 0 then
+ table.insert(lines, "No plugins found for your query.")
+ else
+ for i, plugin in ipairs(search_results_cache) do
+ table.insert(lines, string.format("%d. %-30s", plugin.name))
+ table.insert(lines, string.format(" %s", plugin.description or "No description."))
+ end
+ end
+ table.insert(lines, "---------------------------------")
+ table.insert(lines, "Mappings: (q)uit, (i)nstall selected") -- TODO: Add install mapping
+
+ api.nvim_buf_set_option(search_bufnr, "modifiable", true)
+ api.nvim_buf_set_lines(search_bufnr, 0, -1, false, lines)
+ api.nvim_buf_set_option(search_bufnr, "modifiable", false)
+end
+
+--- Handle install action on a selected search result
+local function handle_search_install_action()
+ local line_nr = api.nvim_win_get_cursor(0)[1]
+ -- Header: 2 lines. Each plugin takes 2 lines. Index is (line_nr - 3) / 2 + 1
+ -- Or, more simply, if we just select based on the plugin name line:
+ -- (line_nr - 2) should be odd. plugin_index = (line_nr - 2 + 1) / 2
+ if line_nr <= 2 then return end -- Clicked on header
+
+ local item_index_on_screen = line_nr - 2
+ -- Each item (name + desc) takes 2 lines. So the actual plugin index is:
+ local plugin_index = math.floor((item_index_on_screen -1) / 2) + 1
+
+ if plugin_index > 0 and plugin_index <= #search_results_cache then
+ local plugin = search_results_cache[plugin_index]
+ if not plugin then
+ vim.notify("Could not get plugin at line " .. line_nr, vim.log.levels.ERROR)
+ return
+ end
+
+ fn.input(string.format("Install %s? [y/N] (version can be specified, e.g., 'y 1.2.0' or 'y dev'): ", plugin.name)):request(function(input)
+ if input and string.lower(input:match("^%s*(%S+)")) == "y" then
+ local _, _, version_str = input:find("^%s*y%s*(.*)$")
+ version_str = version_str and vim.trim(version_str) or nil
+ if version_str == "" then version_str = nil end
+
+ vim.notify(string.format("Attempting to install %s%s...", plugin.name, version_str and "@"..version_str or ""))
+ core.install_plugin(plugin.name, version_str) -- core.install_plugin handles opening progress UI
+ -- No need to refresh search results, but user might want to see it in main manager later
+ close_search_window() -- Close search window after attempting install
+ else
+ vim.notify("Installation cancelled.", vim.log.levels.INFO)
+ end
+ end)
+ else
+ vim.notify("No plugin selected or invalid line for installation.", vim.log.levels.WARN)
+ end
+end
+
+
+--- Setup key mappings for the search TUI window
+local function setup_search_tui_mappings(bufnr)
+ local cfg = config_module.get_config()
+ local keymaps = cfg.keymaps
+ local map_opts = { noremap = true, silent = true, nowait = true }
+
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.search_close, "lua require('rocks-tui.ui').close_search_results_window()", map_opts)
+ api.nvim_buf_set_keymap(bufnr, "n", keymaps.search_install_selected, "lua require('rocks-tui.ui').trigger_search_install_action()", map_opts)
+ -- Potentially add 'r' to re-search with a new query or refresh current
+end
+
+--- Public function for search install action keymap
+function M.trigger_search_install_action()
+ handle_search_install_action()
+end
+
+--- Public function for closing search window keymap
+function M.close_search_results_window()
+ close_search_window()
+end
+
+--- Open the plugin search window
+function M.open_search_window()
+ if search_winid and api.nvim_win_is_valid(search_winid) then
+ api.nvim_set_current_win(search_winid)
+ return
+ end
+
+ vim.ui.input({ prompt = "Search on LuaRocks (or enter git URL):" }, function(query)
+ if query == nil or query == "" then
+ vim.notify("Search cancelled.", vim.log.levels.INFO)
+ return
+ end
+
+ search_bufnr = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_option(search_bufnr, "bufhidden", "wipe")
+ api.nvim_buf_set_option(search_bufnr, "buftype", "nofile")
+ api.nvim_buf_set_option(search_bufnr, "swapfile", false)
+ api.nvim_buf_set_option(search_bufnr, "filetype", "RocksTUISearch")
+
+ local cfg = config_module.get_config().ui.search_window
+ local editor_cols = api.nvim_get_option("columns")
+ local editor_lines = api.nvim_get_option("lines")
+
+ local width = math.floor(editor_cols * cfg.width_ratio)
+ local height = math.floor(editor_lines * cfg.height_ratio)
+ local row = math.floor((editor_lines - height) / 2)
+ local col = math.floor((editor_cols - width) / 2)
+
+ local win_opts = {
+ relative = "editor",
+ width = width,
+ height = height,
+ row = row,
+ col = col,
+ style = "minimal",
+ border = cfg.border,
+ title = cfg.title,
+ title_pos = "center",
+ }
+
+ search_winid = api.nvim_open_win(search_bufnr, true, win_opts)
+ -- Using global highlights like NormalFloat, FloatBorder is generally preferred
+
+ refresh_search_results_list(query)
+ setup_search_tui_mappings(search_bufnr)
+ end)
+end
+
+local progress_winid = nil
+local progress_bufnr = nil
+local progress_cache = {} -- Store the latest progress data
+
+local function create_progress_bar(percentage, width)
+ local filled_width = math.floor(percentage * width)
+ local empty_width = width - filled_width
+ return "Progress: [" .. string.rep("=", filled_width) .. string.rep("-", empty_width) .. string.format("] %.0f%%", percentage * 100)
+end
+
+--- Updates or creates the installation progress window
+--- @param data table Expected fields:
+-- data.overall_progress (float, 0.0 to 1.0)
+-- data.current_operation (string, e.g., "Syncing", "Installing plugin_name")
+-- data.plugins_processed (number)
+-- data.total_plugins (number)
+-- data.log_messages (table of strings, optional)
+function M.update_installation_progress(data)
+ progress_cache = data -- Cache the latest data
+
+ if not (progress_winid and api.nvim_win_is_valid(progress_winid)) then
+ -- Window is not open, so don't try to update.
+ -- It can be opened manually or by an event.
+ return
+ end
+
+ if not (progress_bufnr and api.nvim_buf_is_valid(progress_bufnr)) then
+ vim.notify("Progress buffer is invalid.", vim.log.levels.ERROR)
+ return
+ end
+
+ local lines = { "rocks.nvim - Installation Progress", "------------------------------------" }
+
+ local overall_progress = data.overall_progress or 0
+ local current_op = data.current_operation or "Waiting for operation to start..."
+ local plugins_processed = data.plugins_processed or 0
+ local total_plugins = data.total_plugins or 0
+
+ table.insert(lines, current_op)
+ if total_plugins > 0 then
+ table.insert(lines, string.format("Plugins: %d / %d", plugins_processed, total_plugins))
+ end
+ table.insert(lines, create_progress_bar(overall_progress, 40)) -- 40 char wide bar
+ table.insert(lines, "------------------------------------")
+
+ if data.detailed_statuses then
+ for _, p_status in ipairs(data.detailed_statuses) do
+ table.insert(lines, string.format("- %s: %s", p_status.name, p_status.status))
+ end
+ table.insert(lines, "------------------------------------")
+ end
+
+
+ if data.log_messages and #data.log_messages > 0 then
+ for _, msg in ipairs(data.log_messages) do
+ table.insert(lines, msg)
+ end
+ end
+
+ api.nvim_buf_set_option(progress_bufnr, "modifiable", true)
+ api.nvim_buf_set_lines(progress_bufnr, 0, -1, false, lines)
+ api.nvim_buf_set_option(progress_bufnr, "modifiable", false)
+end
+
+
+--- Opens the installation progress window
+function M.open_installation_progress_window()
+ if progress_winid and api.nvim_win_is_valid(progress_winid) then
+ api.nvim_set_current_win(progress_winid)
+ return
+ end
+
+ progress_bufnr = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_option(progress_bufnr, "bufhidden", "wipe")
+ api.nvim_buf_set_option(progress_bufnr, "buftype", "nofile")
+ api.nvim_buf_set_option(progress_bufnr, "swapfile", false)
+ api.nvim_buf_set_option(progress_bufnr, "filetype", "RocksTUIProgress")
+
+ local cfg = config_module.get_config().ui.progress_window
+ local editor_cols = api.nvim_get_option("columns")
+ local editor_lines = api.nvim_get_option("lines")
+
+ local width = math.floor(editor_cols * cfg.width_ratio)
+ local height = math.floor(editor_lines * cfg.height_ratio)
+ -- Position towards bottom, but ensure it's on screen
+ local row = math.max(0, math.min(editor_lines - height -1, math.floor((editor_lines - height) * 0.8)))
+ local col = math.floor((editor_cols - width) / 2)
+
+
+ local win_opts = {
+ relative = "editor",
+ width = width,
+ height = height,
+ row = row,
+ col = col,
+ style = "minimal",
+ border = cfg.border,
+ title = cfg.title,
+ title_pos = "center",
+ zindex = cfg.zindex,
+ }
+
+ progress_winid = api.nvim_open_win(progress_bufnr, true, win_opts)
+ -- Using global highlights like NormalFloat, FloatBorder is generally preferred
+
+ -- Initial update with cached or default data
+ M.update_installation_progress(progress_cache or {
+ overall_progress = 0,
+ current_operation = "Initializing...",
+ plugins_processed = 0,
+ total_plugins = 0,
+ log_messages = {"Waiting for rocks.nvim operations..."}
+ })
+
+ -- Basic mapping to close this window
+ local keymaps = config_module.get_config().keymaps
+ local map_opts = { noremap = true, silent = true, nowait = true }
+ api.nvim_buf_set_keymap(progress_bufnr, "n", keymaps.progress_close, "lua require('rocks-tui.ui').close_installation_progress_window()", map_opts)
+end
+
+--- Closes the installation progress window
+function M.close_installation_progress_window()
+ if progress_winid and api.nvim_win_is_valid(progress_winid) then
+ api.nvim_win_close(progress_winid, true)
+ end
+ -- Don't delete buffer if we want to reopen with same content, but for progress, fresh is usually better.
+ -- if progress_bufnr and api.nvim_buf_is_valid(progress_bufnr) then
+ -- api.nvim_buf_delete(progress_bufnr, { force = true })
+ -- end
+ progress_winid = nil
+ -- progress_bufnr = nil -- Keep bufnr if we want to quickly reopen and update
+end
+
+
+return M
diff --git a/plugin/rocks-tui.lua b/plugin/rocks-tui.lua
new file mode 100644
index 0000000..458e9ac
--- /dev/null
+++ b/plugin/rocks-tui.lua
@@ -0,0 +1,31 @@
+-- Plugin entry point
+-- This file will be sourced by Neovim at startup if the plugin is installed
+
+-- Example: Expose a setup command
+vim.api.nvim_create_user_command('RocksTUISetup', function(opts)
+ require('rocks-tui').setup(opts.fargs)
+end, { nargs = '*' })
+
+-- Command to open the plugin manager TUI
+vim.api.nvim_create_user_command('RocksTUI', function()
+ require('rocks-tui.ui').open_plugin_manager()
+end, { desc = "Open RocksTUI plugin manager" })
+
+-- Command to open the installation progress window
+vim.api.nvim_create_user_command('RocksTUIProgress', function()
+ require('rocks-tui.ui').open_installation_progress_window()
+end, { desc = "Show RocksTUI installation progress" })
+
+-- Command to open the plugin search TUI
+vim.api.nvim_create_user_command('RocksTUISearch', function()
+ require('rocks-tui.ui').open_search_window()
+end, { desc = "Search for plugins with RocksTUI" })
+
+
+-- Example: A placeholder command for the TUI
+-- vim.api.nvim_create_user_command('RocksTUIOld', function()
+-- vim.notify("RocksTUI coming soon!", vim.log.levels.INFO)
+-- end, {})
+
+-- You might want to call a setup function from here if you have default configurations
+-- require('rocks-tui').setup({})