Skip to content

Commit 86bda38

Browse files
authored
fix(credo): correctly handle umbrella apps and monorepos (#77)
Closes #70 Closes #76
1 parent 7de5655 commit 86bda38

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

bin/credo-language-server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
System.no_halt(true)
44

5-
{%{credo: {_, :credo, credo_version, _, _, _, _, _}}, _} = Code.eval_file("./mix.lock")
5+
{%{credo: {_, :credo, credo_version, _, _, _, _, _}}, _} = Code.eval_file(System.get_env("CREDO_MIX_LOCK_PATH", "./mix.lock"))
66

77
Mix.install([
88
{:credo_language_server, "0.0.4"},

lua/elixir/credo/init.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ function M.setup(opts)
77
group = credo,
88
pattern = { "elixir" },
99
callback = function()
10-
local file =
11-
vim.fs.find({ "mix.exs" }, { upward = true, path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)) })[1]
10+
local matches = vim.fs.find({ "mix.lock" }, {
11+
stop = vim.loop.os_homedir(),
12+
upward = true,
13+
path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
14+
})
15+
16+
local file = nil
1217

1318
local function read_file(path)
1419
local f = io.open(path, "rb")
@@ -20,8 +25,11 @@ function M.setup(opts)
2025
return content
2126
end
2227

23-
if file and not read_file(file):find("{:credo, ") then
24-
file = nil
28+
for _, f in ipairs(matches) do
29+
if f and read_file(f):find([["credo": {]]) then
30+
file = f
31+
break
32+
end
2533
end
2634

2735
if file then
@@ -35,6 +43,7 @@ function M.setup(opts)
3543
vim.lsp.start {
3644
name = "Credo",
3745
cmd = cmd,
46+
cmd_env = { CREDO_MIX_LOCK_PATH = file },
3847
settings = {},
3948
root_dir = vim.fs.dirname(file),
4049
on_attach = opts.on_attach or function() end,

0 commit comments

Comments
 (0)