fix rails setup
This commit is contained in:
parent
1f2f336b64
commit
f3d84f90cd
6 changed files with 87 additions and 81 deletions
|
|
@ -4,15 +4,37 @@ if not setup then
|
|||
end
|
||||
|
||||
local formatting = null_ls.builtins.formatting
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
local conditional = function(fn)
|
||||
local utils = require("null-ls.utils").make_conditional_utils()
|
||||
return fn(utils)
|
||||
end
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
formatting.prettier,
|
||||
formatting.stylua,
|
||||
diagnostics.eslint_d,
|
||||
diagnostics.rubocop,
|
||||
|
||||
-- Here we set a conditional to call the rubocop formatter. If we have a Gemfile in the project, we call "bundle exec rubocop", if not we only call "rubocop".
|
||||
conditional(function(utils)
|
||||
return utils.root_has_file("Gemfile")
|
||||
and null_ls.builtins.formatting.rubocop.with({
|
||||
command = "bundle",
|
||||
args = vim.list_extend({ "exec", "rubocop" }, null_ls.builtins.formatting.rubocop._opts.args),
|
||||
})
|
||||
or null_ls.builtins.formatting.rubocop
|
||||
end),
|
||||
|
||||
-- Same as above, but with diagnostics.rubocop to make sure we use the proper rubocop version for the project
|
||||
conditional(function(utils)
|
||||
return utils.root_has_file("Gemfile")
|
||||
and null_ls.builtins.diagnostics.rubocop.with({
|
||||
command = "bundle",
|
||||
args = vim.list_extend({ "exec", "rubocop" }, null_ls.builtins.diagnostics.rubocop._opts.args),
|
||||
})
|
||||
or null_ls.builtins.diagnostics.rubocop
|
||||
end),
|
||||
},
|
||||
-- format on save
|
||||
on_attach = function(client, bufnr)
|
||||
|
|
@ -22,7 +44,6 @@ null_ls.setup({
|
|||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
||||
vim.lsp.buf.format({ bufnr = bufnr, timeout_ms = 10000 })
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue