Add pre 0.6 support for null-ls

This commit is contained in:
ViViDboarder 2022-01-02 22:13:15 -08:00
parent 5543af4bbc
commit 150a9b36d8
2 changed files with 46 additions and 31 deletions

View File

@ -16,15 +16,17 @@ local function config_dark_notify()
}) })
end end
-- Pin version dependent packages -- Pin version dependent packages due to unstable APIs
local pinned_commits = {} local pinned_commits = {}
if vim.fn.has("nvim-0.6.0") ~= 1 then if vim.fn.has("nvim-0.6.0") ~= 1 then
if vim.fn.has("nvim-0.5.1") == 1 then if vim.fn.has("nvim-0.5.1") == 1 then
-- Last commit compatible with 0.5.1 -- Last commit compatible with 0.5.1
pinned_commits["telescope"] = "80cdb00b221f69348afc4fb4b701f51eb8dd3120" pinned_commits["telescope"] = "80cdb00b221f69348afc4fb4b701f51eb8dd3120"
pinned_commits["null-ls"] = "739a98c12bedaa2430c4a3c08d1d22ad6c16513e"
elseif vim.fn.has("nvim-0.5.0") == 1 then elseif vim.fn.has("nvim-0.5.0") == 1 then
-- Last commit compatible with 0.5.1 -- Last commit compatible with 0.5.0
pinned_commits["telescope"] = "587a10d1494d8ffa1229246228f0655db2f0a48a" pinned_commits["telescope"] = "587a10d1494d8ffa1229246228f0655db2f0a48a"
pinned_commits["null-ls"] = "3e7390735501d0507bf2c2b5c2e7a16f58deeb81"
end end
end end
@ -201,6 +203,7 @@ return require("packer").startup({
-- Generic linter/formatters in diagnostics API -- Generic linter/formatters in diagnostics API
use({ use({
"jose-elias-alvarez/null-ls.nvim", "jose-elias-alvarez/null-ls.nvim",
commit = pinned_commits["null-ls"],
requires = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, requires = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
}) })

View File

@ -176,35 +176,47 @@ end
function M.config_null_ls() function M.config_null_ls()
utils.try_require("null-ls", function(null_ls) utils.try_require("null-ls", function(null_ls)
null_ls.setup({ local sources = {
on_attach = default_attach, -- Generic
capabilities = merged_capabilities(), -- null_ls.builtins.formatting.preittier,
sources = { -- null_ls.builtins.formatting.trim_whitespace,
-- Generic -- null_ls.builtins.formatting.trim_newlines,
-- null_ls.builtins.formatting.preittier, -- Fish
-- null_ls.builtins.formatting.trim_whitespace, -- null_ls.builtins.formatting.fish_indent,
-- null_ls.builtins.formatting.trim_newlines, -- Python
-- Fish null_ls.builtins.formatting.reorder_python_imports,
-- null_ls.builtins.formatting.fish_indent, null_ls.builtins.formatting.black,
-- Python null_ls.builtins.diagnostics.mypy,
null_ls.builtins.formatting.reorder_python_imports, -- Go
null_ls.builtins.formatting.black, null_ls.builtins.diagnostics.golangci_lint,
null_ls.builtins.diagnostics.mypy, -- Text
-- Go -- null_ls.builtins.code_actions.proselint,
null_ls.builtins.diagnostics.golangci_lint, -- Ansible
-- Text -- null_ls.builtins.diagnostics.ansiblelint,
-- null_ls.builtins.code_actions.proselint, -- Shell
-- Ansible null_ls.builtins.diagnostics.shellcheck,
-- null_ls.builtins.diagnostics.ansiblelint, -- Rust
-- Shell -- null_ls.builtins.formatting.rustfmt,
null_ls.builtins.diagnostics.shellcheck, -- Lua
-- Rust null_ls.builtins.diagnostics.luacheck,
-- null_ls.builtins.formatting.rustfmt, null_ls.builtins.formatting.stylua,
-- Lua }
null_ls.builtins.diagnostics.luacheck,
null_ls.builtins.formatting.stylua, -- HACK: Handle old versions of null_ls for vim < 0.6 that don't support `setup`
}, if null_ls["setup"] ~= nil then
}) null_ls.setup({
on_attach = default_attach,
capabilities = merged_capabilities(),
sources = sources,
})
else
null_ls.config({
sources = sources,
})
require("lspconfig")["null-ls"].setup({
on_attach = default_attach,
})
end
end) end)
end end