Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugin/hmts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ end
local function hmts_inject_handler(match, _, bufnr, predicate, metadata)
local path_node = match[predicate[2]]
local filename = find_filename_in_parent_node(path_node, bufnr)
if filename == nil then
return
end
Comment on lines +157 to +159

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better conciseness and to follow Lua idioms, you can use a one-line guard clause. In Lua, nil is falsy, so you can check for it with if not filename then ... end.

	if not filename then return end

local alias = vim.filetype.match({ filename = filename })

if alias == nil then
Expand Down