-
Notifications
You must be signed in to change notification settings - Fork 4
snippet from elsewhere #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new helper module was added to detect the Git root directory. The snippet loader logic in Changes
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
Possibly related PRs
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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.popenfailure, it could be more robust by also handling potentialhandle: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.DEBUGinstead ofINFO.- 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
📒 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
localusage and 2-space indentation. Thegit_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
localas 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_snipsfunction 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.
Summary by CodeRabbit
New Features
Enhancements