cursorless
cursorless copied to clipboard
Elixir support
What
Adds support for the elixir programming language
Checklist
- [x] Recorded tests for the new language
- [x] Used
"change"/"clear"instead of"take"for selection tests to make recorded tests easier to read - [ ] Added a few specific tests that use
"chuck"instead of"change"to test removal behaviour when it's interesting, especially:- [ ]
"chuck arg"with single argument in list - [ ]
"chuck arg"with multiple arguments in list - [ ]
"chuck item"with single argument in list - [ ]
"chuck item"with multiple arguments in list
- [ ]
- [x] Added
@textFragmentcaptures. Usually you want to put these on comment and string nodes. This enables"take round"to work within comments and strings. - [ ] Added a test for
"change round"inside a string, eg"hello (there)" - [/] Supported
"type"both for type annotations (egfoo: string) and declarations (eginterface Foo {}) (and added tests for this behaviour 😊) - [ ] Supported
"item"both for map pairs and list entries (with tests of course) - [ ] Add support for
"name"
There's an edge case for maps that I can't quite figure out.
Elixir has two syntaxes for map key-value pairs:
# regular map
%{"string key" => nil, :atom_key => nil, 123 => nil}
# shorthand for all atom keys
%{a: 1, b: 2, c: 3}
however, those can be combined as long as all the shorthand ones go at the end:
%{"a" => 1, b: 2, c: 3}
This means the AST has separators at two different levels, which leads to weird behaviour if you target the separators themselves
%{"a" => 1, b: 2, c: 3}
---
(source
(map
(map_content
(binary_operator
left: (_)
right: (_))
","
(keywords
(pair
key: (_)
value: (_))
","
(pair
key: (_)
value: (integer))))))
*
%{"a" => 1, b: 2, c: 3}
^^^^^^^^^^^^^^
item comma
*
%{"a" => 1, b: 2, c: 3}
^^^^^^^^^^
item blue comma
This is great! I'm about to be doing some elixir work. What's left to this? Can I help?
@jaresty help would be great! I haven't had a chance to do any more on this since Sept. The biggest outstanding thing is drink/pour in lists/maps (see Pokey's last comment, I haven't made it to a meetup since).
I don't remember what else is outstanding, but I think its mergable if we get just that working
@r-tae I'd love to help! Could we maybe find some time where you could introduce me to the work? I sent you a message on slack if you'd like to coordinate.
"call"
⬆️ I'm a bit surprised that a module definition is considered a call
⬆️ It's also surprising that function definitions are considered calls
But maybe the above all technically are function calls, because they're calling def and defmodule, respectively? I guess it depends whether users would view those as function calls
⬆️ I'm no Elixir expert, but one_arg(x) looks like the name / arg list, not a call
"funk"
Are these not function definitions?
"key"
doesn't look right to me; should just be a and b
shouldn't name and email and "name" be keys? I'm also not convinced user should be a key at all 🤔
We generally prefer if removal range of key extends all the way to start of value, to make it easier to convert a map to a list
"value"
Looks like nested values are missing here (ie "Jane" and "[email protected]")
As with "key", the removal range for value should extend from end of key
Ok I kicked the ball down the field a bit; see my changes @jaresty I'm happy to get you up to speed on this PR in a meet-up if you want to carry it to the finish line; not too much left
Thank you for that @pokey - I'm unexpectedly in a job search so it may be some time before I can get back to this.
ok @r-tae if you wanna bring this home go for it. Otherwise I may take a pass again in the future
@r-tae wanted to let you know that community now has an elixir language mode 😄
@r-tae @jaresty Would be great if any of you had the time to finish this one. I will convert it to draft in the meantime.