Skip to content

Conversation

@NobbZ
Copy link
Owner

@NobbZ NobbZ commented Jun 13, 2025

Summary by CodeRabbit

  • New Features

    • Added a new snippet for git commit messages triggered by "sc", providing a template for short-cut tickets.
    • Introduced a user command to list available snippets for the current filetype.
  • Improvements

    • Updated key bindings for completion navigation and snippet control to streamline workflow.
    • Enabled autosnippet functionality for snippets.
    • Simplified snippet navigation by consolidating keybindings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

Walkthrough

Key bindings for completion and snippet navigation in the blink and luasnip plugins were updated. Custom snippet navigation functions were removed, and snippet loading was switched to a directory-based approach. A new gitcommit snippet module was added, and a user command for listing snippets was introduced.

Changes

File(s) Change Summary
plugins/nobbz/lua/nobbz/blink.lua Reassigned key bindings for completion navigation and documentation scrolling; updated snippet navigation keys.
plugins/nobbz/lua/nobbz/luasnip.lua Enabled autosnippets, removed custom navigation functions, added snippet listing command, changed loading path.
plugins/nobbz/lua/nobbz/luasnip/gitcommit.lua Added new snippet module for gitcommit messages with a "short-cut ticket" snippet.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Neovim
    participant Blink
    participant LuaSnip

    User->>Neovim: Presses new completion/snippet keys
    Neovim->>Blink: Triggers completion navigation (e.g., <C-l>, <C-h>)
    Blink-->>Neovim: Provides completion suggestions

    User->>Neovim: Presses snippet expansion key (<C-k>)
    Neovim->>LuaSnip: Expands or jumps in snippet

    User->>Neovim: Executes :SnipList
    Neovim->>LuaSnip: Lists available snippets for filetype
Loading

Possibly related PRs

  • NobbZ/nobbz-vim#67: Modifies key bindings and snippet navigation logic in luasnip.lua, similar to the changes in this PR.
  • NobbZ/nobbz-vim#69: Alters snippet activation logic in blink.lua regarding LuaSnip integration, related to configuration and behavior updates in this PR.

Poem

A rabbit hopped through Lua code,
Rebinding keys along its road.
Snippets now load from a tidy den,
And listing them is easy—just say when!
With "sc" in gitcommit, tickets appear,
The code is now snappier—let’s all cheer!
🐇✨

✨ 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: 3

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

29-29: Path concatenation lacks a trailing slash

script_path("luasnip") returns “…/luasnip” (no /).
luasnip.loaders.from_lua accepts both styles, yet a trailing slash avoids edge-cases when the parent path does not include one.

-lualoader.load({ paths = script_path("luasnip"), })
+lualoader.load({ paths = script_path("luasnip/"), })
plugins/nobbz/lua/nobbz/luasnip/gitcommit.lua (1)

1-1: Remove stray debug print

vim.print("luasnip loading") is useful while developing, but it pollutes the message area every time snippets are (re)loaded.

-vim.print("luasnip loading")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a223030 and 6239912.

📒 Files selected for processing (3)
  • plugins/nobbz/lua/nobbz/blink.lua (1 hunks)
  • plugins/nobbz/lua/nobbz/luasnip.lua (1 hunks)
  • plugins/nobbz/lua/nobbz/luasnip/gitcommit.lua (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`plugins/**/*.lua`: Please ensure all of the following: - Plugins are lazyloaded if possible through `nobbz.lazy` - `local` has to be used - coding follows the [luarocks styleguide...

plugins/**/*.lua: Please ensure all of the following:

  • Plugins are lazyloaded if possible through nobbz.lazy
  • local has to be used
  • coding follows the luarocks styleguide, but with 2 spaces indentation
  • plugins/nobbz/lua/nobbz/blink.lua
  • plugins/nobbz/lua/nobbz/luasnip/gitcommit.lua
  • plugins/nobbz/lua/nobbz/luasnip.lua
🔇 Additional comments (2)
plugins/nobbz/lua/nobbz/luasnip.lua (1)

8-10: Potential key-mapping collision with <C-k>

<C-k> is bound here to luasnip.expand, but in blink.lua it is also mapped to scroll_documentation_up.
Verify which plugin wins in Insert/Select mode — the losing mapping becomes unreachable.

If both are required, consider a different expansion key (eg. <C-e> which you freed in blink).

plugins/nobbz/lua/nobbz/blink.lua (1)

60-67: Key-binding overlap: <C-k> now doubles as snippet expansion and doc-scroll

luasnip.lua binds <C-k> to luasnip.expand; here the same chord scrolls documentation.
Unless blink’s higher precedence disables snippet expansion, users will get unpredictable behaviour.

Confirm precedence or remap one of the functions.

Comment on lines +18 to +24
local function list_snips()
local ft_list = luasnip.available()[vim.o.filetype]
local ft_snips = {}
for _, item in pairs(ft_list) do
ft_snips[item.trigger] = item.desc
end
vim.print(ft_snips)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

list_snips() crashes when no snippets exist for the current filetype

luasnip.available()[vim.o.filetype] can be nil; calling pairs() on nil raises an error.

-  local ft_list = luasnip.available()[vim.o.filetype]
+  local ft_list = luasnip.available()[vim.o.filetype] or {}

Add a short guard to keep the command safe in empty buffers.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
local function list_snips()
local ft_list = luasnip.available()[vim.o.filetype]
local ft_snips = {}
for _, item in pairs(ft_list) do
ft_snips[item.trigger] = item.desc
end
vim.print(ft_snips)
local function list_snips()
local ft_list = luasnip.available()[vim.o.filetype] or {}
local ft_snips = {}
for _, item in pairs(ft_list) do
ft_snips[item.trigger] = item.desc
end
vim.print(ft_snips)
🤖 Prompt for AI Agents
In plugins/nobbz/lua/nobbz/luasnip.lua around lines 18 to 24, the function
list_snips() crashes because it calls pairs() on nil when no snippets exist for
the current filetype. To fix this, add a guard clause that checks if ft_list is
nil before the for loop, and if so, return early or set ft_list to an empty
table to prevent the error.

Comment on lines +12 to +15
local function script_path(suffix)
local path = debug.getinfo(2, "S").source:sub(2):match("(.*/)")
if suffix then return path .. suffix end
return path
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

script_path() uses the wrong stack-level and breaks when invoked indirectly

debug.getinfo(2, 'S') resolves to the caller of script_path, which is fine for the one internal call in this file, but it fails if the helper is reused from another module (it will then resolve the foreign caller’s path).
Using level 1 (the current function) is safer and matches the usual pattern.

-local function script_path(suffix)
-  local path = debug.getinfo(2, "S").source:sub(2):match("(.*/)")
+local function script_path(suffix)
+  local path = debug.getinfo(1, "S").source:sub(2):match("(.*/)")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
local function script_path(suffix)
local path = debug.getinfo(2, "S").source:sub(2):match("(.*/)")
if suffix then return path .. suffix end
return path
local function script_path(suffix)
local path = debug.getinfo(1, "S").source:sub(2):match("(.*/)")
if suffix then return path .. suffix end
return path
🤖 Prompt for AI Agents
In plugins/nobbz/lua/nobbz/luasnip.lua around lines 12 to 15, the script_path
function uses debug.getinfo with stack level 2, which points to the caller of
script_path and causes incorrect path resolution when called indirectly. Change
the stack level argument from 2 to 1 in debug.getinfo to refer to the current
function itself, ensuring the path is always correctly resolved regardless of
the caller.

Comment on lines +3 to +6
return {
s({ trig = "sc", desc = "short-cut ticket", },
{ t("[SC-"), i(1), t("]"), i(2), }),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Undefined identifiers s, t, i – snippet file will error at load time

luasnip does not expose these globals by default.
Declare them locally:

-return {
-  s({ trig = "sc", desc = "short-cut ticket", },
-    { t("[SC-"), i(1), t("]"), i(2), }),
-}
+local ls = require("luasnip")
+local s, t, i = ls.snippet, ls.text_node, ls.insert_node
+
+return {
+  s({ trig = "sc", desc = "short-cut ticket" }, {
+    t("[SC-"), i(1), t("] "), i(2),
+  }),
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return {
s({ trig = "sc", desc = "short-cut ticket", },
{ t("[SC-"), i(1), t("]"), i(2), }),
}
local ls = require("luasnip")
local s, t, i = ls.snippet, ls.text_node, ls.insert_node
return {
s({ trig = "sc", desc = "short-cut ticket" }, {
t("[SC-"), i(1), t("] "), i(2),
}),
}
🤖 Prompt for AI Agents
In plugins/nobbz/lua/nobbz/luasnip/gitcommit.lua around lines 3 to 6, the
identifiers s, t, and i are used without being declared, causing errors at load
time. Fix this by locally requiring or importing these functions from the
luasnip module at the top of the file before their usage, ensuring they are
properly defined and available in the snippet file.

@NobbZ NobbZ merged commit bc98891 into main Jun 13, 2025
3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jul 19, 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