branch: elpa/idris-mode
commit 3df09338a28041387529f9e700ec97b26246c5de
Author: Marek L <[email protected]>
Commit: Marek L <[email protected]>

    Use Idris2 `:enable-syntax` option to switch syntax highligting
    
    of files in emacs.
    
    Why:
    Improved performance.
---
 idris-commands.el        |  3 ++-
 idris-highlight-input.el | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/idris-commands.el b/idris-commands.el
index 417c827880..d4860c577b 100644
--- a/idris-commands.el
+++ b/idris-commands.el
@@ -1003,7 +1003,8 @@ https://github.com/clojure-emacs/cider";
         idris-rex-continuations '()
         idris-process-current-working-directory nil
         idris-protocol-version 0
-        idris-protocol-version-minor 0))
+        idris-protocol-version-minor 0
+        idris--semantic-source-highlighting t))
 
 (defun idris-delete-ibc (no-confirmation)
   "Delete the IBC file for the current buffer.
diff --git a/idris-highlight-input.el b/idris-highlight-input.el
index 78ebd2398e..9d1471d7b5 100644
--- a/idris-highlight-input.el
+++ b/idris-highlight-input.el
@@ -28,6 +28,11 @@
 (require 'idris-common-utils)
 (require 'idris-settings)
 
+(defvar idris--semantic-source-highlighting t
+  "Initial state of syntax highligt when connecting to Idris process.
+
+Used to ensure we send the right value in `:enable-syntax' option.")
+
 (defun idris-highlight-remove-overlays (&optional buffer)
   "Remove all Idris highlighting overlays from BUFFER.
 Use the current buffer if BUFFER is nil."
@@ -110,9 +115,16 @@ See Info node `(elisp)Overlay Properties' to understand 
how ARGS are used."
 (defun idris-toggle-semantic-source-highlighting ()
   "Turn on/off semantic highlighting.
 This is controled by value of `idris-semantic-source-highlighting' variable."
-  (if idris-semantic-source-highlighting
-      (advice-remove 'idris-highlight-source-file #'ignore)
-    (advice-add 'idris-highlight-source-file :around #'ignore)))
+  (unless (eq idris-semantic-source-highlighting
+              idris--semantic-source-highlighting)
+    (if idris-semantic-source-highlighting
+        (if (>=-protocol-version 2 1)
+            (idris-eval '(:enable-syntax :True))
+          (advice-remove 'idris-highlight-source-file #'ignore))
+      (if (>=-protocol-version 2 1)
+          (idris-eval '(:enable-syntax :False))
+        (advice-add 'idris-highlight-source-file :around #'ignore)))
+    (setq idris--semantic-source-highlighting 
idris-semantic-source-highlighting)))
 
 (defun idris-buffer-semantic-source-highlighting ()
   "Return nil if current buffer size is larger than set limit.

Reply via email to