Skip to content

feat(gleam): support functions and parameters#715

Closed
McCourtRC wants to merge 3 commits intonvim-treesitter:masterfrom
McCourtRC:master
Closed

feat(gleam): support functions and parameters#715
McCourtRC wants to merge 3 commits intonvim-treesitter:masterfrom
McCourtRC:master

Conversation

@McCourtRC
Copy link

@McCourtRC McCourtRC commented Nov 13, 2024

functions

// @function.outer start
pub fn foo(a a: String, b b: String) -> String {
  // @function.inner start  
  a <> b
  // @function.inner end
}
// @function.outer end

// anonymous functions
                     // @function.outer start
with_callback("foo", fn () {
  // @function.inner start 
  "bar"
  // @function.inner end
}                    // @function.outer end
)

parameters
(NOTE: @parameter.outer includes trailing ,)

// function parameters
pub fn foo(a a: String, b b: String) -> String {
  a <> b
}

// arguments
foo(a: "foo", b: "bar")

// data constructor arguments
pub type Foo {
  Foo(a: String, b: String)
}

@clason clason added the legacy Issues and PRs targeting the obsolete master branch. label Nov 30, 2025
@locnide locnide mentioned this pull request Jan 7, 2026
4 tasks
@clason clason closed this Jan 31, 2026
kiyoon pushed a commit that referenced this pull request Mar 8, 2026
This pull requests adds textobjects for gleam.

I mainly took inspiration from the rust `textobject.scm`. 

Feel free to review, it is the first treesitter query file I wrote.

PR #715 is similar but seem abandonned.

---

Some thing that I still have to implement before merge: 

- [x] trailing comma for parameter.outer. Currently trailing comma are
ignored.
- [x] add `@assign.inner` but I’m not sure what it should select, see
#852
- [x] migrate my install to treesitter-nvim main… current CI issues
mighnt be due to an obsolete parser I used for testing
- [x] rebase and squash

---

Some tags are not implemented in this PR:

- `@attribute` couldn’t find examples in languages I know. Are there
supposed to be type/class attributes ?
- `@comment.inner` I would have to use directives
- `@frame`, `@loop` and `@regex` not relevant
- `@scopename` I do not know what it is
---

~~P.S. : I had trouble making `make docs` work
#854
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

legacy Issues and PRs targeting the obsolete master branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants