2021-07-15 00:50:07 +02:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
M.config = function()
|
2021-07-15 03:14:25 +02:00
|
|
|
O.lang.ruby = {
|
|
|
|
diagnostics = {
|
|
|
|
virtualtext = { spacing = 0, prefix = "" },
|
|
|
|
signs = true,
|
|
|
|
underline = true,
|
|
|
|
},
|
|
|
|
filetypes = { "rb", "erb", "rakefile", "ruby" },
|
|
|
|
formatter = {
|
|
|
|
exe = "rufo",
|
|
|
|
args = { "-x" },
|
2021-07-17 08:32:17 +02:00
|
|
|
stdin = true,
|
2021-07-15 03:14:25 +02:00
|
|
|
},
|
2021-07-17 00:30:38 +02:00
|
|
|
linters = { "ruby" },
|
2021-07-15 03:14:25 +02:00
|
|
|
}
|
2021-07-15 00:50:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
M.format = function()
|
|
|
|
O.formatters.filetype["ruby"] = {
|
|
|
|
function()
|
|
|
|
return {
|
|
|
|
exe = O.lang.ruby.formatter.exe,
|
|
|
|
args = O.lang.ruby.formatter.args,
|
2021-07-17 08:32:17 +02:00
|
|
|
stdin = O.lang.ruby.formatter.stdin,
|
2021-07-15 00:50:07 +02:00
|
|
|
}
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
require("formatter.config").set_defaults {
|
|
|
|
logging = false,
|
|
|
|
filetype = O.formatters.filetype,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
M.lint = function()
|
2021-07-17 00:30:38 +02:00
|
|
|
require("lint").linters_by_ft = {
|
|
|
|
ruby = O.lang.ruby.linters,
|
|
|
|
}
|
2021-07-15 00:50:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
M.lsp = function()
|
|
|
|
if require("lv-utils").check_lsp_client_active "solargraph" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- If you are using rvm, make sure to change below configuration
|
|
|
|
require("lspconfig").solargraph.setup {
|
|
|
|
cmd = { DATA_PATH .. "/lspinstall/ruby/solargraph/solargraph", "stdio" },
|
|
|
|
on_attach = require("lsp").common_on_attach,
|
|
|
|
handlers = {
|
|
|
|
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
|
|
virtual_text = O.lang.ruby.diagnostics.virtual_text,
|
|
|
|
signs = O.lang.ruby.diagnostics.signs,
|
|
|
|
underline = O.lang.ruby.diagnostics.underline,
|
|
|
|
update_in_insert = true,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
filetypes = O.lang.ruby.filetypes,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
M.dap = function()
|
|
|
|
-- TODO: implement dap
|
|
|
|
return "No DAP configured!"
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|