Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Switch to experimental Clojure grammar#99

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@rrudakov
Copy link
Contributor

Following thesogaiu/tree-sitter-clojure#65 discussion.

This PR contains a set of commit that accumulated while we were discussing changes in the grammar.

  • Update queries to work with the new grammar. Queries are also improved to better skip comments and metadata nodes. Added support for some missing earlier forms (likedefinterface,extend-type etc).
  • Better matching for docstrings for indentation and fill-paragraph function. Instead of defining custom functions we re-use docstring query now and check if node at point matches it.
  • Fixed a minor bugs inclojure-ts-align + slight performance optimization by pre-compiling the query.
  • Fixed a minor bug inclojure-ts-unwind.

This includes the changes from#98, so if this one is merged, I'll close the other one.


Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):

  • The commits are consistent with ourcontribution guidelines.
  • You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
  • You've runM-x checkdoc and fixed any warnings in the code you've written.
  • You've updated the changelog (if adding/changing user-visible functionality).
  • You've updated the readme (if adding/changing user-visible functionality).

Thanks!

Before we were trying to align multiple nodes starting from the top-level nodeand moving to the most deeply nested node. This could produce misaligned formsif nested nodes have extra spaces that has to be cleaned up. Now we start fromthe most deeply nested node and gradually move to the top of the tree.
@rrudakov
Copy link
ContributorAuthor

@bbatsov, could you please take a look?

@bbatsov
Copy link
Member

Sure. At a glance the PR looks OK, but I'll take a deeper look tomorrow, as the changes are quite extensive.

You can close#98 and perhaps add some notes to the README that we're using a modified version of the upstream grammar and our reasoning for doing this. Probably some of this should also go in some form to the design document.

@rrudakov
Copy link
ContributorAuthor

perhaps add some notes to the README that we're using a modified version of the upstream grammar and our reasoning for doing this.

This is already done, but let me know if I should extend it further.

@rrudakov
Copy link
ContributorAuthor

Probably some of this should also go in some form to the design document.

Yeah... I'm still struggling to even start with that :)

@bbatsov
Copy link
Member

This is already done, but let me know if I should extend it further.

For the README that's fine, but for the design doc I'd probably mention the summary from the end of the discussion about the creation of the experimental grammar. Overall the PR seems to be in a good shape to me, but I left small remarks here and there.

@rrudakov
Copy link
ContributorAuthor

I fixed all the mentioned issues and updated the design documentation.

@rrudakovrrudakov requested a review frombbatsovMay 27, 2025 10:43
@bbatsovbbatsov merged commitcb2cb18 intoclojure-emacs:mainMay 27, 2025
2 of 3 checks passed
@rrudakovrrudakov deleted the feature/experimental-grammar branchMay 27, 2025 10:51
@sogaiu
Copy link

sogaiu commentedMay 29, 2025
edited
Loading

Not sure if it's pilot error on my end, but my Emacs 30.1 doesn't seem to have the functiontreesit-query-valid-p mentioned in this bit:

(defunclojure-ts--clojure-grammar-outdated-p ()"Return TRUE if currently installed grammar is outdated.This function checks if`clojure-ts-mode' is compatible with thecurrently installed grammar.  The simplest way to do this is to validatea query that is valid in a previous grammar version but invalid in therequired version."  (treesit-query-valid-p'clojure '((sym_lit (meta_lit)))))

I think it got added to Emacs inthis commit.

It looks like it got added in 2025-01 (before Emacs-30.1 was released), but may be it didn't make it in?

I don't see it viagit log locally in a checkout of theemacs-30.1 tag.


Fairly short implementation though...

(defuntreesit-query-valid-p (languagequery)"Return non-nil if QUERY is valid in LANGUAGE, nil otherwise."  (ignore-errors    (treesit-query-compile language queryt)t))

@bbatsov
Copy link
Member

Hmm, seems I don't have it as well. It's interesting that lint job didn't catch this...

sogaiu reacted with eyes emoji

@rrudakov
Copy link
ContributorAuthor

Wow, that's surprising. I should have tested it on Emacs 30. Should we just copy the implementation directly toclojure-ts-mode.el?

@bbatsov
Copy link
Member

@rrudakov I guess that would be the simplest thing for now. Hopefully it will be included in 30.2 - I heard it's right around the corner, but I'm not sure what's going to land there.

@rrudakov
Copy link
ContributorAuthor

@rrudakov I guess that would be the simplest thing for now. Hopefully it will be included in 30.2 - I heard it's right around the corner, but I'm not sure what's going to land there.

I'll create a PR shortly.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@bbatsovbbatsovbbatsov approved these changes

+1 more reviewer

@sogaiusogaiusogaiu left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@rrudakov@bbatsov@sogaiu

[8]ページ先頭

©2009-2025 Movatter.jp