Skip to content
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

Add additional level of highlighting for function/type/property usage #35

Open
wants to merge 1 commit into
base: main
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
37 changes: 23 additions & 14 deletions gleam-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@
(function
name: (identifier) @font-lock-function-name-face)
(external_function
name: (identifier) @font-lock-function-name-face)
name: (identifier) @font-lock-function-name-face))

:feature 'function-use
:language 'gleam
'((function_call function: (identifier) @font-lock-function-call-face)
(function_call
function: (identifier) @font-lock-function-name-face))
function: (field_access record: (identifier) field: (label) @font-lock-function-call-face)))

:feature 'variable-name
:language 'gleam
Expand All @@ -110,6 +114,14 @@
(remote_type_identifier) @font-lock-type-face
(type_identifier) @font-lock-type-face)

:language 'gleam
:feature 'type-use
'(((record name: (constructor_name) @font-lock-type-face))
((record_pattern name: (constructor_name) @font-lock-type-face))
((data_constructor name: (constructor_name) @font-lock-type-face))
((remote_constructor_name name: (constructor_name) @font-lock-type-face))
((record_update constructor: (constructor_name) @font-lock-type-face)))

:feature 'constant-name
:language 'gleam
:override t
Expand Down Expand Up @@ -145,9 +157,12 @@

:feature 'property
:language 'gleam
'((label) @font-lock-property-name-face
(tuple_access
index: (integer) @font-lock-property-name-face))
'((data_constructor_argument label: (label) @font-lock-property-name-face))

:feature 'property-use
:language 'gleam
'((field_access record: (identifier) field: (label) @font-lock-property-use-face)
(tuple_access index: (integer) @font-lock-property-use-face))

:feature 'annotation
:language 'gleam
Expand All @@ -167,14 +182,7 @@
'((module) @gleam-ts-module-face
(import alias: (identifier) @gleam-ts-module-face)
(remote_type_identifier
module: (identifier) @gleam-ts-module-face)
(remote_constructor_name
module: (identifier) @gleam-ts-module-face)
;; Unfortunately #is-not? local doesn't work here
;; ((field_access
;; record: (identifier) @gleam-ts-module-face)
;; (#is-not? local))
)
module: (identifier) @gleam-ts-module-face))

:feature 'builtin
:language 'gleam
Expand Down Expand Up @@ -391,7 +399,8 @@ otherwise, it aligns with the initial expression."
(setq-local treesit-font-lock-feature-list
'((comment string number function-name variable-name constructor type-name)
(constant-name keyword operator property)
(annotation documentation module builtin bracket delimiter)))
(annotation documentation module builtin bracket delimiter)
(function-use property-use type-use)))

(setq-local treesit-simple-indent-rules gleam-ts--indent-rules)

Expand Down