ruby.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. local M = {}
  2. M.config = function()
  3. O.lang.ruby = {
  4. diagnostics = {
  5. virtualtext = { spacing = 0, prefix = "" },
  6. signs = true,
  7. underline = true,
  8. },
  9. filetypes = { "rb", "erb", "rakefile", "ruby" },
  10. formatter = {
  11. exe = "rufo",
  12. args = { "-x" },
  13. },
  14. }
  15. end
  16. M.format = function()
  17. O.formatters.filetype["ruby"] = {
  18. function()
  19. return {
  20. exe = O.lang.ruby.formatter.exe,
  21. args = O.lang.ruby.formatter.args,
  22. stdin = not (O.lang.ruby.formatter.stdin ~= nil),
  23. }
  24. end,
  25. }
  26. require("formatter.config").set_defaults {
  27. logging = false,
  28. filetype = O.formatters.filetype,
  29. }
  30. end
  31. M.lint = function()
  32. -- TODO: implement linters (if applicable)
  33. return "No linters configured!"
  34. end
  35. M.lsp = function()
  36. if require("lv-utils").check_lsp_client_active "solargraph" then
  37. return
  38. end
  39. -- If you are using rvm, make sure to change below configuration
  40. require("lspconfig").solargraph.setup {
  41. cmd = { DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph", "stdio" },
  42. on_attach = require("lsp").common_on_attach,
  43. handlers = {
  44. ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
  45. virtual_text = O.lang.ruby.diagnostics.virtual_text,
  46. signs = O.lang.ruby.diagnostics.signs,
  47. underline = O.lang.ruby.diagnostics.underline,
  48. update_in_insert = true,
  49. }),
  50. },
  51. filetypes = O.lang.ruby.filetypes,
  52. }
  53. end
  54. M.dap = function()
  55. -- TODO: implement dap
  56. return "No DAP configured!"
  57. end
  58. return M