feat: Use oxfmt to reformat json/yaml/toml/markdown
This commit is contained in:
parent
e85da11b65
commit
4b00734efe
5 changed files with 50 additions and 66 deletions
3
.oxfmtrc.json
Normal file
3
.oxfmtrc.json
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"ignorePatterns": ["_sources/*.json", "secrets/*.yaml"]
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,38 @@
|
||||||
"arguments": ["-"]
|
"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}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
just
|
just
|
||||||
nvfetcher
|
nvfetcher
|
||||||
alejandra
|
alejandra
|
||||||
|
oxfmt
|
||||||
|
|
||||||
lua-language-server
|
lua-language-server
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -29,36 +29,12 @@ patch:
|
||||||
- { when: has_menu, accept: minus, send: Page_Up }
|
- { when: has_menu, accept: minus, send: Page_Up }
|
||||||
- { when: has_menu, accept: equal, send: Page_Down }
|
- { when: has_menu, accept: equal, send: Page_Down }
|
||||||
|
|
||||||
- {
|
- { when: always, toggle: ascii_punct, accept: Control+Shift+3 } # 切换中英标点
|
||||||
when: always,
|
- { when: always, toggle: ascii_punct, accept: Control+Shift+numbersign } # 切换中英标点
|
||||||
toggle: ascii_punct,
|
- { when: always, toggle: traditionalization, accept: Control+Shift+4 } # 切换简繁
|
||||||
accept: Control+Shift+3,
|
- { 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+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 可使用小键盘输入
|
# 将小键盘 0~9 . 映射到主键盘,数字金额大写的 Lua 如 R1234.5678 可使用小键盘输入
|
||||||
- { accept: KP_0, send: 0, when: composing }
|
- { accept: KP_0, send: 0, when: composing }
|
||||||
|
|
|
||||||
44
treefmt.nix
44
treefmt.nix
|
|
@ -1,43 +1,18 @@
|
||||||
{
|
{
|
||||||
perSystem = {
|
perSystem = {lib, ...}: {
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
treefmt = {
|
treefmt = {
|
||||||
programs = {
|
programs = {
|
||||||
alejandra = {
|
alejandra = {
|
||||||
enable = true;
|
enable = true;
|
||||||
excludes = ["_sources/*.nix"];
|
excludes = ["_sources/*.nix"];
|
||||||
};
|
};
|
||||||
biome = {
|
oxfmt = let
|
||||||
|
oxfmtConfig = with lib;
|
||||||
|
pipe ./.oxfmtrc.json [builtins.readFile builtins.fromJSON];
|
||||||
|
in {
|
||||||
enable = true;
|
enable = true;
|
||||||
includes = ["*.json"];
|
includes = ["*.json" "*.md" "*.toml" "*.yaml"];
|
||||||
excludes = ["_sources/*.json"];
|
excludes = oxfmtConfig.ignorePatterns;
|
||||||
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
|
|
||||||
]
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
just = {
|
just = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -45,10 +20,7 @@
|
||||||
};
|
};
|
||||||
typos = let
|
typos = let
|
||||||
config = with lib;
|
config = with lib;
|
||||||
pipe ./.typos.toml [
|
pipe ./.typos.toml [builtins.readFile fromTOML];
|
||||||
builtins.readFile
|
|
||||||
fromTOML
|
|
||||||
];
|
|
||||||
in {
|
in {
|
||||||
enable = true;
|
enable = true;
|
||||||
includes = ["*"];
|
includes = ["*"];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue