fix(org): +jupyter: syntax highlighting for remapped modes

Particularly treesit ts-modes.
This commit is contained in:
Henrik Lissner
2025-09-16 11:41:05 -04:00
parent 395a807aae
commit 7b35a31322

View File

@@ -5,6 +5,23 @@
(use-package! jupyter-repl
:defer t
:config
;; HACK: Don't use treesit ts-modes for syntax highlighting (is brittle).
(defadvice! +org-jupyter--suppress-major-mode-remapping-a (fn &rest args)
:around #'jupyter-kernel-language-mode-properties
(let (major-mode-remap-alist major-mode-remap-defaults)
(apply fn args)))
;; HACK: And un-remap the major mode when associating a repl with the current
;; buffer, otherwise it will fail with any treesit-enabled (or otherwise
;; remapped) modes.
(defadvice! +org-jupyter--unremap-major-mode-when-associating-buffer-a (fn &rest args)
:around #'jupyter-repl-associate-buffer
(let ((major-mode
(or (car (rassq major-mode (append major-mode-remap-alist
major-mode-remap-defaults)))
major-mode)))
(apply fn args)))
;; HACK: If the user is anywhere but the last prompt, typing should move them
;; there instead of unhelpfully spewing read-only errors at them.
;; REVIEW: Upstream this (maybe?)