complete refactor with kickstart.nvim
This commit is contained in:
parent
f3d84f90cd
commit
897d00ad32
16 changed files with 571 additions and 404 deletions
|
|
@ -9,9 +9,24 @@ local conditional = function(fn)
|
|||
return fn(utils)
|
||||
end
|
||||
|
||||
local lsp_formatting = function(bufnr)
|
||||
vim.lsp.buf.format({
|
||||
timeout_ms = 2000,
|
||||
filter = function(client)
|
||||
-- apply whatever logic you want (in this example, we'll only use null-ls)
|
||||
return client.name ~= "tsserver"
|
||||
end,
|
||||
bufnr = bufnr,
|
||||
})
|
||||
end
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
-- local my_rubocop_formatter = require("rahcodes.null-ls.rubocop")
|
||||
local rubocop = null_ls.builtins.formatting.rubocop
|
||||
|
||||
null_ls.setup({
|
||||
debug = true,
|
||||
sources = {
|
||||
formatting.prettier,
|
||||
formatting.stylua,
|
||||
|
|
@ -19,20 +34,20 @@ null_ls.setup({
|
|||
-- 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
|
||||
and rubocop.with({
|
||||
command = "bundle",
|
||||
args = vim.list_extend({ "exec", "rubocop" }, rubocop._opts.args),
|
||||
})
|
||||
or 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),
|
||||
})
|
||||
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),
|
||||
},
|
||||
|
|
@ -44,7 +59,7 @@ null_ls.setup({
|
|||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr, timeout_ms = 10000 })
|
||||
lsp_formatting(bufnr)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue