Skip to content
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

Elixir support #1844

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ next-env.d.ts

# test subset config
packages/test-harness/testSubsetGrep.properties

data/playground/.metals
data/playground/.vscode
r-tae marked this conversation as resolved.
Show resolved Hide resolved
data/playground/.scala-build
.talon
r-tae marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 19 additions & 0 deletions data/playground/elixir/calls.ex
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
31 changes: 31 additions & 0 deletions data/playground/elixir/data-structures.ex
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
62 changes: 62 additions & 0 deletions data/playground/elixir/functions.ex
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
2 changes: 1 addition & 1 deletion packages/common/src/extensionDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const extensionDependencies = [
"scalameta.metals",
"mrob95.vscode-talonscript",
"jrieken.vscode-tree-sitter-query",

// Necessary for the `drink cell` and `pour cell` tests
"ms-toolsai.jupyter",
"jakebecker.elixir-ls",
r-tae marked this conversation as resolved.
Show resolved Hide resolved
];
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}
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}
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}
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}
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}
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}
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}
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}
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}
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}
Loading