This commit is contained in:
sharings 2025-07-26 12:43:01 +00:00
commit 1e2ca5a6fc
71 changed files with 3330 additions and 0 deletions

View file

@ -0,0 +1,152 @@
{
lib,
config,
helpers,
pkgs,
...
}:
let
inherit (helpers) mkRaw;
in
{
plugins = {
# https://github.com/stevearc/conform.nvim/
# Preserves extmarks and folds
# Fixes bad-behaving LSP formatters
# Enables range formatting for all formatters
# And more
conform-nvim = {
enable = lib.mkIf config.plugins.lsp.enable true;
settings = {
formatters_by_ft = {
perl = [ "perltidy" ];
# nix = ["nixfmt" "alejandra"];
nix = [ "nixfmt" ];
sh = [
"shellcheck"
"shellharden"
"shfmt"
];
bash = [
"shellcheck"
"shellharden"
"shfmt"
];
cpp = [ "clang_format" ];
javascript = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
timeout_ms = 2000;
stop_after_first = true;
};
lua = [ "stylua" ];
# -- Conform will run multiple formatters sequentially
python = [
"isort"
"black"
];
# -- You can customize some of the format options for the filetype (:help conform.format)
rust = {
_unkeyed-1 = "rustfmt";
lsp_format = "fallback";
};
tex = [ "latexindent" ];
# Use the "_" filetype to run formatters on filetypes that don't
# have other formatters configured.
"_" = [
"squeeze_blanks"
"trim_whitespace"
"trim_newlines"
];
};
# format_on_save =
# # Lua
# ''
# function(bufnr)
# if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
# return
# end
#
# if slow_format_filetypes[vim.bo[bufnr].filetype] then
# return
# end
#
# local function on_format(err)
# if err and err:match("timeout$") then
# slow_format_filetypes[vim.bo[bufnr].filetype] = true
# end
# end
#
# return { timeout_ms = 200, lsp_fallback = true }, on_format
# end
# '';
# format_after_save =
# # Lua
# ''
# function(bufnr)
# if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
# return
# end
#
# if not slow_format_filetypes[vim.bo[bufnr].filetype] then
# return
# end
#
# return { lsp_fallback = true }
# end
# '';
log_level = "warn";
notify_on_error = true;
notify_no_formatters = true;
formatters = {
perltidy = {
command = lib.getExe pkgs.perlPackages.PerlTidy;
prepend_args = [ "-i=2" ]; # default 4 spaces
};
shfmt = {
command = lib.getExe pkgs.shfmt;
};
shellcheck = {
command = lib.getExe pkgs.shellcheck;
};
shellharden = {
command = lib.getExe pkgs.shellharden;
};
squeeze_blanks = {
command = lib.getExe' pkgs.coreutils "cat";
};
latexindent = {
command = lib.getExe' pkgs.texlivePackages.latexindent "latexindent";
# latexindent always produce indent.log in the current directory. It cannot be disabled in indentconfig.yaml
# This flag redirect it to /dev/null
prepend_args = [
"-g"
"/dev/null"
];
};
# alejandra = {
# command = lib.getExe pkgs.alejandra;
# prepend_args = ["--quiet"];
# };
nixfmt = {
command = lib.getExe pkgs.nixfmt-rfc-style;
};
stylua = {
command = lib.getExe pkgs.stylua;
};
};
};
};
};
keymaps = [
{
mode = [ "n" ];
key = "<leader>lf";
action = mkRaw ''
function()
require("conform").format()
end'';
options.desc = "Format with conform-nvim";
}
];
}