elixir.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. local M = {}
  2. M.config = function()
  3. O.lang.elixir = {
  4. formatter = {
  5. exe = "mix",
  6. args = { "format" },
  7. stdin = true,
  8. },
  9. lsp = {
  10. path = DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh",
  11. },
  12. }
  13. end
  14. M.format = function()
  15. O.formatters.filetype["elixir"] = {
  16. function()
  17. return {
  18. exe = O.lang.elixir.formatter.exe,
  19. args = O.lang.elixir.formatter.args,
  20. stdin = O.lang.elixir.formatter.stdin,
  21. }
  22. end,
  23. }
  24. require("formatter.config").set_defaults {
  25. logging = false,
  26. filetype = O.formatters.filetype,
  27. }
  28. end
  29. M.lint = function()
  30. -- TODO: implement linters (if applicable)
  31. return "No linters configured!"
  32. end
  33. M.lsp = function()
  34. if require("lv-utils").check_lsp_client_active "elixirls" then
  35. return
  36. end
  37. require("lspconfig").elixirls.setup {
  38. cmd = { O.lang.elixir.lsp.path },
  39. on_attach = require("lsp").common_on_attach,
  40. }
  41. end
  42. M.dap = function()
  43. -- TODO: implement dap
  44. return "No DAP configured!"
  45. end
  46. -- needed for the LSP to recognize elixir files (alternativly just use elixir-editors/vim-elixir)
  47. -- vim.cmd [[
  48. -- au BufRead,BufNewFile *.ex,*.exs set filetype=elixir
  49. -- au BufRead,BufNewFile *.eex,*.leex,*.sface set filetype=eelixir
  50. -- au BufRead,BufNewFile mix.lock set filetype=elixir
  51. -- ]]
  52. return M