-
Notifications
You must be signed in to change notification settings - Fork 4
gleam snippet for externals #71
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
## Walkthrough
This update changes the keybinding for snippet expansion and restricts its active modes, adjusts the tabstop navigation in a git commit snippet, introduces a new Gleam language snippet for external function declarations, adds new Elixir and Lua snippet modules, and enhances snippet expansion and jump logic integration within the blink plugin.
## Changes
| File(s) | Change Summary |
|------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| plugins/nobbz/lua/nobbz/luasnip.lua | Changed snippet expand keybinding from Ctrl+k to Ctrl+e; restricted keybinding to insert and select modes; added Ctrl+j and Ctrl+Shift+j for choice cycling and selection. |
| plugins/nobbz/lua/nobbz/luasnip/gitcommit.lua | Modified snippet to use `i(0)` instead of `i(2)` for the final insert node, altering tabstop flow. |
| plugins/nobbz/lua/nobbz/luasnip/gleam.lua | Added a new snippet for Gleam: "external" function declaration with interactive parameters and choices. |
| plugins/nobbz/lua/nobbz/luasnip/elixir.lua | Added new Elixir snippet module with three snippets for public/private function definitions and debug pipe operator. |
| plugins/nobbz/lua/nobbz/luasnip/lua.lua | Added new Lua snippet module with three snippets for standalone functions, module functions, and module templates. |
| plugins/nobbz/lua/nobbz/blink.lua | Added `is_hidden_snippet()` helper; extended blink snippet setup with `expand` and `jump` functions integrating luasnip expansion and jump logic. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant User
participant LuasnipPlugin
participant GleamSnippet
participant ElixirSnippet
participant LuaSnippet
participant BlinkPlugin
User->>LuasnipPlugin: Presses Ctrl+e in insert/select mode
LuasnipPlugin->>LuasnipPlugin: Expand snippet
User->>LuasnipPlugin: Types "external" in Gleam file
LuasnipPlugin->>GleamSnippet: Trigger "external" snippet
GleamSnippet-->>User: Insert external function template with choices and placeholders
User->>LuasnipPlugin: Types Elixir snippet triggers ("def:", "defp:", ">d")
LuasnipPlugin->>ElixirSnippet: Trigger Elixir snippets
ElixirSnippet-->>User: Insert Elixir function or debug pipe snippet
User->>LuasnipPlugin: Types Lua snippet triggers ("fn", "fnM", "mod")
LuasnipPlugin->>LuaSnippet: Trigger Lua snippets
LuaSnippet-->>User: Insert Lua function or module snippet
User->>BlinkPlugin: Request snippet expand or jump
BlinkPlugin->>LuasnipPlugin: Call expand or jump based on snippet and completion statePossibly related PRs
Poem
|
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.
Pull Request Overview
This PR adds a new Gleam snippet for externals, updates the Git commit snippet to position the cursor at the end, and remaps the snippet expansion keybinding to Ctrl+e in insert/select modes.
- Introduce
externalsnippet in Gleam with language, module, function, args, and return placeholders - Change Git commit snippet’s final tabstop to 0 for end-of-line cursor placement
- Update snippet expansion hotkey to
<C-e>limited to insert and select modes
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| plugins/nobbz/lua/nobbz/luasnip/gleam.lua | New external snippet definition for Gleam |
| plugins/nobbz/lua/nobbz/luasnip/gitcommit.lua | Adjusted Git‐commit snippet final placeholder |
| plugins/nobbz/lua/nobbz/luasnip.lua | Remapped expand key to <C-e> with mode options |
Comments suppressed due to low confidence (3)
plugins/nobbz/lua/nobbz/luasnip/gleam.lua:9
- [nitpick] The placeholder label "function" may be confused with the reserved keyword. Rename it to "function_name" or similar for clarity.
i(3, "function"),
plugins/nobbz/lua/nobbz/luasnip/gleam.lua:1
- Consider adding unit tests or snippet validation to ensure the
externalsnippet expands correctly across the supported languages and argument scenarios.
return {
plugins/nobbz/lua/nobbz/luasnip/gitcommit.lua:5
- Please update the plugin's README or changelog to document that the final cursor position is now handled by a 0 tabstop in this snippet.
{ t("[SC-"), i(1), t("]"), i(0), }),
plugins/nobbz/lua/nobbz/luasnip.lua
Outdated
|
|
||
| WK.add({ | ||
| { "<C-k>", luasnip.expand, desc = "expand snippet", }, | ||
| { "<C-e>", luasnip.expand, desc = "expand snippet", mode = { "i", "s", }, }, |
Copilot
AI
Jun 18, 2025
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.
[nitpick] The trailing comma in the mode table is valid Lua but may not align with the project's style guide—consider removing it if unnecessary.
| { "<C-e>", luasnip.expand, desc = "expand snippet", mode = { "i", "s", }, }, | |
| { "<C-e>", luasnip.expand, desc = "expand snippet", mode = { "i", "s" }, }, |
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 (1)
plugins/nobbz/lua/nobbz/blink.lua (1)
6-9: Optimize module usage - avoid redundant require.The function re-requires
luasnipon line 7 even though it's already available as theluasnipvariable from line 2. This is inefficient and unnecessary.Apply this diff to use the existing module reference:
local function is_hidden_snippet() - local ls = require("luasnip") - return not require("blink.cmp").is_visible() and not ls.in_snippet() and ls.expandable() + return not require("blink.cmp").is_visible() and not luasnip.in_snippet() and luasnip.expandable() end
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
plugins/nobbz/lua/nobbz/blink.lua(2 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.lazylocalhas to be used- coding follows the luarocks styleguide, but with 2 spaces indentation
plugins/nobbz/lua/nobbz/blink.lua
🔇 Additional comments (2)
plugins/nobbz/lua/nobbz/blink.lua (2)
22-22: LGTM: Clean snippet expansion implementation.The expand function correctly delegates to
luasnip.lsp_expandfor snippet expansion.
23-26: LGTM: Well-structured conditional jump logic.The jump function implements sound logic:
- Uses the helper function to determine when to expand or jump
- Falls back to directional jumping when appropriate
- Properly handles the return value from
luasnip.jumpable()The integration with the blink completion plugin state through
is_hidden_snippet()is well thought out.
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: 2
🧹 Nitpick comments (1)
plugins/nobbz/lua/nobbz/luasnip/elixir.lua (1)
6-7: Remove unnecessaryfmtusage for static strings.The
fmtfunction is not needed when there are no placeholders to format.s({ trig = ">d", name = "pipe debug", desc = "pipe into debug", }, - fmt("|> dbg()")), + t("|> dbg()")),Note: You'll also need to import
t(text node) with the other imports:local ls = require("luasnip") local s = ls.snippet local i = ls.insert_node +local t = ls.text_node local fmt = require("luasnip.extras.fmt").fmt
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
plugins/nobbz/lua/nobbz/luasnip.lua(1 hunks)plugins/nobbz/lua/nobbz/luasnip/elixir.lua(1 hunks)plugins/nobbz/lua/nobbz/luasnip/lua.lua(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- plugins/nobbz/lua/nobbz/luasnip.lua
🧰 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.lazylocalhas to be used- coding follows the luarocks styleguide, but with 2 spaces indentation
plugins/nobbz/lua/nobbz/luasnip/lua.luaplugins/nobbz/lua/nobbz/luasnip/elixir.lua
🔇 Additional comments (2)
plugins/nobbz/lua/nobbz/luasnip/lua.lua (1)
17-23: Well-structured snippet definitions.The snippet definitions follow good practices with descriptive triggers, names, and descriptions. The template formatting and placeholder usage look correct for LuaSnip.
plugins/nobbz/lua/nobbz/luasnip/elixir.lua (1)
2-5: Well-crafted Elixir function snippets.The snippet definitions for
def:anddefp:are well-structured with appropriate placeholders for function names, arguments, and bodies. The triggers are intuitive for Elixir developers.
| local fun_string = [[function {}({}) | ||
| {} | ||
| end]] | ||
|
|
||
| local module_string = [[local M = {{}} | ||
|
|
||
| function M.{}({}) | ||
| {} | ||
| end | ||
|
|
||
| return M]] | ||
|
|
||
| local module_fun_string = [[function M.{}({}) | ||
| {} | ||
| end]] | ||
|
|
||
| return { | ||
| s({ trig = "fn", name = "function", desc = "function definition", }, fmt(fun_string, { i(1, "name"), i(2), i(0), })), | ||
| s({ trig = "fnM", name = "module function", desc = "function definition in module", }, | ||
| fmt(module_fun_string, { i(1, "name"), i(2), i(0), })), | ||
| s({ trig = "mod", name = "module", desc = "module definition", }, | ||
| fmt(module_string, { i(1, "name"), i(2, "func"), i(3), i(0), })), | ||
| } |
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.
Add missing imports for LuaSnip functions.
The code uses s, fmt, and i functions but doesn't import them. These appear to be LuaSnip functions that need to be imported at the top of the file.
Add the missing imports at the beginning of the file:
+local ls = require("luasnip")
+local s = ls.snippet
+local i = ls.insert_node
+local fmt = require("luasnip.extras.fmt").fmt
+
local fun_string = [[function {}({})
{}
end]]📝 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.
| local fun_string = [[function {}({}) | |
| {} | |
| end]] | |
| local module_string = [[local M = {{}} | |
| function M.{}({}) | |
| {} | |
| end | |
| return M]] | |
| local module_fun_string = [[function M.{}({}) | |
| {} | |
| end]] | |
| return { | |
| s({ trig = "fn", name = "function", desc = "function definition", }, fmt(fun_string, { i(1, "name"), i(2), i(0), })), | |
| s({ trig = "fnM", name = "module function", desc = "function definition in module", }, | |
| fmt(module_fun_string, { i(1, "name"), i(2), i(0), })), | |
| s({ trig = "mod", name = "module", desc = "module definition", }, | |
| fmt(module_string, { i(1, "name"), i(2, "func"), i(3), i(0), })), | |
| } | |
| local ls = require("luasnip") | |
| local s = ls.snippet | |
| local i = ls.insert_node | |
| local fmt = require("luasnip.extras.fmt").fmt | |
| local fun_string = [[function {}({}) | |
| {} | |
| end]] | |
| local module_string = [[local M = {{}} | |
| function M.{} ({}) | |
| {} | |
| end | |
| return M]] | |
| local module_fun_string = [[function M.{}({}) | |
| {} | |
| end]] | |
| return { | |
| s({ trig = "fn", name = "function", desc = "function definition" }, fmt(fun_string, { i(1, "name"), i(2), i(0) })), | |
| s({ trig = "fnM", name = "module function", desc = "function definition in module" }, fmt(module_fun_string, { i(1, "name"), i(2), i(0) })), | |
| s({ trig = "mod", name = "module", desc = "module definition" }, fmt(module_string, { i(1, "name"), i(2, "func"), i(3), i(0) })), | |
| } |
🤖 Prompt for AI Agents
In plugins/nobbz/lua/nobbz/luasnip/lua.lua lines 1 to 23, the LuaSnip functions
s, fmt, and i are used but not imported. Add the required local imports for
these functions at the top of the file by requiring them from the LuaSnip module
to ensure they are defined before use.
| return { | ||
| s({ trig = "def:", name = "def oneliner", desc = "one line function definition", }, | ||
| fmt("def {}({}), do: {}", { i(1, "name"), i(2, "args"), i(0, "body"), })), | ||
| s({ trig = "defp:", name = "defp oneliner", desc = "one line private function definition", }, | ||
| fmt("defp {}({}), do: {}", { i(1, "name"), i(2, "args"), i(0, "body"), })), | ||
| s({ trig = ">d", name = "pipe debug", desc = "pipe into debug", }, | ||
| fmt("|> dbg()")), | ||
| } |
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.
Add missing imports for LuaSnip functions.
The code uses s, fmt, and i functions but doesn't import them. These are LuaSnip functions that need to be imported.
Add the missing imports at the beginning of the file:
+local ls = require("luasnip")
+local s = ls.snippet
+local i = ls.insert_node
+local fmt = require("luasnip.extras.fmt").fmt
+
return {📝 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.
| return { | |
| s({ trig = "def:", name = "def oneliner", desc = "one line function definition", }, | |
| fmt("def {}({}), do: {}", { i(1, "name"), i(2, "args"), i(0, "body"), })), | |
| s({ trig = "defp:", name = "defp oneliner", desc = "one line private function definition", }, | |
| fmt("defp {}({}), do: {}", { i(1, "name"), i(2, "args"), i(0, "body"), })), | |
| s({ trig = ">d", name = "pipe debug", desc = "pipe into debug", }, | |
| fmt("|> dbg()")), | |
| } | |
| local ls = require("luasnip") | |
| local s = ls.snippet | |
| local i = ls.insert_node | |
| local fmt = require("luasnip.extras.fmt").fmt | |
| return { | |
| s({ trig = "def:", name = "def oneliner", desc = "one line function definition", }, | |
| fmt("def {}({}), do: {}", { i(1, "name"), i(2, "args"), i(0, "body"), })), | |
| s({ trig = "defp:", name = "defp oneliner", desc = "one line private function definition", }, | |
| fmt("defp {}({}), do: {}", { i(1, "name"), i(2, "args"), i(0, "body"), })), | |
| s({ trig = ">d", name = "pipe debug", desc = "pipe into debug", }, | |
| fmt("|> dbg()")), | |
| } |
🤖 Prompt for AI Agents
In plugins/nobbz/lua/nobbz/luasnip/elixir.lua at lines 1 to 8, the functions s,
fmt, and i from LuaSnip are used but not imported. To fix this, add the required
local imports for these functions at the top of the file by requiring them from
the LuaSnip module, ensuring s, fmt, and i are properly defined before usage.
Summary by CodeRabbit
New Features
Improvements