Skip to content

Commit be5f6e0

Browse files
builtins/nvim-snippets: don't rely on global snippet list (#223)
1 parent 40dc2e9 commit be5f6e0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ local function nvim_snippet_exists()
1313
return status
1414
end
1515

16-
local function get_loaded_snippets()
17-
return require("snippets").get_loaded_snippets()
16+
local function get_loaded_snippets(filetype)
17+
return require("snippets").load_snippets_for_ft(filetype)
1818
end
1919

2020
return h.make_builtin({
2121
name = "nvim_snippets",
2222
can_run = nvim_snippet_exists,
2323
condition = nvim_snippet_exists,
24-
runtime_condition = h.cache.by_bufnr(function()
25-
return not vim.tbl_isempty(get_loaded_snippets())
24+
--- @param params NullLsParams
25+
runtime_condition = h.cache.by_bufnr(function(params)
26+
return not vim.tbl_isempty(get_loaded_snippets(params.filetype))
2627
end),
2728
meta = {
2829
url = "https://github.com/garymjr/nvim-snippets",
@@ -43,7 +44,7 @@ return h.make_builtin({
4344
end
4445

4546
local items = {}
46-
local snippets = get_loaded_snippets()
47+
local snippets = get_loaded_snippets(params.filetype)
4748
for _, item in pairs(snippets) do
4849
if vim.startswith(item.prefix, line_to_cursor:sub(start_col)) then
4950
local insertText = (type(item.body) == "table") and table.concat(item.body, "\n") or item.body

0 commit comments

Comments
 (0)