Skip to content

Commit 14b801f

Browse files
authored
Merge pull request #597 from weilbith/feature/condition-line-end
feat: add new built-in condition for line ending
2 parents 4b1a284 + 7117f5e commit 14b801f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Examples/snippets.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ ls.add_snippets("all", {
326326
}, {
327327
condition = conds.line_begin,
328328
}),
329+
s("cond3", {
330+
t("will only expand at the end of the line"),
331+
}, {
332+
condition = conds.line_end,
333+
}),
329334
-- The last entry of args passed to the user-function is the surrounding snippet.
330335
s(
331336
{ trig = "a%d", regTrig = true },

lua/luasnip/extras/expand_conditions.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ function M.line_begin(line_to_cursor, matched_trigger)
55
return line_to_cursor:sub(1, -(#matched_trigger + 1)):match("^%s*$")
66
end
77

8+
function M.line_end(line_to_cursor)
9+
local line = vim.api.nvim_get_current_line()
10+
return #line_to_cursor == #line
11+
end
12+
813
return M

0 commit comments

Comments
 (0)