idris-mode icon indicating copy to clipboard operation
idris-mode copied to clipboard

Bad syntax highlighting of .lidr files

Open nicolabotta opened this issue 4 years ago • 3 comments

Syntax highlighting works fine on .idr files but on .lidr files (Bird style), I get something like this:

Screenshot_2019-12-29_15-31-02

Is there a way to get the same highlighting on .idr files and .lidr files? Thanks + cheers, Nicola

nicolabotta avatar Dec 29 '19 14:12 nicolabotta

This used to work!

I suspect a bug in Idris itself, where it's likely sending the source locations after post processing to get rid of the tracks.

I'm away from the computer on parental leave, but if someone wants to work on this, check the highlight commands being sent by Idris.

On Sun, Dec 29, 2019, 06:43 nicolabotta [email protected] wrote:

Syntax highlighting works fine on .idr files but on .lidr files (Bird style), I get something like this:

[image: Screenshot_2019-12-29_15-31-02] https://user-images.githubusercontent.com/2726946/71558235-1918e180-2a51-11ea-8ec2-35e321f1b3c1.png

Is there a way to get the same highlighting on .idr files and .lidr files? Thanks + cheers, Nicola

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/idris-hackers/idris-mode/issues/506?email_source=notifications&email_token=AAA4FAQIQ3KTP7PCVTHA36LQ3CZSDA5CNFSM4KA5MGXKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IDEA7LQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA4FAUO7MBMQEU3T4MQRT3Q3CZSDANCNFSM4KA5MGXA .

david-christiansen avatar Dec 29 '19 14:12 david-christiansen

Thanks David, I have opened https://github.com/idris-lang/Idris-dev/issues/4799#issue-543469766. Best, Nicola

nicolabotta avatar Dec 29 '19 16:12 nicolabotta

As reported in https://github.com/idris-lang/Idris-dev/issues/4799#issuecomment-569899621, there seem to be two problems in the current idris-mode.

For syntax highlighting to work as expected for .lidr files, the function

(defun idris-highlight-column (idris-col)
  "Compute the Emacs position offset of the Idris column IDRIS-COL, for highlighting.                                     
                                                                                                                          
In particular, this takes bird tracks into account in literate Idris."
  (+ idris-col (if (idris-lidr-p) 1 -1)))

had to be modified as suggested by andrewmcveigh in idris-hackers/idris-mode#480 as

(defun idris-highlight-column (idris-col)
  "Compute the Emacs position offset of the Idris column IDRIS-COL, for highlighting.                                     
                                                                                                                          
In particular, this takes bird tracks into account in literate Idris."
  (+ idris-col (if (idris-lidr-p) -1 -1)))

and loaded. The second problem is that the file that defines idris-highlight-column, idris-highlight-input.el, is not loaded when idris-mode is started. Thus, just modifying the function has no effect when idris-mode is loaded in a fresh emacs instance. One has to manually load idris-highlight-input.el for syntax highlighting to work as expected. Cheers, Nicola

nicolabotta avatar Dec 31 '19 10:12 nicolabotta