themes.mdx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. ---
  2. title: テーマ
  3. description: 組み込みのテーマを選択するか、独自のテーマを定義します。
  4. ---
  5. OpenCode を使用すると、いくつかの組み込みテーマから 1 つを選択したり、端末のテーマに適合するテーマを使用したり、独自のカスタム テーマを定義したりできます。
  6. デフォルトでは、OpenCode は独自の `opencode` テーマを使用します。
  7. ---
  8. ## 端末要件
  9. テーマをフルカラー パレットで正しく表示するには、端末が **truecolor** (24 ビット カラー) をサポートしている必要があります。最新の端末のほとんどはデフォルトでこれをサポートしていますが、有効にする必要がある場合があります。
  10. - **サポートを確認してください**: `echo $COLORTERM` を実行します - `truecolor` または `24bit` が出力されるはずです
  11. - **トゥルーカラーを有効にする**: シェル プロファイルで環境変数 `COLORTERM=truecolor` を設定します。
  12. - **ターミナルの互換性**: ターミナル エミュレータが 24 ビット カラーをサポートしていることを確認してください (iTerm2、Alacritty、Kitty、Windows ターミナル、および GNOME ターミナルの最新バージョンなどのほとんどの最新のターミナルはサポートしています)。
  13. トゥルーカラーのサポートがないと、テーマの色の精度が低下したり、最も近い 256 色の近似値に戻ったりする可能性があります。
  14. ---
  15. ## 組み込みのテーマ
  16. OpenCode にはいくつかの組み込みテーマが付属しています。
  17. | Name | Description |
  18. | ---------------------- | ---------------------------------------------------------------------------- |
  19. | `system` | Adapts to your terminal’s background color |
  20. | `tokyonight` | Based on the [Tokyonight](https://github.com/folke/tokyonight.nvim) theme |
  21. | `everforest` | Based on the [Everforest](https://github.com/sainnhe/everforest) theme |
  22. | `ayu` | Based on the [Ayu](https://github.com/ayu-theme) dark theme |
  23. | `catppuccin` | Based on the [Catppuccin](https://github.com/catppuccin) theme |
  24. | `catppuccin-macchiato` | Based on the [Catppuccin](https://github.com/catppuccin) theme |
  25. | `gruvbox` | Based on the [Gruvbox](https://github.com/morhetz/gruvbox) theme |
  26. | `kanagawa` | Based on the [Kanagawa](https://github.com/rebelot/kanagawa.nvim) theme |
  27. | `nord` | Based on the [Nord](https://github.com/nordtheme/nord) theme |
  28. | `matrix` | Hacker-style green on black theme |
  29. | `one-dark` | Based on the [Atom One](https://github.com/Th3Whit3Wolf/one-nvim) Dark theme |
  30. さらに、新しいテーマも常に追加されています。
  31. ---
  32. ## システムテーマ
  33. `system` テーマは、端末のカラースキームに自動的に適応するように設計されています。固定色を使用する従来のテーマとは異なり、_system_ テーマは次のようになります。
  34. - **グレー スケールを生成**: 端末の背景色に基づいてカスタム グレー スケールを作成し、最適なコントラストを確保します。
  35. - **ANSI カラーを使用**: 構文の強調表示と UI 要素に標準の ANSI カラー (0 ~ 15) を利用し、端末のカラー パレットを尊重します。
  36. - **端末のデフォルトを維持**: テキストと背景の色に `none` を使用して、端末のネイティブの外観を維持します。
  37. システム テーマは、次のようなユーザーを対象としています。
  38. - OpenCode を端末の外観と一致させたい
  39. - カスタム端末のカラースキームを使用する
  40. - すべての端末アプリケーションにわたって一貫した外観を好む
  41. ---
  42. ## テーマの使用
  43. テーマを選択するには、`/theme` コマンドでテーマ選択を表示します。または、[config](/docs/config).
  44. ```json title="opencode.json" {3}
  45. {
  46. "$schema": "https://opencode.ai/config.json",
  47. "theme": "tokyonight"
  48. }
  49. ```
  50. ---
  51. ## カスタムテーマ
  52. OpenCode は、ユーザーがテーマを簡単に作成およびカスタマイズできる柔軟な JSON ベースのテーマ システムをサポートしています。
  53. ---
  54. ### 階層
  55. テーマは複数のディレクトリから次の順序でロードされ、後のディレクトリが前のディレクトリをオーバーライドします。
  56. 1. **組み込みテーマ** - これらはバイナリに埋め込まれています
  57. 2. **ユーザー設定ディレクトリ** - `~/.config/opencode/themes/*.json` または `$XDG_CONFIG_HOME/opencode/themes/*.json` で定義されます
  58. 3. **プロジェクトのルート ディレクトリ** - `<project-root>/.opencode/themes/*.json` で定義されます。
  59. 4. **現在の作業ディレクトリ** - `./.opencode/themes/*.json` で定義
  60. 複数のディレクトリに同じ名前のテーマが含まれている場合は、優先度の高いディレクトリのテーマが使用されます。
  61. ---
  62. ### テーマの作成
  63. カスタム テーマを作成するには、テーマ ディレクトリの 1 つに JSON ファイルを作成します。
  64. ユーザー全体のテーマの場合:
  65. ```bash no-frame
  66. mkdir -p ~/.config/opencode/themes
  67. vim ~/.config/opencode/themes/my-theme.json
  68. ```
  69. そしてプロジェクト固有のテーマについても。
  70. ```bash no-frame
  71. mkdir -p .opencode/themes
  72. vim .opencode/themes/my-theme.json
  73. ```
  74. ---
  75. ### JSON形式
  76. テーマは、以下をサポートする柔軟な JSON 形式を使用します。
  77. - **16 進数の色**: `"#ffffff"`
  78. - **ANSI カラー**: `3` (0-255)
  79. - **色の参照**: `"primary"` またはカスタム定義
  80. - **ダーク/ライトのバリエーション**: `{"dark": "#000", "light": "#fff"}`
  81. - **色なし**: `"none"` - 端末のデフォルトの色または透明を使用します。
  82. ---
  83. ### 色の定義
  84. `defs` セクションはオプションであり、テーマ内で参照できる再利用可能な色を定義できます。
  85. ---
  86. ### 端末のデフォルト
  87. 特別な値 `"none"` を任意の色に使用して、端末のデフォルトの色を継承できます。これは、端末の配色とシームレスに融合するテーマを作成する場合に特に便利です。
  88. - `"text": "none"` - 端末のデフォルトの前景色を使用します
  89. - `"background": "none"` - 端末のデフォルトの背景色を使用します
  90. ---
  91. ### 例
  92. カスタム テーマの例を次に示します。
  93. ```json title="my-theme.json"
  94. {
  95. "$schema": "https://opencode.ai/theme.json",
  96. "defs": {
  97. "nord0": "#2E3440",
  98. "nord1": "#3B4252",
  99. "nord2": "#434C5E",
  100. "nord3": "#4C566A",
  101. "nord4": "#D8DEE9",
  102. "nord5": "#E5E9F0",
  103. "nord6": "#ECEFF4",
  104. "nord7": "#8FBCBB",
  105. "nord8": "#88C0D0",
  106. "nord9": "#81A1C1",
  107. "nord10": "#5E81AC",
  108. "nord11": "#BF616A",
  109. "nord12": "#D08770",
  110. "nord13": "#EBCB8B",
  111. "nord14": "#A3BE8C",
  112. "nord15": "#B48EAD"
  113. },
  114. "theme": {
  115. "primary": {
  116. "dark": "nord8",
  117. "light": "nord10"
  118. },
  119. "secondary": {
  120. "dark": "nord9",
  121. "light": "nord9"
  122. },
  123. "accent": {
  124. "dark": "nord7",
  125. "light": "nord7"
  126. },
  127. "error": {
  128. "dark": "nord11",
  129. "light": "nord11"
  130. },
  131. "warning": {
  132. "dark": "nord12",
  133. "light": "nord12"
  134. },
  135. "success": {
  136. "dark": "nord14",
  137. "light": "nord14"
  138. },
  139. "info": {
  140. "dark": "nord8",
  141. "light": "nord10"
  142. },
  143. "text": {
  144. "dark": "nord4",
  145. "light": "nord0"
  146. },
  147. "textMuted": {
  148. "dark": "nord3",
  149. "light": "nord1"
  150. },
  151. "background": {
  152. "dark": "nord0",
  153. "light": "nord6"
  154. },
  155. "backgroundPanel": {
  156. "dark": "nord1",
  157. "light": "nord5"
  158. },
  159. "backgroundElement": {
  160. "dark": "nord1",
  161. "light": "nord4"
  162. },
  163. "border": {
  164. "dark": "nord2",
  165. "light": "nord3"
  166. },
  167. "borderActive": {
  168. "dark": "nord3",
  169. "light": "nord2"
  170. },
  171. "borderSubtle": {
  172. "dark": "nord2",
  173. "light": "nord3"
  174. },
  175. "diffAdded": {
  176. "dark": "nord14",
  177. "light": "nord14"
  178. },
  179. "diffRemoved": {
  180. "dark": "nord11",
  181. "light": "nord11"
  182. },
  183. "diffContext": {
  184. "dark": "nord3",
  185. "light": "nord3"
  186. },
  187. "diffHunkHeader": {
  188. "dark": "nord3",
  189. "light": "nord3"
  190. },
  191. "diffHighlightAdded": {
  192. "dark": "nord14",
  193. "light": "nord14"
  194. },
  195. "diffHighlightRemoved": {
  196. "dark": "nord11",
  197. "light": "nord11"
  198. },
  199. "diffAddedBg": {
  200. "dark": "#3B4252",
  201. "light": "#E5E9F0"
  202. },
  203. "diffRemovedBg": {
  204. "dark": "#3B4252",
  205. "light": "#E5E9F0"
  206. },
  207. "diffContextBg": {
  208. "dark": "nord1",
  209. "light": "nord5"
  210. },
  211. "diffLineNumber": {
  212. "dark": "nord2",
  213. "light": "nord4"
  214. },
  215. "diffAddedLineNumberBg": {
  216. "dark": "#3B4252",
  217. "light": "#E5E9F0"
  218. },
  219. "diffRemovedLineNumberBg": {
  220. "dark": "#3B4252",
  221. "light": "#E5E9F0"
  222. },
  223. "markdownText": {
  224. "dark": "nord4",
  225. "light": "nord0"
  226. },
  227. "markdownHeading": {
  228. "dark": "nord8",
  229. "light": "nord10"
  230. },
  231. "markdownLink": {
  232. "dark": "nord9",
  233. "light": "nord9"
  234. },
  235. "markdownLinkText": {
  236. "dark": "nord7",
  237. "light": "nord7"
  238. },
  239. "markdownCode": {
  240. "dark": "nord14",
  241. "light": "nord14"
  242. },
  243. "markdownBlockQuote": {
  244. "dark": "nord3",
  245. "light": "nord3"
  246. },
  247. "markdownEmph": {
  248. "dark": "nord12",
  249. "light": "nord12"
  250. },
  251. "markdownStrong": {
  252. "dark": "nord13",
  253. "light": "nord13"
  254. },
  255. "markdownHorizontalRule": {
  256. "dark": "nord3",
  257. "light": "nord3"
  258. },
  259. "markdownListItem": {
  260. "dark": "nord8",
  261. "light": "nord10"
  262. },
  263. "markdownListEnumeration": {
  264. "dark": "nord7",
  265. "light": "nord7"
  266. },
  267. "markdownImage": {
  268. "dark": "nord9",
  269. "light": "nord9"
  270. },
  271. "markdownImageText": {
  272. "dark": "nord7",
  273. "light": "nord7"
  274. },
  275. "markdownCodeBlock": {
  276. "dark": "nord4",
  277. "light": "nord0"
  278. },
  279. "syntaxComment": {
  280. "dark": "nord3",
  281. "light": "nord3"
  282. },
  283. "syntaxKeyword": {
  284. "dark": "nord9",
  285. "light": "nord9"
  286. },
  287. "syntaxFunction": {
  288. "dark": "nord8",
  289. "light": "nord8"
  290. },
  291. "syntaxVariable": {
  292. "dark": "nord7",
  293. "light": "nord7"
  294. },
  295. "syntaxString": {
  296. "dark": "nord14",
  297. "light": "nord14"
  298. },
  299. "syntaxNumber": {
  300. "dark": "nord15",
  301. "light": "nord15"
  302. },
  303. "syntaxType": {
  304. "dark": "nord7",
  305. "light": "nord7"
  306. },
  307. "syntaxOperator": {
  308. "dark": "nord9",
  309. "light": "nord9"
  310. },
  311. "syntaxPunctuation": {
  312. "dark": "nord4",
  313. "light": "nord0"
  314. }
  315. }
  316. }
  317. ```