From c3014b514ccb8f1975828b8f5a009ef93f9b4ced Mon Sep 17 00:00:00 2001 From: Manuel Transfeld Date: Tue, 14 Apr 2026 02:21:32 +0200 Subject: [PATCH] handle nil values --- plugin/hmts.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/hmts.lua b/plugin/hmts.lua index 8514070..d3f7d71 100644 --- a/plugin/hmts.lua +++ b/plugin/hmts.lua @@ -124,7 +124,10 @@ end ---@param predicate string[] ---@return boolean local function hmts_path_handler(match, _, bufnr, predicate) - local node = match[predicate[2]]:parent() + local captured = match[predicate[2]] + if type(captured) == "table" then captured = captured[1] end + if not captured then return false end + local node = captured:parent() local target_path = vim.list_slice(predicate, 3, nil) while node do @@ -153,6 +156,8 @@ end ---@param metadata table local function hmts_inject_handler(match, _, bufnr, predicate, metadata) local path_node = match[predicate[2]] + if type(path_node) == "table" then path_node = path_node[1] end + if not path_node then return end local filename = find_filename_in_parent_node(path_node, bufnr) local alias = vim.filetype.match({ filename = filename })