Skip to content

Preliminary clojure support #375

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

Merged
merged 12 commits into from
Dec 16, 2021
Merged

Preliminary clojure support #375

merged 12 commits into from
Dec 16, 2021

Conversation

pokey
Copy link
Member

@pokey pokey commented Dec 9, 2021

Adds some basic Clojure support, including a few scope types. Can prob merge without adding others, as this PR also makes sure that we have support for paired matchers, eg "take pair", "take round", "take curly", etc

Closes #373

  • Handle TODOs in code (and add tests for them)
  • Add some docstrings
  • Support "funk" (eg just a list where child 0 is "defn"?)

Comment on lines 4 to 15
const nodeMatchers: Partial<Record<ScopeType, NodeMatcherAlternative>> = {
comment: "comment",
map: "map_lit",

// A list is either a vector literal or a quoted list literal
list: ["vec_lit", "quoting_lit.list_lit"],

string: "str_lit",

// A function call is a list literal which is not quoted
functionCall: "~quoting_lit.list_lit!",
};
Copy link
Member Author

Choose a reason for hiding this comment

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

@sdorminey @somanythings Here's an initial set of supported scope types. I couldn't figure out what to do with keys / values, because they seem to be treated identically by the parse tree 🤔. I didn't add other things as well because I think it's better to have someone who really knows the language involved in that step

Choose a reason for hiding this comment

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

yeah it's entirely based on the number of items in the map it needs to be even.
a slight bugbear of mine in keyboard editing as well that I've not figured out. 🤷 the calva, will end up slurping more than I want too

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok cool. We can solve this one fairly easily in cursorless

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok so fairly easily turned out to be wrong 😅. But it works now. Can now say "key", "value", and "item"

@@ -0,0 +1,23 @@
languageId: clojure
Copy link
Member Author

Choose a reason for hiding this comment

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

Hopefully these test cases are at least somewhat readable if you're unfamiliar with them 😅. Basically they're all of the form "clear X", where "X" is a scope type such as "call", "list", "pair", etc. The idea is that it deletes the matched scope, so you can see what it referred to.

You can see the spoken form on line 4, and then check out the initial document contents on line 10, followed by the final document contents on line 16. So you can see here that "call" (eg function call), matches a parenthesized expression that's unquoted

@@ -0,0 +1,23 @@
languageId: clojure
Copy link
Member Author

Choose a reason for hiding this comment

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

Note how quoted lists are treated as lists, but unquoted are not; they're treated as function calls

@@ -0,0 +1,27 @@
languageId: clojure
Copy link
Member Author

Choose a reason for hiding this comment

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

Checking that we can remove parens, tho in reality you'd prob say "chuck bound" instead, to remove without moving cursor. You'll prob also want to try eg "box repack pair" to change parens to square brackets

@pokey pokey marked this pull request as draft December 11, 2021 18:59
@pokey pokey mentioned this pull request Dec 14, 2021
3 tasks
@pokey pokey marked this pull request as ready for review December 14, 2021 22:22
@pokey pokey merged commit 8d5e372 into main Dec 16, 2021
@pokey pokey deleted the pokey-preliminary-clojure-support branch December 16, 2021 16:44
@auscompgeek auscompgeek added the lang-lisp Lisp dialect grammar support label Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-lisp Lisp dialect grammar support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Basic clojure support
4 participants