From bcf68d2cc3f4a13b4a5db2374950f1b6c3882dec Mon Sep 17 00:00:00 2001 From: Jeroen Bourgois Date: Wed, 13 Oct 2021 19:17:45 +0200 Subject: [PATCH 1/4] feat: update elixir snippets and add eelixir snippets --- snippets/eelixir.json | 44 ++++++++++ snippets/elixir.json | 191 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 231 insertions(+), 4 deletions(-) create mode 100644 snippets/eelixir.json diff --git a/snippets/eelixir.json b/snippets/eelixir.json new file mode 100644 index 00000000..9bd6291a --- /dev/null +++ b/snippets/eelixir.json @@ -0,0 +1,44 @@ +{ + "%": { + "prefix": "%", + "body": "<% $0 %>" + }, + "=": { + "prefix": "=", + "body": "<%= $0 %>" + }, + "gettext": { + "prefix": "gt", + "body": "<%= gettext(\"$0\") %>" + }, + "for": { + "prefix": "for", + "body": [ + "<%= for %{1:item} <- ${2:items} do %>", + " $0", + "<% end %>" + ] + }, + "if": { + "prefix": "if", + "body": [ + "<%= if ${1} do %>", + " $0", + "<% end %>" + ] + }, + "ife": { + "prefix": "if", + "body": [ + "<%= if ${1} do %>", + " $2", + "<% else %>", + " $0", + "<% end %>" + ] + }, + "lin": { + "prefix": "if", + "body": "<%= link \"${1:Submit}\", to: ${2:\"/users\"}, method: ${3::delete} %>" + } +} diff --git a/snippets/elixir.json b/snippets/elixir.json index 19f609a3..b53c4568 100644 --- a/snippets/elixir.json +++ b/snippets/elixir.json @@ -1,8 +1,8 @@ { "defmodule": { - "prefix": "defmodule", + "prefix": "defmo", "body": [ - "defmodule ${1:Name} do", + "defmodule ${1:module} do", " $0", "end" ], @@ -26,12 +26,195 @@ ], "description": "Define a private function" }, + "IO.puts": { + "prefix": "put", + "body": "IO.puts($0)" + }, "IO.inspect": { "prefix": "ins", - "body": "IO.inspect(${0})", + "body": "IO.inspect($0)" }, "IO.inspect with label": { "prefix": "insl", - "body": "IO.inspect(${0}, label: \"${1}\")", + "body": "IO.inspect($1, label: \"$0\")" + }, + "if .. do .. end": { + "prefix": "if", + "body": [ + "if ${1:condition} do", + " $0", + "end" + ] + }, + "if .. do:": { + "prefix": "if:", + "body": "if ${1:condition}, do: $0" + }, + "if .. do .. else .. end": { + "prefix": "ife", + "body": [ + "if ${1:condition} do", + " $2", + "else", + " $0", + "end" + ] + }, + "if .. do: .. else:": { + "prefix": "ife:", + "body": "if ${1:condition}, do: $2, else: $0" + }, + "cond": { + "prefix": "cond", + "body": [ + "cond do", + " $1 -> ", + " $0", + "end" + ] + }, + "case": { + "prefix": "case", + "body": [ + "case $1 do", + " $2 -> ", + " $0", + "end" + ] + }, + "for": { + "prefix": "for", + "body": [ + "for ${1:item} <- ${2:items} do", + " $0", + "end" + ] + }, + "def + doc": { + "prefix": "defd", + "body": [ + "@doc \"\"\"", + "${1:doc}", + "\"\"\"", + "def ${2:name} do", + " $0", + "end" + ] + }, + "def + spec": { + "prefix": "defs", + "body": [ + "@spec ${1:name}(${2:args}) :: ${3:no_return}", + "def $1{4:args} do", + " $0", + "end" + ] + }, + "def + doc + spec": { + "prefix": "defsd", + "body": [ + "@doc \"\"\"", + "${1:doc}", + "\"\"\"", + "@spec ${2:name}(${3:args}) :: ${4:no_return}", + "def $2{5:args} do", + " $0", + "end" + ] + }, + "doc": { + "prefix": "doc", + "body": [ + "@doc \"\"\"", + "$0", + "\"\"\"" + ] + }, + "doc s": { + "prefix": "docs", + "body": [ + "@doc ~S\"\"\"", + "$0", + "\"\"\"" + ] + }, + "doc false": { + "prefix": "docf", + "body": "@doc false" + }, + "moduledoc": { + "prefix": "mdoc", + "body": [ + "@moduledoc \"\"\"", + "$0", + "\"\"\"" + ] + }, + "moduledoc s": { + "prefix": "mdocs", + "body": [ + "@moduledoc ~S\"\"\"", + "$0", + "\"\"\"" + ] + }, + "moduledoc false": { + "prefix": "mdocf", + "body": "@moduledoc false" + }, + "require": { + "prefix": "req", + "body": "require ${0:Logger}" + }, + "test": { + "prefix": "test", + "body": [ + "test ${1:name} do", + " $0", + "end" + ] + }, + "des": { + "prefix": "test", + "body": [ + "describe \"${1:test group subject}\" do", + " $0", + "end" + ] + }, + "IEx.pry": { + "prefix": "pry", + "body": [ + "require IEx; IEx.pry", + "$0" + ] + }, + "pipe char": { + "prefix": "p", + "body": "|> $0" + }, + "pipe into each": { + "prefix": ">e", + "body": "|> Enum.each($0)" + }, + "pipe into map": { + "prefix": ">m", + "body": "|> Enum.map($0)" + }, + "pipe into filter": { + "prefix": ">f", + "body": "|> Enum.filter($0)" + }, + "pipe into reduce": { + "prefix": ">f", + "body": "|> Enum.reduce(${1:acc}, fn ${2}, ${3:acc} -> $0 end)" + }, + "word list": { + "prefix": "wl", + "body": "~w($0)" }, + "atom list": { + "prefix": "wl", + "body": "~w($0)a" + } } From 2353145014bf0c536a10b60577cb8a9eaac71f38 Mon Sep 17 00:00:00 2001 From: Jeroen Bourgois Date: Wed, 13 Oct 2021 19:26:00 +0200 Subject: [PATCH 2/4] feat: add Elixir to the readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e6b8b48d..63846aa3 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ duplicates. - Go - GDScript (Godot) - Haskell +- Elixir - Eruby - Ruby - Swift From f44ece7594dc7305b4fc3f113b1149b34976e765 Mon Sep 17 00:00:00 2001 From: Jeroen Bourgois Date: Fri, 29 Oct 2021 15:34:03 +0200 Subject: [PATCH 3/4] chore: fix readme order --- README.md | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/README.md b/README.md index 590d9b44..3d9426ea 100644 --- a/README.md +++ b/README.md @@ -11,41 +11,6 @@ place. First make sure that the snippets don't already exist, so we don't have duplicates. -### Snippets for: - -- HTML, Pug, Jade -- CSS, Sass, Less, Stylus -- JavaScript, Typescript, Javascriptreact, Typescriptreact -- Vue -- PHP -- Python -- C -- C++ -- C# -- ReScript -- Rust -- Go -- GDScript (Godot) -- Haskell -- Elixir -- Eruby -- Ruby -- Swift -- Java -- Fortran -- Lua -- LaTex -- Shell -- Markdown -- Sql -- Rails -- Elixir -- Fennel -- Cobol -- Jekyll(Markdown) -- Kotlin -- R(Markdown) - ### Usage This collection of snippets should work with any plugin that supports loading @@ -96,6 +61,7 @@ CocInstall https://github.com/rafamadriz/friendly-snippets@main - Go - GDScript (Godot) - Haskell +- Elixir - Eruby - Ruby - Swift From cfc2ebd9ad047da0a9def5bc2b23427f88e59cf0 Mon Sep 17 00:00:00 2001 From: Jeroen Bourgois Date: Fri, 29 Oct 2021 15:34:17 +0200 Subject: [PATCH 4/4] fix: add eelixir to package.json --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 1c9b9a39..2ad35ac4 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,10 @@ "language": "elixir", "path": "./snippets/elixir.json" }, + { + "language": "eelixir", + "path": "./snippets/eelixir.json" + }, { "language": "fortran", "path": "./snippets/fortran.json"