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

Initial Nim language support #6123

Merged
merged 4 commits into from
Mar 26, 2023
Merged

Initial Nim language support #6123

merged 4 commits into from
Mar 26, 2023

Conversation

omentic
Copy link
Contributor

@omentic omentic commented Feb 27, 2023

Supercedes #3492.

I've not been able to find comprehensive tree-sitter documentation: and so the queries are mostly modelled after preexisting schemes of other languages.

Before this PR is merged, I'd like to:

  • Test and debug the tree-sitter queries! They're unlikely to work first try. In particular: I'm worried about the type and variable declarations.
  • regenerate documentation (cargo xtask docgen)

After this PR is merged, I'd like to:

  • Incorporate these schemes into the tree-sitter-nim repository, so they can be reused across editors
  • Help get alavass/tree-sitter-nim into a more complete state edit: aMOPel/tree-sitter-nim is now good enough
  • Run the schemes by the Nim community and rework them into better, more complete representations as needed

Resources:

@omentic
Copy link
Contributor Author

omentic commented Feb 27, 2023

Hmm, seems alaviss is working on a rewrite. I'm going to port the queries to aMOPel's repository to get a better sense of how they work, and then possibly re-port them back to alaviss's repo once it's done.

@omentic omentic marked this pull request as ready for review February 27, 2023 17:30
@omentic
Copy link
Contributor Author

omentic commented Mar 2, 2023

2023-03-01-170457

I have minimally working highlight queries + a working language server as of now. Keywords are much more involved and much closer tied to the grammar than I initially hoped. Types have been buggy, but I've some ideas for fixing them.

@omentic
Copy link
Contributor Author

omentic commented Mar 3, 2023

Everything but variable usages appear to be working.
2023-03-03-111406

@omentic
Copy link
Contributor Author

omentic commented Mar 3, 2023

@the-mikedavis This is ready to merge. May I request a review?

@the-mikedavis the-mikedavis added S-waiting-on-review Status: Awaiting review from a maintainer. A-language-support Area: Support for programming/text languages labels Mar 3, 2023
@the-mikedavis the-mikedavis self-requested a review March 3, 2023 19:29
languages.toml Outdated
injection-regex = "nim"
file-types = ["nim", "nims", "nimble"]
shebangs = []
roots = ["*.nimble"]
Copy link
Member

Choose a reason for hiding this comment

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

We don't currently support globs or regexes for roots. We might need something more powerful for Nim: from what I can see, Nim uses <projectname>.nimble for the manifest?

For now you can leave this as roots = [] and Helix will use the .git directory as the root.

@omentic
Copy link
Contributor Author

omentic commented Mar 13, 2023

@the-mikedavis I rebased on master and did some refactoring based on changes to upstream. This is now ready to merge (more than before).

There are a few known bugs:

  • fixed: entries in std/[one, two] get highlighted as variables instead of namespaces
  • fixed: the variables a and b in seq[tuple[a, b: int]] are accidentally matched as types

But that's it, as far as I've been able to test. Everything else is highlighted correctly.

@omentic
Copy link
Contributor Author

omentic commented Mar 13, 2023

Oh - indents are bugged, I think.

@omentic
Copy link
Contributor Author

omentic commented Mar 23, 2023

(ping @the-mikedavis)

runtime/queries/nim/highlights.scm Outdated Show resolved Hide resolved
runtime/queries/nim/highlights.scm Outdated Show resolved Hide resolved
languages.toml Outdated Show resolved Hide resolved
@the-mikedavis the-mikedavis added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from a maintainer. labels Mar 25, 2023
the-mikedavis
the-mikedavis previously approved these changes Mar 26, 2023
@the-mikedavis the-mikedavis merged commit c8fde8b into helix-editor:master Mar 26, 2023
@the-mikedavis
Copy link
Member

Could you add a note on the Nim language server to the language server wiki? https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers

Triton171 pushed a commit to Triton171/helix that referenced this pull request Jun 18, 2023
wes-adams pushed a commit to wes-adams/helix that referenced this pull request Jul 4, 2023
@bdjnk bdjnk mentioned this pull request Nov 23, 2023
@omentic omentic mentioned this pull request Dec 18, 2023
21 tasks
smortime pushed a commit to smortime/helix that referenced this pull request Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants