Download packages/web/src/content/docs/ko/formatters.mdx from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 9.75 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/web/src/content/docs/ko/formatters.mdx
- Command line
-
hf download hf://SaylorTwift/opencode/packages/web/src/content/docs/ko/formatters.mdx
-
curl -L -o formatters.mdx https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/web/src/content/docs/ko/formatters.mdx
9.75 kB
| title: ํฌ๋งคํฐ | |
| description: OpenCode๋ ์ธ์ด๋ณ ํฌ๋งคํฐ๋ฅผ ์ฌ์ฉํฉ๋๋ค. | |
| OpenCode๋ ํ์ผ์ writeํ๊ฑฐ๋ editํ ๋ค, ์ธ์ด๋ณ ํฌ๋งคํฐ๋ฅผ ์ฌ์ฉํด ์๋์ผ๋ก ํฌ๋งทํฉ๋๋ค. ์ด๋ฅผ ํตํด ์์ฑ๋ ์ฝ๋๊ฐ ํ๋ก์ ํธ์ ์ฝ๋ ์คํ์ผ์ ๋ฐ๋ฅด๋๋ก ๋ณด์ฅํฉ๋๋ค. | |
| ## ๋ด์ฅ | |
| OpenCode๋ ์ฃผ์ ์ธ์ด์ ํ๋ ์์ํฌ๋ฅผ ์ํ ์ฌ๋ฌ ๋ด์ฅ ํฌ๋งคํฐ๋ฅผ ์ ๊ณตํฉ๋๋ค. ์๋๋ ํฌ๋งคํฐ ๋ชฉ๋ก, ์ง์ ํ์ฅ์, ํ์ํ ๋ช ๋ น ๋๋ config ์ต์ ์ ๋๋ค. | |
| | ํฌ๋งคํฐ | ํ์ฅ์ | ์๊ตฌ ์ฌํญ | | |
| | -------------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | |
| | air | .R | `air` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | biome | .js, .jsx, .ts, .tsx, .html, .css, .md, .json, .yaml, [๊ธฐํ](https://biomejs.dev/) | `biome.json(c)` config ํ์ผ | | |
| | cargofmt | .rs | `cargo fmt` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | clang-format | .c, .cpp, .h, .hpp, .ino, [๊ธฐํ](https://clang.llvm.org/docs/ClangFormat.html) | `.clang-format` config ํ์ผ | | |
| | cljfmt | .clj, .cljs, .cljc, .edn | `cljfmt` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | dart | .dart | `dart` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | dfmt | .d | `dfmt` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | gleam | .gleam | `gleam` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | gofmt | .go | `gofmt` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | htmlbeautifier | .erb, .html.erb | `htmlbeautifier` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | ktlint | .kt, .kts | `ktlint` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | mix | .ex, .exs, .eex, .heex, .leex, .neex, .sface | `mix` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | nixfmt | .nix | `nixfmt` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | ocamlformat | .ml, .mli | `ocamlformat` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ ๋ฐ `.ocamlformat` config ํ์ผ ํ์ | | |
| | ormolu | .hs | `ormolu` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | oxfmt (Experimental) | .js, .jsx, .ts, .tsx | `package.json`์ `oxfmt` dependency ํ์ ๋ฐ [experimental env variable flag](/docs/cli/#experimental) | | |
| | pint | .php | `composer.json`์ `laravel/pint` dependency ํ์ | | |
| | prettier | .js, .jsx, .ts, .tsx, .html, .css, .md, .json, .yaml, [๊ธฐํ](https://prettier.io/docs/en/index.html) | `package.json`์ `prettier` dependency ํ์ | | |
| | rubocop | .rb, .rake, .gemspec, .ru | `rubocop` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | ruff | .py, .pyi | `ruff` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ ๋ฐ ๊ด๋ จ config ํ์ | | |
| | rustfmt | .rs | `rustfmt` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | shfmt | .sh, .bash | `shfmt` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | standardrb | .rb, .rake, .gemspec, .ru | `standardrb` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | terraform | .tf, .tfvars | `terraform` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | uv | .py, .pyi | `uv` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| | zig | .zig, .zon | `zig` ๋ช ๋ น ์ฌ์ฉ ๊ฐ๋ฅ | | |
| ์๋ฅผ ๋ค์ด ํ๋ก์ ํธ `package.json`์ `prettier`๊ฐ ์์ผ๋ฉด OpenCode๊ฐ ์๋์ผ๋ก ํด๋น ํฌ๋งคํฐ๋ฅผ ์ฌ์ฉํฉ๋๋ค. | |
| ## ์๋ ๋ฐฉ์ | |
| OpenCode๊ฐ ํ์ผ์ writeํ๊ฑฐ๋ editํ ๋ ๋ค์ ์์๋ก ๋์ํฉ๋๋ค. | |
| 1. ํ์ฑํ๋ ๋ชจ๋ ํฌ๋งคํฐ์ ํ์ผ ํ์ฅ์๋ฅผ ๋์กฐํฉ๋๋ค. | |
| 2. ํ์ผ์ ๋ง๋ ํฌ๋งคํฐ ๋ช ๋ น์ ์คํํฉ๋๋ค. | |
| 3. ํฌ๋งท ๋ณ๊ฒฝ ์ฌํญ์ ์๋์ผ๋ก ์ ์ฉํฉ๋๋ค. | |
| ์ด ๊ณผ์ ์ background์์ ์คํ๋๋ฉฐ, ์๋ ์์ ์์ด ์ฝ๋ ์คํ์ผ์ด ์ ์ง๋ฉ๋๋ค. | |
| ## ๊ตฌ์ฑ | |
| OpenCode config์ `formatter` ์น์ ์์ ํฌ๋งคํฐ๋ฅผ ์ปค์คํฐ๋ง์ด์ฆํ ์ ์์ต๋๋ค. | |
| ```json title="opencode.json" | |
| { | |
| "$schema": "https://opencode.ai/config.json", | |
| "formatter": {} | |
| } | |
| ``` | |
| ๊ฐ formatter ์ค์ ์์ ์ง์ํ๋ ํญ๋ชฉ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. | |
| | ์์ฑ | ํ์ | ์ค๋ช | | |
| | ------------- | -------- | ---------------------------------------------- | | |
| | `disabled` | boolean | `true`๋ก ์ค์ ํ๋ฉด ํด๋น ํฌ๋งคํฐ๋ฅผ ๋นํ์ฑํํฉ๋๋ค | | |
| | `command` | string[] | ํฌ๋งท ์คํ ๋ช ๋ น์ ๋๋ค | | |
| | `environment` | object | ํฌ๋งคํฐ ์คํ ์ ์ค์ ํ ํ๊ฒฝ ๋ณ์์ ๋๋ค | | |
| | `extensions` | string[] | ํด๋น ํฌ๋งคํฐ๊ฐ ์ฒ๋ฆฌํ ํ์ผ ํ์ฅ์์ ๋๋ค | | |
| ์๋ ์์๋ฅผ ์ฐธ๊ณ ํ์ธ์. | |
| ### ํฌ๋งคํฐ ๋นํ์ฑํ | |
| ์ ์ฒด ํฌ๋งคํฐ๋ฅผ ์ ์ญ์์ ๋นํ์ฑํํ๋ ค๋ฉด `formatter`๋ฅผ `false`๋ก ์ค์ ํ์ธ์. | |
| ```json title="opencode.json" {3} | |
| { | |
| "$schema": "https://opencode.ai/config.json", | |
| "formatter": false | |
| } | |
| ``` | |
| ํน์ ํฌ๋งคํฐ๋ง ๋นํ์ฑํํ๋ ค๋ฉด `disabled`๋ฅผ `true`๋ก ์ค์ ํ์ธ์. | |
| ```json title="opencode.json" {5} | |
| { | |
| "$schema": "https://opencode.ai/config.json", | |
| "formatter": { | |
| "prettier": { | |
| "disabled": true | |
| } | |
| } | |
| } | |
| ``` | |
| ### ์ฌ์ฉ์ ์ ์ ํฌ๋งคํฐ | |
| ๋ช ๋ น, ํ๊ฒฝ ๋ณ์, ํ์ผ ํ์ฅ์๋ฅผ ์ง์ ํด ๋ด์ฅ ํฌ๋งคํฐ๋ฅผ overrideํ๊ฑฐ๋ ์ ํฌ๋งคํฐ๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๋ค. | |
| ```json title="opencode.json" {4-14} | |
| { | |
| "$schema": "https://opencode.ai/config.json", | |
| "formatter": { | |
| "prettier": { | |
| "command": ["npx", "prettier", "--write", "$FILE"], | |
| "environment": { | |
| "NODE_ENV": "development" | |
| }, | |
| "extensions": [".js", ".ts", ".jsx", ".tsx"] | |
| }, | |
| "custom-markdown-formatter": { | |
| "command": ["deno", "fmt", "$FILE"], | |
| "extensions": [".md"] | |
| } | |
| } | |
| } | |
| ``` | |
| ๋ช ๋ น์ **`$FILE` placeholder**๋ ํฌ๋งท ๋์ ํ์ผ ๊ฒฝ๋ก๋ก ์นํ๋ฉ๋๋ค. | |