home: vim: only use 'null-ls' sources if available

This avoids the big red warning on each file that tries to use those
sources...
This commit is contained in:
Bruno BELANYI 2022-02-28 11:31:26 +01:00
parent 8155f6be4c
commit fb49a1df14
6 changed files with 50 additions and 6 deletions

View file

@ -4,17 +4,23 @@ call ftplugined#check_undo_ft()
" Set-up LSP, linters, formatters " Set-up LSP, linters, formatters
lua << EOF lua << EOF
local null_ls = require("null-ls") local null_ls = require("null-ls")
local utils = require("ambroisie.utils")
null_ls.register({ null_ls.register({
null_ls.builtins.diagnostics.shellcheck.with({ null_ls.builtins.diagnostics.shellcheck.with({
-- Show error code in message -- Show error code in message
diagnostics_format = "[#{c}] #{m}", diagnostics_format = "[#{c}] #{m}",
-- Require explicit empty string test, use bash dialect -- Require explicit empty string test, use bash dialect
extra_args = { "-s", "bash", "-o", "avoid-nullary-conditions" }, extra_args = { "-s", "bash", "-o", "avoid-nullary-conditions" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}), }),
null_ls.builtins.formatting.shfmt.with({ null_ls.builtins.formatting.shfmt.with({
-- Indent with 4 spaces, simplify the code, indent switch cases, -- Indent with 4 spaces, simplify the code, indent switch cases,
-- add space after redirection, use bash dialect -- add space after redirection, use bash dialect
extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "bash" }, extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "bash" },
-- Only used if available
condition = utils.is_executable_condition("shfmt"),
}), }),
}) })
EOF EOF

View file

@ -4,8 +4,13 @@ call ftplugined#check_undo_ft()
" Set-up LSP, linters, formatters " Set-up LSP, linters, formatters
lua << EOF lua << EOF
local null_ls = require("null-ls") local null_ls = require("null-ls")
local utils = require("ambroisie.utils")
null_ls.register({ null_ls.register({
null_ls.builtins.formatting.brittany, null_ls.builtins.formatting.brittany.with({
-- Only used if available
condition = utils.is_executable_condition("brittany"),
}),
}) })
EOF EOF

View file

@ -4,7 +4,12 @@ call ftplugined#check_undo_ft()
" Set-up LSP, linters, formatters " Set-up LSP, linters, formatters
lua << EOF lua << EOF
local null_ls = require("null-ls") local null_ls = require("null-ls")
local utils = require("ambroisie.utils")
null_ls.register({ null_ls.register({
null_ls.builtins.formatting.nixpkgs_fmt, null_ls.builtins.formatting.nixpkgs_fmt.with({
-- Only used if available
condition = utils.is_executable_condition("nixpkgs-fmt"),
}),
}) })
EOF EOF

View file

@ -4,14 +4,30 @@ call ftplugined#check_undo_ft()
" Set-up LSP, linters, formatters " Set-up LSP, linters, formatters
lua << EOF lua << EOF
local null_ls = require("null-ls") local null_ls = require("null-ls")
local utils = require("ambroisie.utils")
null_ls.register({ null_ls.register({
null_ls.builtins.diagnostics.flake8, null_ls.builtins.diagnostics.flake8.with({
null_ls.builtins.diagnostics.mypy, -- Only used if available
null_ls.builtins.diagnostics.pylint, condition = utils.is_executable_condition("flake8"),
}),
null_ls.builtins.diagnostics.mypy.with({
-- Only used if available
condition = utils.is_executable_condition("mypy"),
}),
null_ls.builtins.diagnostics.pylint.with({
-- Only used if available
condition = utils.is_executable_condition("pylint"),
})
null_ls.builtins.formatting.black.with({ null_ls.builtins.formatting.black.with({
extra_args = { "--fast" }, extra_args = { "--fast" },
-- Only used if available
condition = utils.is_executable_condition("black"),
}),
null_ls.builtins.formatting.isort.with({
-- Only used if available
condition = utils.is_executable_condition("isort"),
}), }),
null_ls.builtins.formatting.isort,
}) })
EOF EOF

View file

@ -4,17 +4,23 @@ call ftplugined#check_undo_ft()
" Set-up LSP, linters, formatters " Set-up LSP, linters, formatters
lua << EOF lua << EOF
local null_ls = require("null-ls") local null_ls = require("null-ls")
local utils = require("ambroisie.utils")
null_ls.register({ null_ls.register({
null_ls.builtins.diagnostics.shellcheck.with({ null_ls.builtins.diagnostics.shellcheck.with({
-- Show error code in message -- Show error code in message
diagnostics_format = "[#{c}] #{m}", diagnostics_format = "[#{c}] #{m}",
-- Require explicit empty string test -- Require explicit empty string test
extra_args = { "-o", "avoid-nullary-conditions" }, extra_args = { "-o", "avoid-nullary-conditions" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}), }),
null_ls.builtins.formatting.shfmt.with({ null_ls.builtins.formatting.shfmt.with({
-- Indent with 4 spaces, simplify the code, indent switch cases, -- Indent with 4 spaces, simplify the code, indent switch cases,
-- add space after redirection, use POSIX -- add space after redirection, use POSIX
extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "posix" }, extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "posix" },
-- Only used if available
condition = utils.is_executable_condition("shfmt"),
}), }),
}) })
EOF EOF

View file

@ -4,17 +4,23 @@ call ftplugined#check_undo_ft()
" Set-up LSP, linters, formatters " Set-up LSP, linters, formatters
lua << EOF lua << EOF
local null_ls = require("null-ls") local null_ls = require("null-ls")
local utils = require("ambroisie.utils")
null_ls.register({ null_ls.register({
null_ls.builtins.diagnostics.shellcheck.with({ null_ls.builtins.diagnostics.shellcheck.with({
-- Show error code in message -- Show error code in message
diagnostics_format = "[#{c}] #{m}", diagnostics_format = "[#{c}] #{m}",
-- Require explicit empty string test, use bash dialect -- Require explicit empty string test, use bash dialect
extra_args = { "-s", "bash", "-o", "avoid-nullary-conditions" }, extra_args = { "-s", "bash", "-o", "avoid-nullary-conditions" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}), }),
null_ls.builtins.formatting.shfmt.with({ null_ls.builtins.formatting.shfmt.with({
-- Indent with 4 spaces, simplify the code, indent switch cases, -- Indent with 4 spaces, simplify the code, indent switch cases,
-- add space after redirection, use bash dialect -- add space after redirection, use bash dialect
extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "bash" }, extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "bash" },
-- Only used if available
condition = utils.is_executable_condition("shfmt"),
}), }),
}) })
EOF EOF