-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Conversation
src/languages/clojure.ts
Outdated
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!", | ||
}; |
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.
@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
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.
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
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.
Ok cool. We can solve this one fairly easily in cursorless
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.
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 |
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.
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 |
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.
Note how quoted lists are treated as lists, but unquoted are not; they're treated as function calls
@@ -0,0 +1,27 @@ | |||
languageId: clojure |
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.
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
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