From 6403cafe921af495951dffc09d8d209cd6363f81 Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Fri, 5 Jul 2024 23:43:38 -0500 Subject: [PATCH 1/4] feat(projectionist): allow disabling the projectionist integration --- README.md | 6 +++++- lua/elixir/init.lua | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a26335f..4c4b2340 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,9 @@ Requires 0.8 vim.keymap.set("n", "tp", ":ElixirToPipe", { buffer = true, noremap = true }) vim.keymap.set("v", "em", ":ElixirExpandMacro", { buffer = true, noremap = true }) end, + }, + projectionist = { + enable = true } } end, @@ -75,7 +78,7 @@ The minimal setup will configure both ElixirLS but not Next LS. require("elixir").setup() ``` -Next LS and ElixirLS can be enabled/disabled by setting the `enable` flag in the respective options table. +Next LS, ElixirLS, and Projectionist can be enabled/disabled by setting the `enable` flag in the respective options table. The defaults are shown below. @@ -83,6 +86,7 @@ The defaults are shown below. require("elixir").setup({ nextls = {enable = false}, elixirls = {enable = true}, + projectionist = {enable = true}, }) ``` diff --git a/lua/elixir/init.lua b/lua/elixir/init.lua index 0d935462..9f7ea19a 100644 --- a/lua/elixir/init.lua +++ b/lua/elixir/init.lua @@ -89,6 +89,7 @@ function M.setup(opts) opts.elixirls = opts.elixirls or {} opts.credo = opts.credo or {} opts.nextls = opts.nextls or {} + opts.projectionist = opts.projectionist or {} define_user_command() @@ -107,7 +108,11 @@ function M.setup(opts) end mix.setup() - projectionist.setup() + + if enabled(opts.projectionist.enable) then + projectionist.setup(opts.projectionist) + end + if enabled(opts.elixirls.enable) then elixirls.setup(opts.elixirls) end From 5ebbecd8590fcd0a6f8a06b975ac731c318933c3 Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Sat, 6 Jul 2024 00:09:02 -0500 Subject: [PATCH 2/4] fix: nvim test runner breaking changes --- .github/workflows/ci.yml | 8 ++++---- justfile | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abef6118..7e4ca297 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,19 +96,19 @@ jobs: - os: ubuntu-20.04 manager: sudo apt-get packages: -y fd-find esl-erlang elixir - nvim-version: 0.8.3 + nvim-version: v0.8.3 - os: ubuntu-20.04 manager: sudo apt-get packages: -y fd-find esl-erlang elixir - nvim-version: 0.9.5 + nvim-version: v0.9.5 - os: macos-14 manager: brew packages: fd elixir - nvim-version: 0.8.3 + nvim-version: v0.8.3 - os: macos-14 manager: brew packages: fd elixir - nvim-version: 0.9.5 + nvim-version: v0.9.5 steps: - uses: actions/checkout@v4 - uses: extractions/setup-just@v2 diff --git a/justfile b/justfile index 7fb9c19d..52a4c182 100644 --- a/justfile +++ b/justfile @@ -13,7 +13,7 @@ init: deps #!/usr/bin/env bash nvim-test/bin/nvim-test --init -test nvim_version="0.9.5": init +test nvim_version="v0.9.5": init #!/usr/bin/env bash nvim-test/bin/nvim-test --target_version {{nvim_version}} busted --lpath="$PWD/lua/?.lua" From 6e7a997be7bbaa90f5e0291f760aa4e0f8cb71c0 Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Sat, 6 Jul 2024 20:19:44 -0500 Subject: [PATCH 3/4] fix(projectionist): do not overwrite existing projections --- lua/elixir/projectionist/init.lua | 2 +- tests/projectionist_spec.lua | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lua/elixir/projectionist/init.lua b/lua/elixir/projectionist/init.lua index 53dca591..20b8321d 100644 --- a/lua/elixir/projectionist/init.lua +++ b/lua/elixir/projectionist/init.lua @@ -225,7 +225,7 @@ local config = { function M.setup() local new_heuristics if vim.g.projectionist_heuristics then - new_heuristics = vim.tbl_extend("force", vim.g.projectionist_heuristics, config) + new_heuristics = vim.tbl_deep_extend("keep", vim.g.projectionist_heuristics, config) else new_heuristics = config end diff --git a/tests/projectionist_spec.lua b/tests/projectionist_spec.lua index 79fda89e..6618fd51 100644 --- a/tests/projectionist_spec.lua +++ b/tests/projectionist_spec.lua @@ -11,6 +11,30 @@ describe("projectionist", function() after_each(function() vim.cmd.cd("../../../") + vim.g.projectionist_heuristics = {} + end) + + it("does not overwrite existing projections", function() + vim.g.projectionist_heuristics = { + ["mix.exs"] = { + ["lib/*_test.ex"] = { + type = "test", + alternate = "lib/{}.ex", + }, + }, + } + + local test_projection_before_setup = vim.g.projectionist_heuristics["mix.exs"]["lib/*_test.ex"] + + require("elixir.projectionist").setup() + + local test_projection_after_setup = vim.g.projectionist_heuristics["mix.exs"]["lib/*_test.ex"] + + -- existing projections not overwritten + assert.are.same(test_projection_before_setup, test_projection_after_setup) + + -- new projections added + assert.not_nil(vim.g.projectionist_heuristics["mix.exs"]["lib/*.ex"]) end) it("Eview", function() From 61456ff20ef1c509b4fee48d1965c15891b4d0a4 Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Sat, 6 Jul 2024 20:42:04 -0500 Subject: [PATCH 4/4] chore(ci): attempt to fix CI nvim url --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e4ca297..b4483d5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: manager: sudo apt-get packages: -y fd-find esl-erlang elixir - os: macos-14 - url: https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz + url: https://github.com/neovim/neovim/releases/download/nightly/nvim-macos-x86_64.tar.gz manager: brew packages: fd elixir - os: macos-14