mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
core: add built-in Dart LSP server and formatter (#4841)
This commit is contained in:
parent
025a47d01f
commit
7112a706b8
4 changed files with 29 additions and 0 deletions
|
|
@ -246,3 +246,12 @@ export const htmlbeautifier: Info = {
|
|||
return Bun.which("htmlbeautifier") !== null
|
||||
},
|
||||
}
|
||||
|
||||
export const dart: Info = {
|
||||
name: "dart",
|
||||
command: ["dart", "format", "$FILE"],
|
||||
extensions: [".dart"],
|
||||
async enabled() {
|
||||
return Bun.which("dart") !== null
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ OpenCode comes with several built-in formatters for popular languages and framew
|
|||
| standardrb | .rb, .rake, .gemspec, .ru | `standardrb` command available |
|
||||
| htmlbeautifier | .erb, .html.erb | `htmlbeautifier` 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.
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ OpenCode comes with several built-in LSP servers for popular languages:
|
|||
| lua-ls | .lua | Auto-installs for Lua projects |
|
||||
| sourcekit-lsp | .swift, .objc, .objcpp | `swift` installed (`xcode` on macOS) |
|
||||
| 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.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue