This commit is contained in:
Snoweuph 2026-05-10 21:51:23 +02:00 committed by GitHub
commit 17db12e9fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 76 additions and 4 deletions

View file

@ -388,6 +388,8 @@
- Fix `languages.ts` registration of formatters.
- Added `asmfmt` and `nasmfmt` formatters to `languages.asm`.
- Added `biome-check` and `biome-organize-imports` formatters to `languages.ts`.
- Added [`biomejs`](https://biomejs.dev/) as extra diagnostics provider to

View file

@ -4,15 +4,37 @@
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) enum listOf;
inherit (builtins) attrNames;
inherit (lib) genAttrs;
inherit (lib.generators) mkLuaInline;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) enum listOf;
cfg = config.vim.languages.assembly;
defaultServers = ["asm-lsp"];
servers = ["asm-lsp"];
defaultFormat = ["asmfmt"];
formats = {
asmfmt = {
command = getExe pkgs.asmfmt;
};
nasmfmt = {
command = getExe pkgs.nasmfmt;
args = mkLuaInline ''
function(self, ctx)
return {
"--ii", ctx.shiftwidth,
"$FILENAME",
}
end
'';
};
};
in {
options.vim.languages.assembly = {
enable = mkEnableOption "Assembly support";
@ -42,6 +64,20 @@ in {
description = "Assembly LSP server to use";
};
};
format = {
enable =
mkEnableOption "Assembly formatting"
// {
default = config.vim.languages.enableFormat;
defaultText = literalExpression "config.vim.languages.enableFormat";
};
type = mkOption {
type = listOf (enum (attrNames formats));
default = defaultFormat;
description = "Assembly formatter to use";
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
@ -57,9 +93,43 @@ in {
vim.lsp = {
presets = genAttrs cfg.lsp.servers (_: {enable = true;});
servers = genAttrs cfg.lsp.servers (_: {
filetypes = ["asm" "nasm" "masm" "vmasm" "fasm" "tasm" "tiasm" "asm68k" "asm8300"];
filetypes = [
"asm"
"nasm"
"masm"
"vmasm"
"fasm"
"tasm"
"tiasm"
"asm68k"
"asmh8300"
];
});
};
})
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts = {
formatters_by_ft = {
asm = cfg.format.type;
nasm = cfg.format.type;
masm = cfg.format.type;
vmasm = cfg.format.type;
tasm = cfg.format.type;
tiasm = cfg.format.type;
asm68k = cfg.format.type;
asmh8300 = cfg.format.type;
};
formatters =
mapListToAttrs (name: {
inherit name;
value = formats.${name};
})
cfg.format.type;
};
};
})
]);
}