Skip to content

feat(projectionist): allow disabling the projectionist integration #221

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Requires 0.8
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
end,
},
projectionist = {
enable = true
}
}
end,
Expand All @@ -75,14 +78,15 @@ 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.

```lua
require("elixir").setup({
nextls = {enable = false},
elixirls = {enable = true},
projectionist = {enable = true},
})
```

Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 6 additions & 1 deletion lua/elixir/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lua/elixir/projectionist/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/projectionist_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading