Open yogan opened 6 months ago
Hey! What exactly is going on in Haskell files? I couldn't really reproduce any weird behaviour with this file:
I was moving the cursor around and didn't notice anything weird.
Maybe it's an issue with your config? Could you try a minimal config to reproduce the issue?
It does not seem to happen for all files, but I found one that cause me trouble:
module DNA (nucleotideCounts, Nucleotide (..)) where
import Data.List (group, sort)
import Data.Map (Map)
import qualified Data.Map as Map
data Nucleotide = A | C | G | T deriving (Eq, Ord, Show)
nucleotideCounts :: String -> Either String (Map Nucleotide Int)
nucleotideCounts dna = case counts of
Just xs -> Right $ Map.fromList xs
Nothing -> Left $ "invalid DNA strand" ++ dna
where
counts = mapM count $ group $ sort dna
count :: String -> Maybe (Nucleotide, Int)
count xs = case xs of
[] -> Nothing
x : _ -> case x of
'A' -> Just (A, length xs)
'C' -> Just (C, length xs)
'G' -> Just (G, length xs)
'T' -> Just (T, length xs)
_ -> Nothing
Error 08:06:29 AM msg_show.lua_error Error detected while processing CursorHold Autocommands for "<buffer=1>":
08:06:29 AM msg_show Error executing lua callback: ...-commentstring/lua/ts_context_commentstring/internal.lua:126: attempt to index local 'match' (a function value)
stack traceback:
...-commentstring/lua/ts_context_commentstring/internal.lua:126: in function 'calculate_commentstring'
...-commentstring/lua/ts_context_commentstring/internal.lua:86: in function 'update_commentstring'
...-commentstring/lua/ts_context_commentstring/internal.lua:33: in function <...-commentstring/lua/ts_context_commentstring/internal.lua:32>
I'll try to recreate with a minimal config…
I tried to use the minimal config from here: https://github.com/JoosepAlviste/nvim-ts-context-commentstring/blob/main/utils/minimal_init.lua
~But this does not seem to load ts-context-commentstring
, only treesitter.~
Update: works just fine.
Indeed there are no issues with this minimal config, even with the problematic source file I posted in the comment above. I'll try to dig deeper where the issues are coming from…
I've just encountered this in a Markdown document too:
Debug print:
commentstring_key "__default" language_config "<!-- %s -->" node_type "comment" match nil
commentstring_key "__default" language_config "<!-- %s -->" node_type "document" match nil
Edit: And now in a Lua file.
This is obviously just a hack, but without it, the autocommand is going haywire when moving around in Haskell files, making it impossible to work.
I could not find out where the function is for char nodes is coming from. Any hints / help for a proper fix are welcome.