emacs-tree-sitter / elisp-tree-sitter

Emacs Lisp bindings for tree-sitter
https://emacs-tree-sitter.github.io
MIT License
827 stars 74 forks source link

Conflict between hideshow and tree-sitter #234

Closed mattiasdrp closed 2 years ago

mattiasdrp commented 2 years ago

Whenever I M-x tree-sitter-query-builder I have the following error:

hs-grok-mode-type: tsc-query-builder Mode doesn’t support Hideshow Minor Mode

I tried adding a hook:

(use-package tree-sitter-mode
  :hook
  (tuareg-mode . tree-sitter-mode)
  (tree-sitter-mode . (lambda () (hs-minor-mode -1)))
  )

But the error remains

ntBre commented 2 years ago

I was having this issue too, and then I found in my config that I had hs-minor-mode in my prog-mode-hook. If you check major-mode in the tree-sitter-query-builder buffer, you'll see that it's actually tree-sitter-query-mode, so you need to disable hs-minor-mode in that, not in tree-sitter-mode proper. However, I also tried adding a hook to tree-sitter-query-mode to turn it off, and it's already too late, so you will have to disable hideshow before running tree-sitter-query-builder.

I also couldn't find the source of this error in the tree-sitter code, so I checked hideshow.el, and that is where the issue originates, not in this package.

mattiasdrp commented 2 years ago

Sorry for the delay! Thanks, that actually fixed my issue :-)

snowman commented 1 year ago

I also couldn't find the source of this error in the tree-sitter code, so I checked hideshow.el, and that is where the issue originates, not in this package.

what the issues hideshow package has? This should be fixed in upstream.

currently workaround:

(use-package hideshow
  :hook (prog-mode . (lambda ()
                       (unless (eq major-mode 'tree-sitter-query-mode)
                         (hs-minor-mode)))))
ntBre commented 1 year ago

For some reason hs-grok-mode-type throws an error after determining that the mode doesn't support hideshow mode. I didn't originally think of this as an actual issue in hideshow, just an incompatibility. But looking at it again, it doesn't really make sense why they signal an error instead of just disabling hideshow (as they already do) and printing a warning or something. I'm not really using either of these packages anymore, but that should give you somewhere to start if you want to report/fix this upstream.

I think hideshow is part of emacs itself, so this is probably a time for M-x report-emacs-bug.