Skip to content

Fix: font lock updates #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions hy-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"max"
"memoryview"
"min"
"match"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the whole list can be replaced by reusing python mode:

(defconst hy-font-lock--python-builtins
  (seq-concatenate 'list
                   (seq-copy python--treesit-builtins)
                   '("--package--"
                     "--import--"
                     "--all--"
                     "--doc--"
                     "--name--"))
  "Builtin names available in Python normally.")

"next"
"object"
"oct"
Expand Down Expand Up @@ -219,17 +220,25 @@

(defconst hy-font-lock--exceptions
'("ArithmeticError" "AssertionError" "AttributeError" "BaseException"
"DeprecationWarning" "EOFError" "EnvironmentError" "Exception"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants and exceptions as well can be reused.

;;;; Constants

(defconst hy-font-lock--constants (seq-copy python--treesit-constants)
  "Constant names in Hy.")

;;;; Exceptions

(defconst hy-font-lock--exceptions (seq-copy python--treesit-exceptions)
  "Exception and error names.")

"FloatingPointError" "FutureWarning" "GeneratorExit" "IOError" "ImportError"
"ImportWarning" "IndexError" "KeyError" "KeyboardInterrupt" "LookupError"
"MemoryError" "NameError" "NotImplementedError" "OSError" "OverflowError"
"PendingDeprecationWarning" "ReferenceError" "RuntimeError" "RuntimeWarning"
"StopIteration" "SyntaxError" "SyntaxWarning" "SystemError" "SystemExit"
"TypeError" "UnboundLocalError" "UnicodeDecodeError" "UnicodeEncodeError"
"UnicodeError" "UnicodeTranslateError" "UnicodeWarning" "UserWarning"
"VMSError" "ValueError" "Warning" "WindowsError" "ZeroDivisionError"
"BufferError" "BytesWarning" "IndentationError" "ResourceWarning"
"TabError")
"BufferError" "BytesWarning" "DeprecationWarning" "EOFError"
"EnvironmentError" "Exception" "FloatingPointError" "FutureWarning"
"GeneratorExit" "IOError" "ImportError" "ImportWarning"
"IndentationError" "IndexError" "KeyError" "KeyboardInterrupt"
"LookupError" "MemoryError" "NameError" "NotImplementedError"
"OSError" "OverflowError" "PendingDeprecationWarning"
"ReferenceError" "RuntimeError" "RuntimeWarning" "StopIteration"
"SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError"
"TypeError" "UnboundLocalError" "UnicodeDecodeError"
"UnicodeEncodeError" "UnicodeError" "UnicodeTranslateError"
"UnicodeWarning" "UserWarning" "ValueError" "Warning"
"ZeroDivisionError"
"BlockingIOError" "BrokenPipeError" "ChildProcessError"
"ConnectionAbortedError" "ConnectionError" "ConnectionRefusedError"
"ConnectionResetError" "FileExistsError" "FileNotFoundError"
"InterruptedError" "IsADirectoryError" "NotADirectoryError"
"PermissionError" "ProcessLookupError" "RecursionError"
"ResourceWarning" "StopAsyncIteration" "TimeoutError"
"VMSError" "WindowsError")
"Exception and error names.")

;;;; Definitions
Expand All @@ -240,15 +249,16 @@

;; Macros
"defmacro" "defmacro/g!" "defmacro!"
"delmacro"

;; Tag Macros
"deftag"
;; Reader Macros
"defreader"

;; Defining __main__
"defmain"

;; Multi-methods
"defmulti" "defmethod")
;; Defining lazy sequences
"defseq")
"Names in Hy that define functions, macros, etc.")

;;;; Operators
Expand All @@ -264,7 +274,7 @@
(defconst hy-font-lock--special-names
'(;; Looping
"for" "for/a"
"dfor" "lfor" "sfor" ; comprehensions
"dfor" "lfor" "sfor" "gfor" "cfor" ; comprehensions
"loop" "recur" ; hy.contrib.loop

;; Threading
Expand All @@ -277,6 +287,8 @@
"break" "continue" "while"
"cond"
"do"
"case" "branch"
"ecase" "ebranch"
Comment on lines +290 to +291

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These may have been since replaced by match.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake, these are from hyrule.


;; Functional
"fn" "fn/a"
Expand All @@ -286,7 +298,7 @@
"with-gensyms"

;; Error Handling
"except" "try" "throw" "raise" "catch" "finally" "assert"
"except" "try" "throw" "raise" "finally" "assert"

;; Python builtins (and shadowed calls to builtins)
"print"
Expand All @@ -313,7 +325,9 @@
"ap-map"
"ap-map-when"
"ap-reduce"
"ap-reject")
"ap-reject"
"ap-when"
"ap-with")
"Hy anaphoric contrib keywords.")

;;; Keywords
Expand Down