콘텐츠로 이동

LSP Servers

opencode integrates with your LSP servers.

opencode는 언어 서버 프로토콜 (LSP)과 통합하여 LLM은 코드베이스와 상호 작용합니다. 그것은 LLM에 피드백을 제공하기 위해 진단을 사용합니다.


내장

opencode는 인기있는 언어로 여러 내장 LSP 서버와 함께 제공됩니다.

LSP 서버연장요구사항
astro.astroAstro 프로젝트 자동 설치
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, .ednclojure-lsp 명령 가능
다트다트dart 명령
deno.ts, .tsx, .js, .jsx, .mjsdeno 명령 가능(자동검출 deno.json/deno.jsonc)
elixir-ls.ex, .exselixir 명령 가능
eslint.ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue프로젝트의 eslint 의존성
fsharp.fs, .fsi, .fsx, .fsscript.NET SDK 설치
gleam.gleamgleam 명령 가능
gopls.gogo 명령 가능
hls.hs, .lhshaskell-language-server-wrapper 명령 가능
jdtls.javaJava SDK (version 21+) 설치
kotlin-ls.kt, .ktsKotlin 프로젝트용 자동 설치
lua-ls.lua루아 사업용 자동설치
nixd.nixnixd 명령 가능
ocaml-lsp.ml, .mliocamllsp 명령 가능
oxlint.ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .ct, .vue, .astro, .svelte프로젝트의 oxlint 신뢰성
PHP intelephense.phpPHP 프로젝트 자동 설치
프리즘.prismaprisma 명령 가능
pyright.py, .pyipyright 의존성 설치
루비-lsp(rubocop).rb, .rake, .gemspec, .rurubygem 명령 사용 가능
.rsrust-analyzer 명령 가능
sourcekit-lsp.swift, .objc, .objcppswift 설치 (MacOS의 xcode)
svelte.svelteSvelte 프로젝트 자동 설치
지형.tf, .tfvarsGitHub 릴리스의 자동 설치
작문.typ, .typcGitHub 릴리스의 자동 설치
인가정보.ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts프로젝트의 typescript 의존성
vue.vueVue 프로젝트 자동 설치
yaml-ls.yaml, .yml자동 설치 Red Hat yaml-language-server
zls.zig, .zonzig 명령 가능

LSP 서버는 위의 파일 확장자 중 하나가 감지되고 요구 사항은 자동으로 활성화됩니다.


그것이 작동하는 방법

opencode가 파일을 열 때, 그것은:

  1. 모든 활성화된 LSP 서버에 대한 파일 확장을 확인합니다.
  2. 이미 실행되지 않은 경우 적절한 LSP 서버를 시작합니다.

구성

opencode 설정에서 lsp 섹션을 통해 LSP 서버를 사용자 정의할 수 있습니다.

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

각 LSP 서버는 다음을 지원합니다:

재산유형묘사
disabled불린LSP 서버를 비활성화하려면 true로 설정
command문자열[]LSP 서버를 시작하는 명령
extensionsstring[]이 LSP 서버 확장
env객체서버 시작시 설정할 환경 변수
initialization객체LSP 서버에 보내는 초기화 옵션

몇 가지 예제를 살펴 보자.


환경 변수

env 속성을 사용하여 LSP 서버를 시작할 때 환경 변수를 설정하십시오.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"lsp": {
"rust": {
"env": {
"RUST_LOG": "debug"
}
}
}
}

초기화 옵션

initialization 속성을 사용하여 초기화 옵션을 LSP 서버에 전달합니다. 이들은 LSP initialize 요청에 보내진 서버 별 설정입니다.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"lsp": {
"typescript": {
"initialization": {
"preferences": {
"importModuleSpecifierPreference": "relative"
}
}
}
}
}

LSP 서버를 해제

전 세계적으로 ** 모든** LSP 서버를 비활성화하려면 lspfalse로 설정하십시오.

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

** 특정** LSP 서버를 비활성화하려면 disabledtrue로 설정하십시오.

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

사용자 정의 LSP 서버

명령 및 파일 확장명을 지정하여 사용자 정의 LSP 서버를 추가할 수 있습니다.

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

추가 정보

PHP 인텔

PHP를 Intelephense는 라이센스 키를 통해 프리미엄 기능을 제공합니다. 텍스트 파일에서 키 (만)를 배치하여 라이센스 키를 제공 할 수 있습니다.

  • macOS/리눅스에서: $HOME/intelephense/license.txt
  • Windows에서: %USERPROFILE%/intelephense/license.txt

파일에는 추가 내용이 없습니다.