Skip to content

Conversation

@NobbZ
Copy link
Owner

@NobbZ NobbZ commented May 31, 2025

Summary by CodeRabbit

  • Refactor
    • Improved the configuration logic for snippet handling within the Blink plugin to enhance compatibility with snippet usage and popup visibility. No changes to visible features or exported settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 31, 2025

Walkthrough

The configuration for the blink.cmp plugin was refactored to require its dependencies explicitly and replace the simple snippet preset with a dynamic function that determines snippet activation based on the current LuaSnip state and blink popup visibility. No public APIs were changed; only internal setup logic was updated.

Changes

File(s) Change Summary
plugins/nobbz/lua/nobbz/blink.lua Refactored blink.cmp setup: explicit requires, replaced preset with dynamic snippets.active function, commented out old preset line.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant blink.cmp
    participant luasnip

    User->>blink.cmp: Trigger completion
    blink.cmp->>luasnip: Check if inside snippet
    alt Inside snippet and blink popup not visible
        blink.cmp-->>User: Activate snippet completion
    else Not inside snippet and in normal mode
        blink.cmp->>luasnip: Unlink current snippet
        blink.cmp-->>User: Snippet completion inactive
    end
Loading

Possibly related PRs

  • remove cmp-mode as default #33: Modifies blink.cmp configuration in the same file, focusing on snippet and appearance setup.
  • disable blink for cmdline #42: Alters blink.cmp setup to add an option for disabling blink in the command line, related to configuration logic.
  • do some blink #31: Changes snippet configuration in blink.cmp from a preset to a static approach, closely related to snippet activation logic.

Poem

In the code where snippets blink and play,
A rabbit hops to tweak the way—
Now functions check if snippets hide,
Or if a popup’s open wide.
With LuaSnip and blink in sync,
The setup’s smarter than you think!
🐇✨

✨ 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

🔭 Outside diff range comments (1)
plugins/nobbz/lua/nobbz/blink.lua (1)

6-69: 💡 Verification agent

🧩 Analysis chain

Implement lazy loading as required by coding guidelines.

The configuration doesn't follow the lazy loading requirement specified in the coding guidelines. All plugins should be lazy loaded through nobbz.lazy.

Please verify how other plugin configurations in the project implement lazy loading and apply the same pattern here:


🏁 Script executed:

#!/bin/bash
# Description: Find examples of nobbz.lazy usage in other plugin files
# Expected: Examples of lazy loading patterns to follow

fd -e lua . plugins/ --exec grep -l "nobbz.lazy" {} \;

Length of output: 519


🏁 Script executed:

#!/bin/bash
# Inspect the nobbz.lazy pattern in init.lua
sed -n '1,200p' plugins/nobbz/lua/nobbz/lazy/init.lua

Length of output: 1513


#!/bin/bash
# Locate the add_specs call in the lazy specs file
grep -R "add_specs" -n plugins/nobbz/lua/nobbz/lazy/specs.lua

🏁 Script executed:

#!/bin/bash
# Check for existing blink.nvim entry in lazy specs
grep -R "blink.nvim" -n plugins/nobbz/lua/nobbz/lazy/specs.lua || echo "No blink.nvim spec found"

Length of output: 121


Add Blink plugin to lazy-loading specs

Blink is currently configured eagerly via a direct blink.setup() call. Per project guidelines, all plugins must be loaded through nobbz.lazy. Please:

  • Refactor plugins/nobbz/lua/nobbz/blink.lua so it returns a setup() function instead of invoking require("blink").setup() at load time.

  • In plugins/nobbz/lua/nobbz/lazy/specs.lua, register Blink with require("nobbz.lazy").add_specs({ … }), mirroring patterns in other specs. For example:

    require("nobbz.lazy").add_specs({
      {
        "plugin-author/blink.nvim",
        event        = "InsertEnter",
        dependencies = { "L3MON4D3/LuaSnip" },
        config       = function()
          require("nobbz.blink").setup({
            -- your existing options
          })
        end,
      },
    })
🧹 Nitpick comments (1)
plugins/nobbz/lua/nobbz/blink.lua (1)

7-17: Snippet configuration logic looks sound but could be simplified.

The custom active function addresses the LuaSnip interaction issue mentioned in the PR title. The logic correctly manages snippet state based on popup visibility and current mode.

Consider simplifying the logic:

  active = function()
-   if luasnip.in_snippet() and not blink.is_visible() then
-     return true
-   else
-     if not luasnip.in_snippet() and vim.fn.mode() == "n" then luasnip.unlink_current() end
-     return false
-   end
+   local in_snippet = luasnip.in_snippet()
+   if not in_snippet and vim.fn.mode() == "n" then
+     luasnip.unlink_current()
+   end
+   return in_snippet and not blink.is_visible()
  end,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 104fb5d and 39cb1d6.

📒 Files selected for processing (1)
  • plugins/nobbz/lua/nobbz/blink.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
🔇 Additional comments (1)
plugins/nobbz/lua/nobbz/blink.lua (1)

1-2: LGTM! Good practice to explicitly require dependencies.

The explicit requires improve code clarity and follow the local declaration guideline properly.

@NobbZ NobbZ requested a review from Copilot May 31, 2025 10:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the configuration logic for snippet handling in the Blink plugin to enhance compatibility with snippet usage and popup visibility.

  • Refactored snippet configuration by introducing an "active" function to control snippet behavior
  • Adjusted logic to unlink snippets in normal mode when not in an active snippet session

Comment on lines +10 to +13
if luasnip.in_snippet() and not blink.is_visible() then
return true
else
if not luasnip.in_snippet() and vim.fn.mode() == "n" then luasnip.unlink_current() end
Copy link

Copilot AI May 31, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider caching the result of 'luasnip.in_snippet()' at the start of the active function to avoid duplicate function calls and improve clarity. For example, assign its value to a local variable and reuse it in subsequent checks.

Suggested change
if luasnip.in_snippet() and not blink.is_visible() then
return true
else
if not luasnip.in_snippet() and vim.fn.mode() == "n" then luasnip.unlink_current() end
local in_snippet = luasnip.in_snippet()
if in_snippet and not blink.is_visible() then
return true
else
if not in_snippet and vim.fn.mode() == "n" then luasnip.unlink_current() end

Copilot uses AI. Check for mistakes.
@NobbZ NobbZ merged commit a223030 into main May 31, 2025
3 checks passed
This was referenced Jun 13, 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