Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore Haskell char node function match #97

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion lua/ts_context_commentstring/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ function M.check_node(node, language_config, commentstring_key)
local node_type = node:type()
local match = language_config[node_type]

if match then
-- print('language_config', vim.inspect(language_config), 'node_type', node_type, 'match', vim.inspect(match))
-- For Haskell, the debug print above shows values like:
-- language_config "-- %s" node_type haskell match nil
-- language_config "-- %s" node_type pat_literal match nil
-- language_config "-- %s" node_type char match <function 1>
-- I'm clueless why we get a function for 'char" nodes.
-- Ignoring seems to work, but actually we should find out what is going on
-- and fix that.
if match and type(match) ~= 'function' then
Copy link

Choose a reason for hiding this comment

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

suggestion: I think checking for table would be more reliable and concise.

Suggested change
if match and type(match) ~= 'function' then
if type(match) == 'table' then

return match[commentstring_key] or match.__default or match
end

Expand Down