File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ local M = {}
2+
3+ function M .setup (opts )
4+ local credo = vim .api .nvim_create_augroup (" elixir-tools.credo" , { clear = true })
5+
6+ vim .api .nvim_create_autocmd ({ " FileType" }, {
7+ group = credo ,
8+ pattern = { " elixir" },
9+ 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 ]
12+
13+ local function read_file (path )
14+ local f = io.open (path , " rb" )
15+ if not f then
16+ return nil
17+ end
18+ local content = f :read (" *a" )
19+ f :close ()
20+ return content
21+ end
22+
23+ if file and not read_file (file ):find (" {:credo, " ) then
24+ file = nil
25+ end
26+
27+ vim .lsp .start {
28+ name = " Credo" ,
29+ cmd = { " mix" , " credo.lsp" , " --stdio" },
30+ settings = {},
31+ root_dir = vim .fs .dirname (file ),
32+ on_attach = opts .on_attach or function () end ,
33+ }
34+ end ,
35+ })
36+ end
37+
38+ return M
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ function M.setup(opts)
285285 vim .api .nvim_buf_set_name (elixir_nvim_output_bufnr , " ElixirLS Output Panel" )
286286 end
287287
288- local elixir_group = vim .api .nvim_create_augroup (" elixirnvim " , { clear = true })
288+ local elixir_group = vim .api .nvim_create_augroup (" elixir-tools.elixirls " , { clear = true })
289289
290290 local start_elixir_ls = function (arg )
291291 local fname = Path .new (arg .file ):absolute ()
Original file line number Diff line number Diff line change 11local elixirls = require (" elixir.elixirls" )
2+ local credo = require (" elixir.credo" )
23local mix = require (" elixir.mix" )
34local projectionist = require (" elixir.projectionist" )
45
@@ -12,7 +13,10 @@ M.elixirls.open_output_panel = elixirls.open_output_panel
1213function M .setup (opts )
1314 mix .setup ()
1415 projectionist .setup ()
15- elixirls .setup (opts [" elixirls" ] or {})
16+ elixirls .setup (opts .elixirls or {})
17+ if opts .credo then
18+ credo .setup (opts .credo )
19+ end
1620end
1721
1822return M
You can’t perform that action at this time.
0 commit comments