-
-
Notifications
You must be signed in to change notification settings - Fork 85
Elixir support #1844
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
Draft
r-tae
wants to merge
24
commits into
cursorless-dev:main
Choose a base branch
from
r-tae:elixir-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Elixir support #1844
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f3e979b
Initial WIP elixir support
r-tae 74ac7ee
Address comments and format elixir.scm
r-tae f452edb
Move func def `#match?` predicate for readability
r-tae 2e9ced4
Support maps and map shorthand
r-tae 0502350
Add map tests
r-tae af5ffb4
Add module support (as "class" scope)
r-tae 9547949
Add more elixir syntax examples in playground
r-tae fc7d6cc
Fix unfinished comment
r-tae d5843c4
Keep `end` on its own line for "chuck inside funk"
r-tae 3b8456f
Add negative funk test
r-tae 36ba114
Add elixirls extension dependency
r-tae 437e803
Merge branch 'main' into elixir-support
r-tae 8b74b41
Add defguard query
r-tae c7fc534
Merge branch 'main' into elixir-support
r-tae d965ad9
Remove unwanted .gitignore inclusions
r-tae 89955dd
Delete unecessary previous comment test
r-tae e8f8c11
Make defmodule namedFunction iteration scope
r-tae 5a1d1ab
Add @textFragment to string and comment
r-tae 52fc129
Add comment explaining elixir-ls dependency
r-tae b5bb32f
Merge branch 'main' into elixir-support
r-tae 9f7ad92
Merge branch 'main' into pr/r-tae/1844
pokey 470a072
Cleanup
pokey 2471282
Some fixes
pokey 8e08213
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 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 hidden or 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 hidden or 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,19 @@ | ||
defmodule Calls do | ||
a() | ||
b.() | ||
c do | ||
1 | ||
end | ||
d.() do | ||
end | ||
e.() do | ||
1 | ||
end | ||
a x do | ||
x | ||
end | ||
f.(0) do | ||
1 | ||
end | ||
Alias.g() | ||
r-tae marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end |
This file contains hidden or 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,31 @@ | ||
defmodule DataStructures do | ||
[] | ||
[a] | ||
[A] | ||
[1] | ||
[1, 2] | ||
[[1], 1] | ||
%{} | ||
%{a: 1, b: 2} | ||
%{:a => 1, "b" => 2, c => 3} | ||
%{"a" => 1, b: 2, c: 3} | ||
%{user | name: "Jane", email: "[email protected]"} | ||
%{user | "name" => "Jane"} | ||
%AStruct{a: 1, b: 2} | ||
%AnotherStruct{:a => 1, "b" => 2, c => 3} | ||
%ThirdStruct{"a" => 1, b: 2, c: 3} | ||
%User{user | name: "Jane", email: "[email protected]"} | ||
%User{user | "name" => "Jane"} | ||
%_{} | ||
%name{} | ||
%^name{} | ||
%__MODULE__{} | ||
%__MODULE__.Child{} | ||
%:"Elixir.Mod"{} | ||
%fun(){} | ||
%Mod.fun(){} | ||
%fun.(){} | ||
{} | ||
{1} | ||
{1, 2} | ||
end |
This file contains hidden or 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,62 @@ | ||
defmodule Funcs do | ||
def no_args() do | ||
end | ||
|
||
def no_args_no_parens do | ||
end | ||
|
||
def one_arg(x) do | ||
x | ||
end | ||
|
||
def one_arg_no_parens(x) do | ||
x | ||
end | ||
|
||
def two_args(x, y) do | ||
x + y | ||
end | ||
|
||
def two_args_no_parens(x, y) do | ||
x + y | ||
end | ||
|
||
def default_args_no_parens(x, y \\ 1) do | ||
x + y | ||
end | ||
|
||
def default_args(x, y \\ 1) do | ||
x + y | ||
end | ||
|
||
def do_block(), do: 1 | ||
def do_block(x), do: x | ||
|
||
def pattern_matching([{x, y} | tail]) do | ||
x + y | ||
end | ||
|
||
def one_guard(x) when x == 1 do | ||
x | ||
end | ||
|
||
def multiple_guard(x) when x > 10 when x < 5 do | ||
x | ||
end | ||
|
||
defp private(x) do | ||
x | ||
end | ||
|
||
defmacro macro(x) do | ||
quote do | ||
[unquote(x)] | ||
end | ||
end | ||
|
||
defguard guard(term) when is_integer(term) and rem(term, 2) == 0 | ||
|
||
def unquote(name)(unquote_splicing(args)) do | ||
unquote(compiled) | ||
end | ||
end |
This file contains hidden or 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
27 changes: 27 additions & 0 deletions
27
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk.yml
This file contains hidden or 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,27 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: | | ||
def fun() do | ||
# body | ||
end | ||
selections: | ||
- anchor: {line: 1, character: 2} | ||
active: {line: 1, character: 2} | ||
marks: {} | ||
finalState: | ||
documentContents: |+ | ||
|
||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
26 changes: 26 additions & 0 deletions
26
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk10.yml
This file contains hidden or 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,26 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
def fun(x) when x == 1 do | ||
x | ||
end | ||
selections: | ||
- anchor: {line: 1, character: 2} | ||
active: {line: 1, character: 2} | ||
marks: {} | ||
finalState: | ||
documentContents: "" | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
26 changes: 26 additions & 0 deletions
26
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk11.yml
This file contains hidden or 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,26 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
defp fun(x) do | ||
x | ||
end | ||
selections: | ||
- anchor: {line: 1, character: 2} | ||
active: {line: 1, character: 2} | ||
marks: {} | ||
finalState: | ||
documentContents: "" | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
28 changes: 28 additions & 0 deletions
28
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk12.yml
This file contains hidden or 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,28 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
defmacro fun(x) do | ||
quote do | ||
[unquote(x)] | ||
end | ||
end | ||
selections: | ||
- anchor: {line: 2, character: 4} | ||
active: {line: 2, character: 4} | ||
marks: {} | ||
finalState: | ||
documentContents: "" | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
25 changes: 25 additions & 0 deletions
25
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk13.yml
This file contains hidden or 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,25 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: | | ||
defguard is_even(term) when is_integer(term) and rem(term, 2) == 0 | ||
selections: | ||
- anchor: {line: 0, character: 26} | ||
active: {line: 0, character: 26} | ||
marks: {} | ||
finalState: | ||
documentContents: |+ | ||
|
||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
22 changes: 22 additions & 0 deletions
22
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk14.yml
This file contains hidden or 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,22 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
a x do | ||
x | ||
end | ||
selections: | ||
- anchor: {line: 1, character: 3} | ||
active: {line: 1, character: 3} | ||
marks: {} | ||
thrownError: {name: NoContainingScopeError} |
27 changes: 27 additions & 0 deletions
27
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk2.yml
This file contains hidden or 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,27 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: | | ||
def fun do | ||
# body | ||
end | ||
selections: | ||
- anchor: {line: 1, character: 2} | ||
active: {line: 1, character: 2} | ||
marks: {} | ||
finalState: | ||
documentContents: |+ | ||
|
||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
25 changes: 25 additions & 0 deletions
25
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk3.yml
This file contains hidden or 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,25 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: | | ||
def fun, do: 1 | ||
selections: | ||
- anchor: {line: 0, character: 14} | ||
active: {line: 0, character: 14} | ||
marks: {} | ||
finalState: | ||
documentContents: |+ | ||
|
||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
25 changes: 25 additions & 0 deletions
25
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk4.yml
This file contains hidden or 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,25 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: | | ||
def fun(), do: 1 | ||
selections: | ||
- anchor: {line: 0, character: 16} | ||
active: {line: 0, character: 16} | ||
marks: {} | ||
finalState: | ||
documentContents: |+ | ||
|
||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
26 changes: 26 additions & 0 deletions
26
packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/elixir/changeFunk5.yml
This file contains hidden or 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,26 @@ | ||
languageId: elixir | ||
command: | ||
version: 6 | ||
spokenForm: change funk | ||
action: | ||
name: clearAndSetSelection | ||
target: | ||
type: primitive | ||
modifiers: | ||
- type: containingScope | ||
scopeType: {type: namedFunction} | ||
usePrePhraseSnapshot: true | ||
initialState: | ||
documentContents: |- | ||
def fun(x) do | ||
x | ||
end | ||
selections: | ||
- anchor: {line: 1, character: 2} | ||
active: {line: 1, character: 2} | ||
marks: {} | ||
finalState: | ||
documentContents: "" | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.