From 8d289ad3de39adb4b7eba87b08c3805c2bf40057 Mon Sep 17 00:00:00 2001 From: Stefan Bradl Date: Fri, 13 Feb 2026 16:51:55 +0100 Subject: [PATCH] feat: add elixir --- README.md | 2 ++ lua/code-playground/commands.lua | 16 ++++++++++++ lua/code-playground/languages/elixir.lua | 26 +++++++++++++++++++ lua/code-playground/templates/elixir/main.exs | 1 + 4 files changed, 45 insertions(+) create mode 100644 lua/code-playground/languages/elixir.lua create mode 100644 lua/code-playground/templates/elixir/main.exs diff --git a/README.md b/README.md index cc85006..34e8b5c 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Currently, the plugin supports the following languages: - Go - Odin - Haskell +- Elixir More languages will be supported in future updates! @@ -104,6 +105,7 @@ This will destroy the workspace and reinitialize it. Code fsharp Code odin Code haskell + Code elixir ``` ## Configuration diff --git a/lua/code-playground/commands.lua b/lua/code-playground/commands.lua index 3e63e5f..2b9d1ac 100644 --- a/lua/code-playground/commands.lua +++ b/lua/code-playground/commands.lua @@ -5,6 +5,7 @@ local java = require("code-playground.languages.java") local zig = require("code-playground.languages.zig") local typescript = require("code-playground.languages.typescript") local fsharp = require("code-playground.languages.fsharp") +local elixir = require("code-playground.languages.elixir") local options_manager = require("code-playground.options") local animation = require("code-playground.animations") @@ -305,4 +306,19 @@ M.zig = { }, } +M.elixir = { + handle = function() + local def = elixir.run() + open_workspace(def.file, def.command) + end, + subcommands = { + reset = { + handle = function() + elixir.reset() + M.elixir.handle("", {}) + end, + }, + }, +} + return M diff --git a/lua/code-playground/languages/elixir.lua b/lua/code-playground/languages/elixir.lua new file mode 100644 index 0000000..4237429 --- /dev/null +++ b/lua/code-playground/languages/elixir.lua @@ -0,0 +1,26 @@ +local fileutils = require("code-playground.file-utils") +local root_path = vim.fs.joinpath(vim.fn.stdpath("data"), "code-playground") +local elixir_folder = vim.fs.joinpath(root_path, "elixir") +local main_exs = vim.fs.joinpath(elixir_folder, "main.exs") + +local M = {} + +local function ensure_files() + fileutils.ensure_directory_exists(elixir_folder) + fileutils.ensure_file_exists(main_exs, "elixir/main.exs") +end + +---@return Run +M.run = function() + ensure_files() + return { + file = main_exs, + command = string.format("elixir %s", main_exs), + } +end + +M.reset = function() + vim.fn.delete(elixir_folder, "rf") +end + +return M diff --git a/lua/code-playground/templates/elixir/main.exs b/lua/code-playground/templates/elixir/main.exs new file mode 100644 index 0000000..5e6bd55 --- /dev/null +++ b/lua/code-playground/templates/elixir/main.exs @@ -0,0 +1 @@ +IO.puts("Hello World!")