feat: Use oxfmt to reformat json/yaml/toml/markdown

This commit is contained in:
ulic-youthlic 2026-02-10 12:45:34 +08:00
parent e85da11b65
commit 4b00734efe
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
5 changed files with 50 additions and 66 deletions

3
.oxfmtrc.json Normal file
View file

@ -0,0 +1,3 @@
{
"ignorePatterns": ["_sources/*.json", "secrets/*.yaml"]
}

View file

@ -7,6 +7,38 @@
"arguments": ["-"]
}
}
},
"JSON": {
"formatter": {
"external": {
"command": "oxfmt",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
},
"Markdown": {
"formatter": {
"external": {
"command": "oxfmt",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
},
"YAML": {
"formatter": {
"external": {
"command": "oxfmt",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
},
"TOML": {
"formatter": {
"external": {
"command": "oxfmt",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
}
}
}

View file

@ -33,6 +33,7 @@
just
nvfetcher
alejandra
oxfmt
lua-language-server
];

View file

@ -29,36 +29,12 @@ patch:
- { when: has_menu, accept: minus, send: Page_Up }
- { when: has_menu, accept: equal, send: Page_Down }
- {
when: always,
toggle: ascii_punct,
accept: Control+Shift+3,
} # 切换中英标点
- {
when: always,
toggle: ascii_punct,
accept: Control+Shift+numbersign,
} # 切换中英标点
- {
when: always,
toggle: traditionalization,
accept: Control+Shift+4,
} # 切换简繁
- {
when: always,
toggle: traditionalization,
accept: Control+Shift+dollar,
} # 切换简繁
- {
when: always,
toggle: full_shape,
accept: Control+Shift+5,
} # 切换全半角
- {
when: always,
toggle: full_shape,
accept: Control+Shift+percent,
} # 切换全半角
- { when: always, toggle: ascii_punct, accept: Control+Shift+3 } # 切换中英标点
- { when: always, toggle: ascii_punct, accept: Control+Shift+numbersign } # 切换中英标点
- { when: always, toggle: traditionalization, accept: Control+Shift+4 } # 切换简繁
- { when: always, toggle: traditionalization, accept: Control+Shift+dollar } # 切换简繁
- { when: always, toggle: full_shape, accept: Control+Shift+5 } # 切换全半角
- { when: always, toggle: full_shape, accept: Control+Shift+percent } # 切换全半角
# 将小键盘 0~9 . 映射到主键盘,数字金额大写的 Lua 如 R1234.5678 可使用小键盘输入
- { accept: KP_0, send: 0, when: composing }

View file

@ -1,43 +1,18 @@
{
perSystem = {
pkgs,
lib,
...
}: {
perSystem = {lib, ...}: {
treefmt = {
programs = {
alejandra = {
enable = true;
excludes = ["_sources/*.nix"];
};
biome = {
oxfmt = let
oxfmtConfig = with lib;
pipe ./.oxfmtrc.json [builtins.readFile builtins.fromJSON];
in {
enable = true;
includes = ["*.json"];
excludes = ["_sources/*.json"];
settings = {
formatter.indentStyle = "space";
javascript.formatter.enabled = false;
css.formatter.enabled = false;
};
};
dprint = {
enable = true;
includes = [
"*.md"
"*.toml"
"*.yaml"
];
excludes = ["secrets/*.yaml"];
settings = {
plugins = pkgs.dprint-plugins.getPluginList (
plugins:
with plugins; [
dprint-plugin-toml
dprint-plugin-markdown
g-plane-pretty_yaml
]
);
};
includes = ["*.json" "*.md" "*.toml" "*.yaml"];
excludes = oxfmtConfig.ignorePatterns;
};
just = {
enable = true;
@ -45,10 +20,7 @@
};
typos = let
config = with lib;
pipe ./.typos.toml [
builtins.readFile
fromTOML
];
pipe ./.typos.toml [builtins.readFile fromTOML];
in {
enable = true;
includes = ["*"];