-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support toplevel defs with metadata #43
Closed
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9112b4d
Allow font locking of `def`s at the toplevel with metadata
kommen ce90a9b
Don't indent toplevel `def`s with metadata
kommen 7867ed5
Fix bytecompile
kommen c956302
Better solution for indentation of forms with meta, add tests
kommen db53936
Lint
kommen 56fbdbc
Merge remote-tracking branch 'origin/main' into tld-with-metadata
kommen 84a56ce
Correctly font-lock docstring in def/defn with meta data
kommen 32dc24a
Fix body indentation with meta data
kommen 3b2e674
Use clojure-ts--meta-node-p
kommen 702af2e
Fix imenu entries for def/defn having meta data
kommen 026b65d
Refactor using clojure-ts--node-child-skip-meta
kommen 75aa34d
Correctly font lock the name symbols of def and defn with meta data
kommen 75edb95
Lint
kommen 774330d
Use 'metadata' instead of just 'meta' in function names
kommen cf90573
Small code formatting fix
kommen 6d71712
Touch up clojure-ts--node-child-skip-metadata
kommen 919884b
Remove unused function args
kommen b1e4ab0
Lint
kommen 997c591
Add tests for the imenu fixes
kommen 7e44026
Replace unneded let*
kommen 9152ab6
Fix call to clojure-ts--match-with-metadata
kommen d495e11
Try lint
kommen eafed20
Try lint
kommen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
;;; clojure-ts-mode-util-test.el --- Clojure TS Mode: util test suite -*- lexical-binding: t; -*- | ||
|
||
;; Copyright © 2022-2024 Danny Freeman | ||
|
||
;; This file is not part of GNU Emacs. | ||
|
||
;; This program is free software; you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation, either version 3 of the License, or | ||
;; (at your option) any later version. | ||
|
||
;; This program is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
|
||
;; You should have received a copy of the GNU General Public License | ||
;; along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
;;; Commentary: | ||
|
||
;; The unit test suite of Clojure TS Mode | ||
|
||
(require 'clojure-ts-mode) | ||
(require 'buttercup) | ||
(require 'imenu) | ||
|
||
|
||
(describe "clojure-ts-mode imenu integration" | ||
(it "should index def with meta data" | ||
(with-clojure-ts-buffer "^{:foo 1}(def a 1)" | ||
(expect (imenu--in-alist "a" (imenu--make-index-alist)) | ||
:not :to-be nil))) | ||
|
||
(it "should index defn with meta data" | ||
(with-clojure-ts-buffer "^{:foo 1}(defn a [])" | ||
(expect (imenu--in-alist "a" (imenu--make-index-alist)) | ||
:not :to-be nil)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets you some of the way to syntax highlighting with these types of forms. A similar fix I believe is also needed for just about anything that follows the pattern of matching
Because any list literal can have metadata attached to the beginning. A lot of these queries want to capture the first symbol in the list to match special function calls, so they had to be
:anchor
ed to the front of the list. They all break down when metadata is present because the syntax tree lists the metadata as the first literal sub element of the list node.This also applies to the docstring queries in
clojure-ts--docstring-query
.and
The
"hello"
string in both should be highlighted withThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't get this to work for now. Shall I revert my change related to this and get the PR merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unsure. I need to set aside some time to get reacquainted with this problem. I'll try to do that within the next week and have a better answer for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dannyfreeman thank you! meanwhile, I had a chance to dive deeper and I think I actually figured it out (mostly?). there are a bunch of similar queries where the the optional metadata node could be added, but I didn't have time to come up with actual clojure code examples testing them so a didn't want to touch them – maybe unnecessarily.