Skip to content

Conversation

@NobbZ
Copy link
Owner

@NobbZ NobbZ commented Mar 25, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration option for workspace management with the AUGMENT_WORKSPACE variable.
    • Added a new entry for the "nvim-augment" plugin, ensuring access to the latest version.
    • Released a new augment module that includes chat commands and key mappings for enhanced user interaction.
    • Enhanced plugin management with explicit optional plugin settings.
  • Chores

    • Improved the plugin loading process to streamline dependency handling.
    • Added a new dependency on nodejs to enhance Neovim setup.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

📝 Walkthrough

Walkthrough

This pull request introduces new environment configurations, plugin specifications, and lazy loading improvements. A new environment variable (AUGMENT_WORKSPACE) is exported, and the Node.js dependency is integrated via nvim.nix with an associated AUGMENT_NODE variable. Additionally, a new "nvim-augment" entry is added in the sources JSON. Plugin management is updated with optional plugins functionality in plugins/default.nix, and a new augment plugin is established in Lua files. The lazy loading system has been reworked by replacing the old loader with the new nobbz.lazy module and added specifications.

Changes

File(s) Change Summary
.envrc, nvim.nix Added new environment variables and dependencies: AUGMENT_WORKSPACE is exported; nodejs is added with AUGMENT_NODE set to its executable path.
npins/sources.json Added a new "nvim-augment" entry with GitRelease properties, including repository details, version, revision, URL, and hash for integrity verification.
plugins/default.nix Introduced an optionalPlugins mapping and a new makeOptional function for managing plugin optionality.
plugins/nobbz/lua/nobbz/{augment.lua, init.lua} Added a new augment plugin: In augment.lua, environment variables are read, global variables are set, and key mappings are defined; In init.lua, replaced the old lazy loader (lz.n) with nobbz.lazy, added a call to load the new "augment" spec, and invoked lazy.finish().
plugins/nobbz/lua/nobbz/lazy/{init.lua, specs.lua} Introduced new lazy loading modules: init.lua provides functions (finish, packadd, load_once, and add_specs) for managing plugin configurations, and specs.lua defines an empty module for holding specifications.

Sequence Diagram(s)

sequenceDiagram
    participant Env as .envrc
    participant Nvim as nvim.nix
    participant Augment as Augment Plugin (augment.lua)
    participant Lazy as Lazy Loader (nobbz.lazy)
    participant User as Neovim User

    Env->>Nvim: Set AUGMENT_WORKSPACE
    Nvim->>Nvim: Configure AUGMENT_NODE with nodejs
    Augment->>Env: Retrieve environment variables
    Augment->>Lazy: Register augment plugin spec and key mappings
    Lazy->>Augment: Load and finish lazy configuration
    User->>Augment: Trigger plugin commands via key mappings
Loading

Poem

I hopped through lines of code today,
New vars and plugins light my way,
From env to lazy loads so neat,
With Node.js, our setup's complete!
My floppy ears dance in glee 🐇,
Hoppy changes bring joy to me!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
plugins/default.nix (1)

16-24: Well-structured approach for optional plugins management

The introduction of the optionalPlugins attribute set and the makeOptional function provides a clean way to handle plugin optionality. This is a good architectural improvement that increases flexibility in the plugin system.

One small suggestion: consider changing the warning message from "assuming mandatoryness" to "assuming mandatory status" for better clarity and standard English usage.

-      optional = optionalPlugins.${name} or (lib.warn "${name} has no explicit optionality, assuming mandatoryness" false);
+      optional = optionalPlugins.${name} or (lib.warn "${name} has no explicit optionality, assuming mandatory status" false);
plugins/nobbz/lua/nobbz/lazy/specs.lua (1)

1-4: Add documentation for better maintainability

This module appears to be laying the groundwork for a plugin specification system, but lacks documentation. Consider adding comments explaining the purpose of this module and how it interacts with the broader system.

---@type lz.n.Spec
+--- Module for storing lazy-loaded plugin specifications
+--- This module is populated through nobbz.lazy.add_specs and used by the lazy loading system
local M = {}

return M
nvim.nix (1)

115-117: Add a comment explaining the purpose of AUGMENT_NODE

The environment variable setup looks good, but consider adding a brief comment explaining what this variable is used for and why Node.js is needed.

        "--set"
        "NOBBZ_NVIM_PATH"
        "${placeholder "out"}/bin/nvim"
+       # Set Node.js path for the augment plugin
        "--set"
        "AUGMENT_NODE"
        "${lib.getExe nodejs}"
plugins/nobbz/lua/nobbz/lazy/init.lua (1)

19-19: Remove or improve the debug notification.

The vim.notify(k) call appears to be a debugging statement that should be removed or enhanced with more context for production code.

-    vim.notify(k)
+    -- Remove this line if it's just for debugging
+    -- Or improve it with context if it's intended for users
+    -- vim.notify("Loading plugin " .. v, vim.log.levels.INFO)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b2d69d and cde0f8c.

📒 Files selected for processing (8)
  • .envrc (1 hunks)
  • npins/sources.json (1 hunks)
  • nvim.nix (2 hunks)
  • plugins/default.nix (1 hunks)
  • plugins/nobbz/lua/nobbz/augment.lua (1 hunks)
  • plugins/nobbz/lua/nobbz/init.lua (3 hunks)
  • plugins/nobbz/lua/nobbz/lazy/init.lua (1 hunks)
  • plugins/nobbz/lua/nobbz/lazy/specs.lua (1 hunks)
🔇 Additional comments (14)
plugins/default.nix (1)

30-30: LGTM - Good integration with the existing plugin pipeline

The integration of makeOptional into the existing plugin processing pipeline is clean and non-disruptive.

.envrc (1)

5-5: LGTM - Good addition of workspace environment variable

The export of AUGMENT_WORKSPACE is straightforward and properly sets the current working directory for the augment plugin.

nvim.nix (1)

9-9: LGTM - Node.js dependency added correctly

Adding Node.js as a dependency is appropriate for supporting the augment plugin functionality.

plugins/nobbz/lua/nobbz/init.lua (4)

1-1: Module dependency change looks good.

The change from using the external lz.n module directly to a custom wrapper module nobbz.lazy is a good architectural decision that provides more control over the lazy loading interface.


28-28: Well-placed AI module integration.

This addition loads the new augment module which is properly documented with a clear comment about its AI functionality.


49-52: API update is consistent with the new module approach.

The replacement of lz_n.load({...}) with lazy.add_specs({...}) maintains the same functionality while using the new wrapper interface.


53-53: Proper finalization of the lazy loading process.

The addition of lazy.finish() ensures proper completion of the lazy loading setup, which is consistent with the new architecture.

plugins/nobbz/lua/nobbz/lazy/init.lua (3)

4-6: Clean implementation of the finish function.

The function correctly completes the configuration by loading specifications from the dedicated specs module.


8-11: Effective plugin loading wrapper.

The packadd function provides a clean abstraction over the Neovim API for adding plugins.


28-31: Well-implemented specs extension function.

The function correctly extends the existing specifications using Vim's list extension utility.

plugins/nobbz/lua/nobbz/augment.lua (3)

1-3: Good environment variable handling.

The code properly retrieves environment variables that will be used for conditional plugin loading.


4-14: Well-structured plugin specification with proper conditional loading.

The augment plugin specification is well-defined with appropriate conditional enabling based on environment variables. The before function correctly sets up global variables required by the plugin.


16-22: Comprehensive key mappings for the augment plugin.

The key mappings are well-organized with a dedicated leader key group and descriptive commands. The usage of WhichKey for mapping definition provides good discoverability for users.

npins/sources.json (1)

39-53: Well-configured augment plugin source.

The new entry for "nvim-augment" is properly configured with all necessary fields and pinned to a specific version (v0.26.0) for stability. The configuration aligns well with the augment module implementation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
plugins/nobbz/lua/nobbz/lazy/init.lua (2)

13-24: Consider adding error handling for more robustness.

The load_once function might benefit from some validation to handle cases where the plugin name doesn't exist in the state.

M.load_once = function(name)
  local state = require("lz.n.state").plugins
+ if not name or type(name) ~= "string" then
+   vim.notify("Invalid plugin name provided", vim.log.levels.ERROR)
+   return
+ end
  require("lz.n").trigger_load(name)

  for k, v in ipairs(state) do
    if v == name then
      table.remove(state, k)
      break
    end
  end
+ -- Optional: Notify if plugin wasn't found in state
+ if not found then
+   vim.notify("Plugin '" .. name .. "' not found in state", vim.log.levels.DEBUG)
+ end
end

3-6: Consider enhancing documentation for better maintainability.

While the current documentation is adequate, more detailed descriptions would help future maintainers understand the purpose and behavior of each function.

---finishes the configuration of `lz.n`.
+---Completes the configuration by loading all specifications.
+---This should be called after all specs have been added.
M.finish = function()
  require("lz.n").load(require("nobbz.lazy.specs"))
end
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cde0f8c and 848e62d.

📒 Files selected for processing (4)
  • nvim.nix (2 hunks)
  • plugins/default.nix (1 hunks)
  • plugins/nobbz/lua/nobbz/lazy/init.lua (1 hunks)
  • plugins/nobbz/lua/nobbz/lazy/specs.lua (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • plugins/nobbz/lua/nobbz/lazy/specs.lua
  • plugins/default.nix
  • nvim.nix
🔇 Additional comments (5)
plugins/nobbz/lua/nobbz/lazy/init.lua (5)

1-31: Overall structure looks good, with clear module organization.

The module provides a clean interface for lazy loading plugins with well-defined functions for configuration, loading, and management.


3-6: LGTM: Finish function implementation is straightforward.

The function correctly loads specifications from the required module.


8-11: LGTM: Packadd wrapper is well implemented.

Good use of Neovim API to expose the packadd functionality.


13-24: LGTM: Load_once implementation is correct.

This function correctly handles triggering the load and updating the plugin state. I see the previous issue with table.remove has been fixed by using the index parameter correctly.


26-29: LGTM: Add_specs function is simple and effective.

The implementation correctly extends the specifications list.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
plugins/nobbz/lua/nobbz/lazy/init.lua (3)

7-9: Consider adding error handling to the finish function.

The function loads specifications from an external module but doesn't handle potential errors if the required module is missing or contains syntax errors.

M.finish = function()
+  local ok, specs = pcall(require, "nobbz.lazy.specs")
+  if not ok then
+    vim.notify("Failed to load specifications: " .. tostring(specs), vim.log.levels.ERROR)
+    return
+  end
-  require("lz.n").load(require("nobbz.lazy.specs"))
+  require("lz.n").load(specs)
end

37-40: Guard against adding specs after finish is called.

The documentation for finish states that "there is no way to effectively add more specs" after it has been called, but there's no mechanism to prevent this. Consider adding a state flag to track whether finish has been called.

local M = {}
+local _finished = false

M.finish = function()
+  _finished = true
  require("lz.n").load(require("nobbz.lazy.specs"))
end

---@param specs lz.n.Spec[]
M.add_specs = function(specs)
+  if _finished then
+    vim.notify("Cannot add specs after finish() has been called", vim.log.levels.WARN)
+    return
+  end
  vim.list_extend(require("nobbz.lazy.specs"), specs)
end

16-35: Ensure proper handling of plugins that don't exist in state.

The function correctly handles non-existent plugin names with a warning notification, but consider returning a boolean to indicate success/failure for better programmatic usage.

---@param name string
+---@return boolean success Whether the plugin was found and loaded
M.load_once = function(name)
  if not name or type(name) ~= "string" then
    vim.notify("Invalid plugin name provided", vim.log.levels.ERROR)
-    return
+    return false
  end

  local state = require("lz.n.state").plugins
  require("lz.n").trigger_load(name)

  for k, v in ipairs(state) do
    if v == name then
      table.remove(state, k)
-      return
+      return true
    end
  end

  -- Only reached if `name` was not in `state`:
  vim.notify("Plugin " .. name .. " not found in state", vim.log.levels.WARN)
+  return false
end
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 848e62d and ee968e7.

📒 Files selected for processing (1)
  • plugins/nobbz/lua/nobbz/lazy/init.lua (1 hunks)
🔇 Additional comments (1)
plugins/nobbz/lua/nobbz/lazy/init.lua (1)

11-14: LGTM: The packadd function looks good.

This is a simple and clean wrapper around the Neovim API command, with proper type annotation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
plugins/nobbz/lua/nobbz/lazy/init.lua (1)

1-52: Consider adding unit tests for this module.

This module handles critical plugin loading functionality. Adding unit tests would help ensure continued reliability, especially for edge cases like invalid plugin names or handling of the _finished state.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee968e7 and 7cff831.

📒 Files selected for processing (2)
  • plugins/nobbz/lua/nobbz/lazy/init.lua (1 hunks)
  • plugins/nobbz/lua/nobbz/lazy/specs.lua (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/nobbz/lua/nobbz/lazy/specs.lua
🔇 Additional comments (5)
plugins/nobbz/lua/nobbz/lazy/init.lua (5)

1-3: Good attribution practice.

Properly acknowledging the source of the borrowed implementation with a specific commit link is excellent practice for open source collaboration.


7-14: Well-documented function with clear constraints.

The documentation clearly explains the purpose and limitations of the finish function. The implementation correctly sets a completion flag and loads the specifications.


16-19: Clean implementation of packadd wrapper.

The function provides a convenient wrapper around Neovim's command API with appropriate type annotation.


21-40: Fixed implementation of load_once function.

The function now correctly uses the index k when removing an item from the state table, addressing the previously reported issue.


42-50: Well-designed spec management with validation.

The add_specs function properly validates the module state before attempting to modify specs and provides helpful error messaging.

@NobbZ NobbZ merged commit 0aa28b0 into main Mar 26, 2025
1 check passed
@NobbZ NobbZ deleted the augment branch March 26, 2025 07:51
@coderabbitai coderabbitai bot mentioned this pull request Mar 26, 2025
This was referenced Apr 4, 2025
This was referenced May 25, 2025
@coderabbitai coderabbitai bot mentioned this pull request Nov 9, 2025
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