Skip to content

Commit c4f048b

Browse files
committed
fix: set keyword-based trigger as default
1 parent 318ab24 commit c4f048b

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

lua/snippy/main.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ local function get_snippet_at_cursor(auto_trigger)
167167
end
168168

169169
local word = current_line_to_col:match('(%S*)$') -- Remove leading whitespace
170-
local kword = fn.matchstr(word, '\\k\\+$')
171170
local word_bound = true
172171
local scopes = shared.get_scopes()
173172
while #word > 0 do
@@ -194,10 +193,6 @@ local function get_snippet_at_cursor(auto_trigger)
194193
if word == current_line_to_col then
195194
return word, snippet
196195
end
197-
elseif snippet.option.word then
198-
if word == kword then
199-
return word, snippet
200-
end
201196
else
202197
if word_bound then
203198
-- By default only match on word boundary
@@ -209,8 +204,8 @@ local function get_snippet_at_cursor(auto_trigger)
209204
end
210205
end
211206
end
212-
word = word:sub(2)
213-
word_bound = false
207+
word_bound = fn.match(word, '^\\k') == -1
208+
word = fn.strcharpart(word, 1)
214209
end
215210
end
216211
return nil, nil

test/functional/snippy_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ describe('Snippy', function()
835835
feed('<plug>(snippy-expand)')
836836
screen:expect({
837837
grid = [[
838-
foo Expand only if space-delimited word present!^ |
838+
foo Expand if keyword-delimited word present!^ |
839839
{1:~ }|
840840
{1:~ }|
841841
{1:~ }|
@@ -849,7 +849,7 @@ describe('Snippy', function()
849849
feed('<plug>(snippy-expand)')
850850
screen:expect({
851851
grid = [[
852-
@@@default^ |
852+
@@@Expand if keyword-delimited word present!^ |
853853
{1:~ }|
854854
{1:~ }|
855855
{1:~ }|

test/snippets/python.snippets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ snippet word "Test word" w
77
snippet comment "Test custome expand (comment)" c
88
Expand this if on a commented line!
99
snippet default "Test default"
10-
Expand only if space-delimited word present!
10+
Expand if keyword-delimited word present!

0 commit comments

Comments
 (0)