Skip to content

Commit 057f6e5

Browse files
authored
feat(projectionist): allow disabling the projectionist integration (#221)
fix: nvim test runner breaking changes fix(projectionist): do not overwrite existing projections chore(ci): attempt to fix CI nvim url
1 parent 66ccac7 commit 057f6e5

File tree

6 files changed

+42
-9
lines changed

6 files changed

+42
-9
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
manager: sudo apt-get
4343
packages: -y fd-find esl-erlang elixir
4444
- os: macos-14
45-
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz
45+
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-macos-x86_64.tar.gz
4646
manager: brew
4747
packages: fd elixir
4848
- os: macos-14
@@ -96,19 +96,19 @@ jobs:
9696
- os: ubuntu-20.04
9797
manager: sudo apt-get
9898
packages: -y fd-find esl-erlang elixir
99-
nvim-version: 0.8.3
99+
nvim-version: v0.8.3
100100
- os: ubuntu-20.04
101101
manager: sudo apt-get
102102
packages: -y fd-find esl-erlang elixir
103-
nvim-version: 0.9.5
103+
nvim-version: v0.9.5
104104
- os: macos-14
105105
manager: brew
106106
packages: fd elixir
107-
nvim-version: 0.8.3
107+
nvim-version: v0.8.3
108108
- os: macos-14
109109
manager: brew
110110
packages: fd elixir
111-
nvim-version: 0.9.5
111+
nvim-version: v0.9.5
112112
steps:
113113
- uses: actions/checkout@v4
114114
- uses: extractions/setup-just@v2

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ Requires 0.8
5050
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
5151
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
5252
end,
53+
},
54+
projectionist = {
55+
enable = true
5356
}
5457
}
5558
end,
@@ -75,14 +78,15 @@ The minimal setup will configure both ElixirLS but not Next LS.
7578
require("elixir").setup()
7679
```
7780

78-
Next LS and ElixirLS can be enabled/disabled by setting the `enable` flag in the respective options table.
81+
Next LS, ElixirLS, and Projectionist can be enabled/disabled by setting the `enable` flag in the respective options table.
7982

8083
The defaults are shown below.
8184

8285
```lua
8386
require("elixir").setup({
8487
nextls = {enable = false},
8588
elixirls = {enable = true},
89+
projectionist = {enable = true},
8690
})
8791
```
8892

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ init: deps
1313
#!/usr/bin/env bash
1414
nvim-test/bin/nvim-test --init
1515

16-
test nvim_version="0.9.5": init
16+
test nvim_version="v0.9.5": init
1717
#!/usr/bin/env bash
1818
nvim-test/bin/nvim-test --target_version {{nvim_version}} busted --lpath="$PWD/lua/?.lua"
1919

lua/elixir/init.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function M.setup(opts)
8989
opts.elixirls = opts.elixirls or {}
9090
opts.credo = opts.credo or {}
9191
opts.nextls = opts.nextls or {}
92+
opts.projectionist = opts.projectionist or {}
9293

9394
define_user_command()
9495

@@ -107,7 +108,11 @@ function M.setup(opts)
107108
end
108109

109110
mix.setup()
110-
projectionist.setup()
111+
112+
if enabled(opts.projectionist.enable) then
113+
projectionist.setup(opts.projectionist)
114+
end
115+
111116
if enabled(opts.elixirls.enable) then
112117
elixirls.setup(opts.elixirls)
113118
end

lua/elixir/projectionist/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ local config = {
225225
function M.setup()
226226
local new_heuristics
227227
if vim.g.projectionist_heuristics then
228-
new_heuristics = vim.tbl_extend("force", vim.g.projectionist_heuristics, config)
228+
new_heuristics = vim.tbl_deep_extend("keep", vim.g.projectionist_heuristics, config)
229229
else
230230
new_heuristics = config
231231
end

tests/projectionist_spec.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@ describe("projectionist", function()
1111

1212
after_each(function()
1313
vim.cmd.cd("../../../")
14+
vim.g.projectionist_heuristics = {}
15+
end)
16+
17+
it("does not overwrite existing projections", function()
18+
vim.g.projectionist_heuristics = {
19+
["mix.exs"] = {
20+
["lib/*_test.ex"] = {
21+
type = "test",
22+
alternate = "lib/{}.ex",
23+
},
24+
},
25+
}
26+
27+
local test_projection_before_setup = vim.g.projectionist_heuristics["mix.exs"]["lib/*_test.ex"]
28+
29+
require("elixir.projectionist").setup()
30+
31+
local test_projection_after_setup = vim.g.projectionist_heuristics["mix.exs"]["lib/*_test.ex"]
32+
33+
-- existing projections not overwritten
34+
assert.are.same(test_projection_before_setup, test_projection_after_setup)
35+
36+
-- new projections added
37+
assert.not_nil(vim.g.projectionist_heuristics["mix.exs"]["lib/*.ex"])
1438
end)
1539

1640
it("Eview", function()

0 commit comments

Comments
 (0)