core: add built-in Dart LSP server and formatter (#4841)

This commit is contained in:
Christoph 2025-11-28 07:33:45 +01:00 committed by GitHub
commit 7112a706b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 0 deletions

View file

@ -246,3 +246,12 @@ export const htmlbeautifier: Info = {
return Bun.which("htmlbeautifier") !== null return Bun.which("htmlbeautifier") !== null
}, },
} }
export const dart: Info = {
name: "dart",
command: ["dart", "format", "$FILE"],
extensions: [".dart"],
async enabled() {
return Bun.which("dart") !== null
},
}

View file

@ -1166,4 +1166,22 @@ export namespace LSPServer {
} }
}, },
} }
export const Dart: Info = {
id: "dart",
extensions: [".dart"],
root: NearestRoot(["pubspec.yaml", "analysis_options.yaml"]),
async spawn(root) {
const dart = Bun.which("dart")
if (!dart) {
log.info("dart not found, please install dart first")
return
}
return {
process: spawn(dart, ["language-server", "--lsp"], {
cwd: root,
}),
}
},
}
} }

View file

@ -26,6 +26,7 @@ OpenCode comes with several built-in formatters for popular languages and framew
| standardrb | .rb, .rake, .gemspec, .ru | `standardrb` command available | | standardrb | .rb, .rake, .gemspec, .ru | `standardrb` command available |
| htmlbeautifier | .erb, .html.erb | `htmlbeautifier` command available | | htmlbeautifier | .erb, .html.erb | `htmlbeautifier` command available |
| air | .R | `air` command available | | air | .R | `air` command available |
| dart | .dart | `dart` command available |
So if your project has `prettier` in your `package.json`, OpenCode will automatically use it. So if your project has `prettier` in your `package.json`, OpenCode will automatically use it.

View file

@ -32,6 +32,7 @@ OpenCode comes with several built-in LSP servers for popular languages:
| lua-ls | .lua | Auto-installs for Lua projects | | lua-ls | .lua | Auto-installs for Lua projects |
| sourcekit-lsp | .swift, .objc, .objcpp | `swift` installed (`xcode` on macOS) | | sourcekit-lsp | .swift, .objc, .objcpp | `swift` installed (`xcode` on macOS) |
| php intelephense | .php | Auto-installs for PHP projects | | php intelephense | .php | Auto-installs for PHP projects |
| dart | .dart | `dart` command available |
LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met. LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.