nvim/plugin-confs/null-ls.lua

132 lines
4.9 KiB
Lua
Raw Permalink Normal View History

2022-11-02 22:50:13 -07:00
local null_ls = require("null-ls")
local helpers = require("null-ls.helpers")
require("null-ls").setup({
on_attach = function(client)
if client.supports_method "textDocument/formatting" then
vim.cmd([[
augroup LspFormatting
autocmd! * <buffer>
2023-02-16 10:26:53 -08:00
autocmd BufWritePre <buffer> lua vim.lsp.buf.format()
2022-11-02 22:50:13 -07:00
augroup END
]])
end
end,
sources = {
2023-02-28 14:58:53 -08:00
-- null_ls.builtins.completion.spell,
2022-11-02 22:50:13 -07:00
null_ls.builtins.completion.luasnip,
2023-08-11 18:12:35 -07:00
-- null_ls.builtins.code_actions.gitsigns,
2022-11-02 22:50:13 -07:00
null_ls.builtins.code_actions.shellcheck,
2023-09-06 16:21:01 -07:00
null_ls.builtins.code_actions.eslint, null_ls.builtins.diagnostics.tsc,
2022-11-02 22:50:13 -07:00
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.gitlint,
2023-08-27 23:43:14 -07:00
null_ls.builtins.diagnostics.eslint
.with({ cmd = "eslint-language-server" }),
2022-11-02 22:50:13 -07:00
null_ls.builtins.diagnostics.jsonlint,
2023-08-11 18:12:35 -07:00
require("null-ls").builtins.diagnostics.luacheck,
2022-11-02 22:50:13 -07:00
null_ls.builtins.diagnostics.markdownlint,
2023-02-16 18:11:50 -08:00
-- null_ls.builtins.diagnostics.sqlfluff.with({
-- extra_args = {
-- "--dialect", "oracle"
-- }
-- }),
null_ls.builtins.formatting.sql_formatter,
2023-09-06 16:21:01 -07:00
null_ls.builtins.diagnostics.pylint, null_ls.builtins.diagnostics.mypy,
null_ls.builtins.diagnostics.pycodestyle,
2022-11-02 22:50:13 -07:00
null_ls.builtins.diagnostics.pydocstyle.with({
extra_args = { "--config=$ROOT/setup.cfg" }
2023-08-11 18:12:35 -07:00
}), null_ls.builtins.diagnostics.vint,
2022-11-02 22:50:13 -07:00
null_ls.builtins.diagnostics.shellcheck.with({
2023-08-11 18:12:35 -07:00
extra_args = {
"-s", "bash", "-o",
"add-default-case, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables"
}
}), null_ls.builtins.diagnostics.ansiblelint,
2022-11-02 22:50:13 -07:00
null_ls.builtins.formatting.json_tool,
2023-08-11 18:12:35 -07:00
require("null-ls").builtins.formatting.lua_format,
2022-11-02 22:50:13 -07:00
null_ls.builtins.formatting.markdownlint,
2023-08-11 18:12:35 -07:00
null_ls.builtins.formatting.prettier, -- handled by lsp server
2022-11-02 22:50:13 -07:00
-- require("null-ls").builtins.formatting.rustfmt,
null_ls.builtins.formatting.shfmt.with({
filetypes = { "sh", "bash" },
extra_args = { "-i", "0", "-ci", "-sr" }
2023-08-11 18:12:35 -07:00
}), null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort, null_ls.builtins.formatting.djlint
2023-04-12 22:43:41 -07:00
-- null_ls.builtins.hover.printenv
2022-11-02 22:50:13 -07:00
-- null_ls.builtins.formatting.tidy
2023-08-11 18:12:35 -07:00
}
2022-11-02 22:50:13 -07:00
})
-- local markdownlint = {
-- method = null_ls.methods.DIAGNOSTICS,
-- filetypes = { "markdown" },
-- -- null_ls.generator creates an async source
-- -- that spawns the command with the given arguments and options
-- generator = null_ls.generator({
-- command = "markdownlint",
-- args = { "--stdin" },
-- to_stdin = true,
-- from_stderr = true,
-- -- choose an output format (raw, json, or line)
-- format = "line",
-- check_exit_code = function(code, stderr)
-- local success = code <= 1
-- if not success then
-- -- can be noisy for things that run often (e.g. diagnostics), but can
-- -- be useful for things that run on demand (e.g. formatting)
-- print(stderr)
-- end
-- return success
-- end,
-- -- use helpers to parse the output from string matchers,
-- -- or parse it manually with a function
-- on_output = helpers.diagnostics.from_patterns({
-- {
-- pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]],
-- groups = { "row", "col", "message" },
-- },
-- {
-- pattern = [[:(%d+) [%w-/]+ (.*)]],
-- groups = { "row", "message" },
-- },
-- }),
-- }),
-- }
-- local shellcheck = {
-- method = null_ls.methods.DIAGNOSTICS,
-- filetypes = { "sh", "bash", "zsh", "fish" },
-- generator = null_ls.generator({
-- command = "shellcheck",
-- args = { "-s", "bash", "-o", "all", "-e", "2250" },
-- from_stderr = true,
-- format = "line",
-- check_exit_code = function(code, stderr)
-- local success = code <= 1
-- if not success then
-- -- can be noisy for things that run often (e.g. diagnostics), but can
-- -- be useful for things that run on demand (e.g. formatting)
-- print(stderr)
-- end
-- return success
-- end,
-- on_output = helpers.diagnostics.from_patterns({
-- {
-- pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]],
-- groups = { "row", "col", "message" },
-- },
-- {
-- pattern = [[:(%d+) [%w-/]+ (.*)]],
-- groups = { "row", "message" },
-- },
-- }),
-- }),
-- }
-- null_ls.register(markdownlint)
-- null_ls.register(shellcheck)