Skip to content

Commit 487bc70

Browse files
fix(nvim_snippets): cannot expand snippet on indented line (#240)
1 parent eec6019 commit 487bc70

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lua/null-ls/builtins/completion/nvim_snippets.lua

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ local methods = require("null-ls.methods")
44
local COMPLETION = methods.internal.COMPLETION
55

66
-- based on pattern from cmp-luasnip
7-
local pattern = "\\%([^[:alnum:][:blank:]]\\+\\|\\w\\+\\)"
8-
local regex = vim.regex([[\%(]] .. pattern .. [[\)\m$]])
7+
local regex = vim.regex([===[\%(\%([^[:alnum:][:blank:]]\+\|\w\+\)\)\m$]===])
98

109
local function nvim_snippet_exists()
1110
local status, _ = pcall(require, "snippets")
@@ -43,10 +42,12 @@ return h.make_builtin({
4342
return
4443
end
4544

45+
local prefix = vim.trim(line_to_cursor:sub(start_col))
4646
local items = {}
4747
local snippets = get_loaded_snippets(params.filetype)
48+
4849
for _, item in pairs(snippets) do
49-
if vim.startswith(item.prefix, line_to_cursor:sub(start_col)) then
50+
if vim.startswith(item.prefix, prefix) then
5051
local insertText = (type(item.body) == "table") and table.concat(item.body, "\n") or item.body
5152
local textEdit = {
5253
range = {

0 commit comments

Comments
 (0)