File size: 11,002 Bytes
0dbc9de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
---
title: LSP μ„œλ²„
description: OpenCodeλŠ” LSP μ„œλ²„μ™€ ν†΅ν•©λ©λ‹ˆλ‹€.
---

OpenCodeλŠ” Language Server Protocol(LSP) μ„œλ²„μ™€ 톡합해 진단 정보λ₯Ό agent의 ν”Όλ“œλ°±μœΌλ‘œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

---

## 기본 제곡 (Built-in)

OpenCodeλŠ” 널리 μ‚¬μš©λ˜λŠ” μ–Έμ–΄λ₯Ό μœ„ν•΄ μ—¬λŸ¬ built-in LSP μ„œλ²„λ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€.

| LSP μ„œλ²„           | ν™•μž₯자                                                              | μš”κ΅¬ 사항                                                  |
| ------------------ | ------------------------------------------------------------------- | ---------------------------------------------------------- |
| astro              | .astro                                                              | Astro ν”„λ‘œμ νŠΈμ—μ„œ μžλ™ μ„€μΉ˜                               |
| bash               | .sh, .bash, .zsh, .ksh                                              | `bash-language-server` μžλ™ μ„€μΉ˜                           |
| clangd             | .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++                | C/C++ ν”„λ‘œμ νŠΈμ—μ„œ μžλ™ μ„€μΉ˜                               |
| csharp             | .cs                                                                 | `.NET SDK` μ„€μΉ˜λ¨                                          |
| clojure-lsp        | .clj, .cljs, .cljc, .edn                                            | `clojure-lsp` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                               |
| dart               | .dart                                                               | `dart` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                                      |
| deno               | .ts, .tsx, .js, .jsx, .mjs                                          | `deno` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯ (`deno.json`/`deno.jsonc` μžλ™ 감지) |
| elixir-ls          | .ex, .exs                                                           | `elixir` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                                    |
| eslint             | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue                  | ν”„λ‘œμ νŠΈμ— `eslint` dependency 쑴재                        |
| fsharp             | .fs, .fsi, .fsx, .fsscript                                          | `.NET SDK` μ„€μΉ˜λ¨                                          |
| gleam              | .gleam                                                              | `gleam` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                                     |
| gopls              | .go                                                                 | `go` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                                        |
| hls                | .hs, .lhs                                                           | `haskell-language-server-wrapper` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯           |
| jdtls              | .java                                                               | `Java SDK (version 21+)` μ„€μΉ˜λ¨                            |
| julials            | .jl                                                                 | `julia` 및 `LanguageServer.jl` μ„€μΉ˜λ¨                      |
| kotlin-ls          | .kt, .kts                                                           | Kotlin ν”„λ‘œμ νŠΈμ—μ„œ μžλ™ μ„€μΉ˜                              |
| lua-ls             | .lua                                                                | Lua ν”„λ‘œμ νŠΈμ—μ„œ μžλ™ μ„€μΉ˜                                 |
| nixd               | .nix                                                                | `nixd` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                                      |
| ocaml-lsp          | .ml, .mli                                                           | `ocamllsp` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                                  |
| oxlint             | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue, .astro, .svelte | ν”„λ‘œμ νŠΈμ— `oxlint` dependency 쑴재                        |
| php intelephense   | .php                                                                | PHP ν”„λ‘œμ νŠΈμ—μ„œ μžλ™ μ„€μΉ˜                                 |
| prisma             | .prisma                                                             | `prisma` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                                    |
| pyright            | .py, .pyi                                                           | `pyright` dependency μ„€μΉ˜λ¨                                |
| ruby-lsp (rubocop) | .rb, .rake, .gemspec, .ru                                           | `ruby` 및 `gem` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                             |
| rust               | .rs                                                                 | `rust-analyzer` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                             |
| sourcekit-lsp      | .swift, .objc, .objcpp                                              | `swift` μ„€μΉ˜λ¨ (macOSμ—μ„œλŠ” `xcode`)                       |
| svelte             | .svelte                                                             | Svelte ν”„λ‘œμ νŠΈμ—μ„œ μžλ™ μ„€μΉ˜                              |
| terraform          | .tf, .tfvars                                                        | GitHub releasesμ—μ„œ μžλ™ μ„€μΉ˜                              |
| tinymist           | .typ, .typc                                                         | GitHub releasesμ—μ„œ μžλ™ μ„€μΉ˜                              |
| typescript         | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts                        | ν”„λ‘œμ νŠΈμ— `typescript` dependency 쑴재                    |
| vue                | .vue                                                                | Vue ν”„λ‘œμ νŠΈμ—μ„œ μžλ™ μ„€μΉ˜                                 |
| yaml-ls            | .yaml, .yml                                                         | Red Hat `yaml-language-server` μžλ™ μ„€μΉ˜                   |
| zls                | .zig, .zon                                                          | `zig` λͺ…λ Ή μ‚¬μš© κ°€λŠ₯                                       |

LSPλŠ” 기본적으둜 λΉ„ν™œμ„±ν™”λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. ν™œμ„±ν™”ν•˜λ©΄ μœ„ ν™•μž₯자 쀑 ν•˜λ‚˜κ°€ κ°μ§€λ˜κ³  μš”κ΅¬ 사항이 좩쑱될 λ•Œ μ„œλ²„κ°€ μ‹œμž‘λ©λ‹ˆλ‹€.

:::note
`OPENCODE_DISABLE_LSP_DOWNLOAD` ν™˜κ²½ λ³€μˆ˜λ₯Ό `true`둜 μ„€μ •ν•˜λ©΄ LSP μ„œλ²„ μžλ™ λ‹€μš΄λ‘œλ“œλ₯Ό λΉ„ν™œμ„±ν™”ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
:::

---

## μž‘λ™ 방식

LSPκ°€ ν™œμ„±ν™”λ˜μ–΄ 있고 OpenCodeκ°€ νŒŒμΌμ„ μ—΄λ©΄ λ‹€μŒκ³Ό 같이 λ™μž‘ν•©λ‹ˆλ‹€.

1. ν™œμ„±ν™”λœ λͺ¨λ“  LSP μ„œλ²„μ— λŒ€ν•΄ 파일 ν™•μž₯자λ₯Ό ν™•μΈν•©λ‹ˆλ‹€.
2. μ μ ˆν•œ LSP μ„œλ²„κ°€ 아직 μ‹€ν–‰ 쀑이지 μ•Šλ‹€λ©΄ μ‹œμž‘ν•©λ‹ˆλ‹€.

---

## λͺ¨λ²” 사둀

LSPλŠ” μ–Έμ–΄ μ„œλ²„μ˜ 진단을 μ œκ³΅ν•΄ agentκ°€ 문제λ₯Ό μ°Ύκ³  μˆ˜μ •ν•˜λŠ” 데 도움을 쀄 수 μžˆμŠ΅λ‹ˆλ‹€. 일뢀 ν”„λ‘œμ νŠΈμ—μ„œλŠ” μœ μš©ν•˜μ§€λ§Œ 항상 순이읡이 λ˜λŠ” 것은 μ•„λ‹™λ‹ˆλ‹€.

μ–Έμ–΄ μ„œλ²„λŠ” 동기화가 μ–΄κΈ‹λ‚˜κ±°λ‚˜ λ§Žμ€ λ©”λͺ¨λ¦¬λ₯Ό μ‚¬μš©ν•˜κ±°λ‚˜ 버전 λ˜λŠ” ν”„λ‘œμ νŠΈμ— 따라 λ‹€λ₯΄κ²Œ λ™μž‘ν•˜κ³  agent μ›Œν¬ν”Œλ‘œλ₯Ό 느리게 λ§Œλ“€ 수 μžˆμŠ΅λ‹ˆλ‹€. λ§Žμ€ ν”„λ‘œμ νŠΈμ—μ„œλŠ” agentκ°€ lint, typecheck λ˜λŠ” λ‹€λ₯Έ μ§„λ‹¨μš© CLI 도ꡬλ₯Ό 직접 μ‹€ν–‰ν•˜κ²Œ ν•˜λŠ” 편이 더 μ’‹μŠ΅λ‹ˆλ‹€. μ΄λ ‡κ²Œ ν•˜λ©΄ μ΄λŸ¬ν•œ νŠΈλ ˆμ΄λ“œμ˜€ν”„ 없이 였λ₯˜κ°€ agent λ£¨ν”„λ‘œ λ‹€μ‹œ μ „λ‹¬λ©λ‹ˆλ‹€. agentκ°€ 무엇을 μ‹€ν–‰ν•΄μ•Ό ν•˜λŠ”μ§€ μ•Œ 수 μžˆλ„λ‘ ν•΄λ‹Ή λͺ…령을 `AGENTS.md` λ˜λŠ” skills 같은 instruction files에 λ¬Έμ„œν™”ν•˜μ„Έμš”. ν”„λ‘œμ νŠΈκ°€ μΆ”κ°€ μ–Έμ–΄ μ„œλ²„ ν”Όλ“œλ°±μ˜ 이점을 얻을 λ•Œ LSPλ₯Ό ν™œμ„±ν™”ν•˜μ„Έμš”.

---

## ꡬ성

OpenCode config의 `lsp` μ„Ήμ…˜μ—μ„œ LSP μ„œλ²„λ₯Ό ν™œμ„±ν™”ν•˜κ³  μ‚¬μš©μž μ •μ˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λͺ¨λ“  λ‚΄μž₯ LSP μ„œλ²„λ₯Ό ν™œμ„±ν™”ν•˜λ €λ©΄ `lsp`λ₯Ό `true`둜 μ„€μ •ν•˜μ„Έμš”.

```json title="opencode.json"
{
  "$schema": "https://opencode.ai/config.json",
  "lsp": true
}
```

객체λ₯Ό μ‚¬μš©ν•˜λ©΄ λ‚΄μž₯ μ„œλ²„λ₯Ό ν™œμ„±ν™”ν•œ μƒνƒœλ‘œ μœ μ§€ν•˜λ©΄μ„œ μ˜€λ²„λΌμ΄λ“œλ‚˜ μ‚¬μš©μž μ •μ˜ μ„œλ²„λ₯Ό ꡬ성할 수 μžˆμŠ΅λ‹ˆλ‹€.

```json title="opencode.json"
{
  "$schema": "https://opencode.ai/config.json",
  "lsp": {}
}
```

각 LSP μ„œλ²„λŠ” λ‹€μŒ 속성을 μ§€μ›ν•©λ‹ˆλ‹€.

| 속성             | νƒ€μž…     | μ„€λͺ…                                          |
| ---------------- | -------- | --------------------------------------------- |
| `disabled`       | boolean  | LSP μ„œλ²„λ₯Ό λΉ„ν™œμ„±ν™”ν•˜λ €λ©΄ `true`둜 μ„€μ •ν•˜μ„Έμš” |
| `command`        | string[] | LSP μ„œλ²„λ₯Ό μ‹œμž‘ν•˜λŠ” λͺ…λ Ήμž…λ‹ˆλ‹€                |
| `extensions`     | string[] | 이 LSP μ„œλ²„κ°€ μ²˜λ¦¬ν•  파일 ν™•μž₯μžμž…λ‹ˆλ‹€        |
| `env`            | object   | μ„œλ²„ μ‹œμž‘ μ‹œ μ„€μ •ν•  ν™˜κ²½ λ³€μˆ˜μž…λ‹ˆλ‹€           |
| `initialization` | object   | LSP μ„œλ²„λ‘œ 전솑할 μ΄ˆκΈ°ν™” μ˜΅μ…˜μž…λ‹ˆλ‹€           |

μ˜ˆμ‹œλ₯Ό μ‚΄νŽ΄λ³΄κ² μŠ΅λ‹ˆλ‹€.

---

### ν™˜κ²½ λ³€μˆ˜

`env` 속성을 μ‚¬μš©ν•˜λ©΄ LSP μ„œλ²„ μ‹œμž‘ μ‹œ ν™˜κ²½ λ³€μˆ˜λ₯Ό μ„€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

```json title="opencode.json" {5-7}
{
  "$schema": "https://opencode.ai/config.json",
  "lsp": {
    "rust": {
      "env": {
        "RUST_LOG": "debug"
      }
    }
  }
}
```

---

### μ΄ˆκΈ°ν™” μ˜΅μ…˜

`initialization` 속성을 μ‚¬μš©ν•΄ LSP μ„œλ²„μ— μ΄ˆκΈ°ν™” μ˜΅μ…˜μ„ μ „λ‹¬ν•˜μ„Έμš”. 이 값은 LSP `initialize` μš”μ²­ 쀑에 μ „μ†‘λ˜λŠ” μ„œλ²„λ³„ μ„€μ •μž…λ‹ˆλ‹€.

```json title="opencode.json" {5-9}
{
  "$schema": "https://opencode.ai/config.json",
  "lsp": {
    "typescript": {
      "initialization": {
        "preferences": {
          "importModuleSpecifierPreference": "relative"
        }
      }
    }
  }
}
```

:::note
μ΄ˆκΈ°ν™” μ˜΅μ…˜μ€ LSP μ„œλ²„λ§ˆλ‹€ λ‹€λ¦…λ‹ˆλ‹€. μ‚¬μš© κ°€λŠ₯ν•œ μ˜΅μ…˜μ€ ν•΄λ‹Ή LSP μ„œλ²„ λ¬Έμ„œλ₯Ό ν™•μΈν•˜μ„Έμš”.
:::

---

### LSP μ„œλ²„ λΉ„ν™œμ„±ν™”

`lsp`λ₯Ό μƒλž΅ν•˜λ©΄ λͺ¨λ“  LSP μ„œλ²„κ°€ λΉ„ν™œμ„±ν™”λ©λ‹ˆλ‹€. λ‹€λ₯Έ configμ—μ„œ ν™œμ„±ν™”ν•œ λͺ¨λ“  LSP μ„œλ²„λ₯Ό λΉ„ν™œμ„±ν™”ν•˜λ €λ©΄ `lsp`λ₯Ό `false`둜 μ„€μ •ν•˜μ„Έμš”.

```json title="opencode.json" {3}
{
  "$schema": "https://opencode.ai/config.json",
  "lsp": false
}
```

**νŠΉμ •** LSP μ„œλ²„λ₯Ό λΉ„ν™œμ„±ν™”ν•˜λ €λ©΄ `disabled`λ₯Ό `true`둜 μ„€μ •ν•˜μ„Έμš”.

```json title="opencode.json" {5}
{
  "$schema": "https://opencode.ai/config.json",
  "lsp": {
    "typescript": {
      "disabled": true
    }
  }
}
```

---

## μ‚¬μš©μž μ •μ˜ LSP μ„œλ²„

λͺ…λ Ήκ³Ό 파일 ν™•μž₯자λ₯Ό μ§€μ •ν•΄ μ‚¬μš©μž μ •μ˜ LSP μ„œλ²„λ₯Ό μΆ”κ°€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

```json title="opencode.json" {4-7}
{
  "$schema": "https://opencode.ai/config.json",
  "lsp": {
    "custom-lsp": {
      "command": ["custom-lsp-server", "--stdio"],
      "extensions": [".custom"]
    }
  }
}
```

---

## μΆ”κ°€ 정보

### PHP Intelephense

PHP IntelephenseλŠ” λΌμ΄μ„ μŠ€ ν‚€λ₯Ό 톡해 프리미엄 κΈ°λŠ₯을 μ œκ³΅ν•©λ‹ˆλ‹€. ν…μŠ€νŠΈ νŒŒμΌμ— ν‚€λ§Œ μ €μž₯ν•΄ λΌμ΄μ„ μŠ€ ν‚€λ₯Ό μ œκ³΅ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

- macOS/Linux: `$HOME/intelephense/license.txt`
- Windows: `%USERPROFILE%/intelephense/license.txt`

νŒŒμΌμ—λŠ” μΆ”κ°€ λ‚΄μš© 없이 λΌμ΄μ„ μŠ€ ν‚€λ§Œ ν¬ν•¨ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.