Skip to content

Conversation

@NobbZ
Copy link
Owner

@NobbZ NobbZ commented Jul 19, 2025

Summary by CodeRabbit

  • New Features

    • Expanded snippet loading to support multiple directories, including project-specific and user-level snippet folders.
    • Automatically detects and adds Git repository root snippets if available.
  • Enhancements

    • Improved configuration for snippet sources, allowing broader and more flexible snippet management.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 19, 2025

Walkthrough

A new helper module was added to detect the Git root directory. The snippet loader logic in luasnip.lua was updated to use this helper, expanding snippet source paths to include project and user-specific directories. Keybinding registrations were repositioned, but their content remained unchanged.

Changes

File(s) Change Summary
plugins/nobbz/lua/nobbz/helpers.lua Added new helper module with git_root() function to determine the Git repository root directory.
plugins/nobbz/lua/nobbz/luasnip.lua Required the new helper, enhanced snippet loader to use multiple paths (including Git root), reordered keybinding registration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant luasnip.lua
    participant helpers.lua

    User->>luasnip.lua: Load snippets
    luasnip.lua->>helpers.lua: Call git_root()
    helpers.lua-->>luasnip.lua: Return Git root path or nil
    luasnip.lua->>luasnip.lua: Build snippet paths list
    luasnip.lua->>luasnip.lua: Load snippets from all paths
Loading

Possibly related PRs

  • luasnip-again #70: Modifies snippet loading and keybindings in luasnip.lua, related to how snippet paths are managed, but does not use Git root detection.

Poem

A helper appears, so clever and neat,
To find the Git root beneath our feet.
Now snippets can gather from far and near,
Project or user, all will appear!
🐇✨ With code that hops, and paths that grow,
Lua magic helps our snippets flow.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

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: 0

🧹 Nitpick comments (2)
plugins/nobbz/lua/nobbz/helpers.lua (1)

4-8: Consider adding error handling for handle:read() failure.

While the current implementation handles io.popen failure, it could be more robust by also handling potential handle:read() failures.

function M.git_root()
  local handle = io.popen("git rev-parse --show-toplevel 2> /dev/null")
  if not handle then return nil end

-  local result = handle:read("*a")
+  local result = handle:read("*a")
+  if not result then
+    handle:close()
+    return nil
+  end
  handle:close()
plugins/nobbz/lua/nobbz/luasnip.lua (1)

42-42: Consider using debug log level for git root notification.

The notification about git root detection might be too verbose for regular use. Consider using vim.log.levels.DEBUG instead of INFO.

-  vim.notify("git root: " .. git_root, vim.log.levels.INFO)
+  vim.notify("git root: " .. git_root, vim.log.levels.DEBUG)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f445ba9 and 8b022d9.

📒 Files selected for processing (2)
  • plugins/nobbz/lua/nobbz/helpers.lua (1 hunks)
  • plugins/nobbz/lua/nobbz/luasnip.lua (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
plugins/**/*.lua

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🧠 Learnings (2)
📓 Common learnings
Learnt from: NobbZ
PR: NobbZ/nobbz-vim#0
File: :0-0
Timestamp: 2025-04-12T09:24:45.451Z
Learning: NobbZ uses a homebrewn shallow abstraction over `lz.n` rather than using lazy.nvim directly. References to Lazy.nvim's specific features should be avoided in reviews of NobbZ's repository.
plugins/nobbz/lua/nobbz/luasnip.lua (2)
Learnt from: NobbZ
PR: NobbZ/nobbz-vim#0
File: :0-0
Timestamp: 2025-04-12T09:24:45.451Z
Learning: NobbZ uses a homebrewn shallow abstraction over `lz.n` rather than using lazy.nvim directly. References to Lazy.nvim's specific features should be avoided in reviews of NobbZ's repository.
Learnt from: NobbZ
PR: NobbZ/nobbz-vim#19
File: plugins/nobbz/lua/nobbz/lsp/beancount.lua:3-6
Timestamp: 2025-01-31T23:06:17.133Z
Learning: In the nobbz-vim project, `LSP_CAPAS` is defined as a global variable in `plugins/nobbz/lua/nobbz/init.lua` and should be used for LSP capabilities across the codebase.
🔇 Additional comments (4)
plugins/nobbz/lua/nobbz/helpers.lua (1)

1-19: LGTM! Well-structured helper module with proper error handling.

The module follows the luarocks style guide correctly with proper local usage and 2-space indentation. The git_root() function implementation is solid with appropriate error handling for both command failure and empty output cases.

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

1-1: LGTM! Proper local require statement.

The helpers module is correctly imported using local as required by the coding guidelines.


31-35: LGTM! Keybinding registration repositioning.

The keybinding registrations were moved but their content remains unchanged. The new position after the list_snips function definition is appropriate.


39-47: Excellent snippet path expansion implementation!

The implementation correctly:

  • Uses the helpers module to detect git root
  • Constructs a paths table starting with the script's luasnip directory
  • Conditionally adds project-specific snippets when git root is detected
  • Includes helpful logging for debugging
  • Adds user config snippets as fallback
  • Passes the expanded paths to the loader

This enables snippet loading from multiple sources as intended by the PR objectives.

@NobbZ NobbZ merged commit 09544f8 into main Jul 19, 2025
3 checks passed
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