highlight modules (#2)

* highlight modules
* highlight remote type modules as modules
* make string replace variable parameter example less ambiguous
pull/204/head
Michael Davis 2022-01-13 22:14:02 +07:00 committed by GitHub
parent 5b9ac0c6a7
commit e254d08b7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 12 deletions

@ -7,6 +7,15 @@
(constant
name: (identifier) @constant)
; Modules
(module) @module
(import alias: (identifier) @module)
(remote_type_identifier module: (identifier) @module)
((function_call function: (field_access record: (identifier) @module))
(#is-not? local))
((binary_expression "|>" (field_access record: (identifier) @module))
(#is-not? local))
; Functions
(function
name: (identifier) @function)

@ -0,0 +1,13 @@
; Scopes
(function_body) @local.scope
; Definitions
(let pattern: (identifier) @local.definition)
(function_parameter name: (identifier) @local.definition)
(list_pattern (identifier) @local.definition)
(list_pattern assign: (identifier) @local.definition)
(tuple_pattern (identifier) @local.definition)
(record_pattern_argument pattern: (identifier) @local.definition)
; References
(identifier) @local.reference

@ -3,7 +3,7 @@ pub fn replace(
// <- keyword
// ^ function
// ^ punctuation.bracket
in string: String,
in original: String,
// <- property
// ^ variable.parameter
// ^ type
@ -22,15 +22,15 @@ pub fn replace(
// <- punctuation.delimeter
// ^ type
// ^ punctuation.bracket
string.replace(in: string, each: pattern, with: replacement)
// <- variable
string.replace(in: original, each: pattern, with: replacement)
// <- module
// ^ property
// ^ property
// ^ variable
// ^ variable.parameter
// ^ property
// ^ variable
// ^ variable.parameter
// ^ property
// ^ variable
// ^ variable.parameter
}
fn trial(uri) {

@ -0,0 +1,40 @@
import gleam/io
// ^ module
// ^ module
// ^ module
import animal/cat as kitty
// ^ module
// ^ module
pub fn main() {
io.println("hello world")
// <- module
}
type MyType {
MyType(func: fn() -> Int)
}
fn record_access_case(param: MyType) {
let binding = MyType(func: fn() { 42 })
let _ = binding.func()
// ^ variable
let _ = param.func()
// ^ variable.parameter
}
fn pipe_operator_case(string: String) {
string
// <- variable.parameter
|> iodata.new
// ^ module
|> iodata.reverse
// ^ module
}
fn remote_type_case() {
gleam.Ok(1)
// <- module
// ^ punctuation.delimeter
// ^ type
}