summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lang/elixir.lua
blob: 0959809f3cd90c2be8e7ee5fe08c0d334bb78c3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
local M = {}

M.config = function()
  O.lang.elixir = {
    formatter = {
      exe = "mix",
      args = { "format" },
      stdin = true,
    },
    lsp = {
      path = DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh",
    },
  }
end

M.format = function()
  O.formatters.filetype["elixir"] = {
    function()
      return {
        exe = O.lang.elixir.formatter.exe,
        args = O.lang.elixir.formatter.args,
        stdin = O.lang.elixir.formatter.stdin,
      }
    end,
  }

  require("formatter.config").set_defaults {
    logging = false,
    filetype = O.formatters.filetype,
  }
end

M.lint = function()
  -- TODO: implement linters (if applicable)
  return "No linters configured!"
end

M.lsp = function()
  if require("utils").check_lsp_client_active "elixirls" then
    return
  end

  require("lspconfig").elixirls.setup {
    cmd = { O.lang.elixir.lsp.path },
    on_attach = require("lsp").common_on_attach,
  }
end

M.dap = function()
  -- TODO: implement dap
  return "No DAP configured!"
end

-- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir)
-- vim.cmd [[
--   au BufRead,BufNewFile *.ex,*.exs set filetype=elixir
--   au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir
--   au BufRead,BufNewFile mix.lock set filetype=elixir
-- ]]

return M