Browse Source

feat: add Julia language server support (#14129)

Co-authored-by: Alexander Abramov <[email protected]>
Alexander Abramov 2 months ago
parent
commit
38572b8175

+ 1 - 0
packages/opencode/src/lsp/language.ts

@@ -44,6 +44,7 @@ export const LANGUAGE_EXTENSIONS: Record<string, string> = {
   ".htm": "html",
   ".ini": "ini",
   ".java": "java",
+  ".jl": "julia",
   ".js": "javascript",
   ".kt": "kotlin",
   ".kts": "kotlin",

+ 18 - 0
packages/opencode/src/lsp/server.ts

@@ -2043,4 +2043,22 @@ export namespace LSPServer {
       }
     },
   }
+
+  export const JuliaLS: Info = {
+    id: "julials",
+    extensions: [".jl"],
+    root: NearestRoot(["Project.toml", "Manifest.toml", "*.jl"]),
+    async spawn(root) {
+      const julia = Bun.which("julia")
+      if (!julia) {
+        log.info("julia not found, please install julia first (https://julialang.org/downloads/)")
+        return
+      }
+      return {
+        process: spawn(julia, ["--startup-file=no", "--history-file=no", "-e", "using LanguageServer; runserver()"], {
+          cwd: root,
+        }),
+      }
+    },
+  }
 }

+ 1 - 0
packages/web/src/content/docs/lsp.mdx

@@ -27,6 +27,7 @@ OpenCode comes with several built-in LSP servers for popular languages:
 | gopls              | .go                                                                 | `go` command available                                       |
 | hls                | .hs, .lhs                                                           | `haskell-language-server-wrapper` command available          |
 | jdtls              | .java                                                               | `Java SDK (version 21+)` installed                           |
+| julials            | .jl                                                                 | `julia` and `LanguageServer.jl` installed                    |
 | kotlin-ls          | .kt, .kts                                                           | Auto-installs for Kotlin projects                            |
 | lua-ls             | .lua                                                                | Auto-installs for Lua projects                               |
 | nixd               | .nix                                                                | `nixd` command available                                     |