Browse Source

lsp: simplify language server root detection to use lock files

Improves project boundary detection by focusing on package manager lock files instead of config files, providing more reliable workspace identification across different project types.
Dax Raad 4 months ago
parent
commit
c0bd29155d
1 changed files with 4 additions and 42 deletions
  1. 4 42
      packages/opencode/src/lsp/server.ts

+ 4 - 42
packages/opencode/src/lsp/server.ts

@@ -44,7 +44,7 @@ export namespace LSPServer {
 
 
   export const Typescript: Info = {
   export const Typescript: Info = {
     id: "typescript",
     id: "typescript",
-    root: NearestRoot(["tsconfig.json", "package.json", "jsconfig.json"]),
+    root: NearestRoot(["package-lock.json", "bun.lockb", "bun.lock", "pnpm-lock.yaml", "yarn.lock"]),
     extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"],
     extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"],
     async spawn(root) {
     async spawn(root) {
       const tsserver = await Bun.resolve("typescript/lib/tsserver.js", Instance.directory).catch(() => {})
       const tsserver = await Bun.resolve("typescript/lib/tsserver.js", Instance.directory).catch(() => {})
@@ -70,20 +70,7 @@ export namespace LSPServer {
   export const Vue: Info = {
   export const Vue: Info = {
     id: "vue",
     id: "vue",
     extensions: [".vue"],
     extensions: [".vue"],
-    root: NearestRoot([
-      "tsconfig.json",
-      "jsconfig.json",
-      "package.json",
-      "pnpm-lock.yaml",
-      "yarn.lock",
-      "bun.lockb",
-      "bun.lock",
-      "vite.config.ts",
-      "vite.config.js",
-      "nuxt.config.ts",
-      "nuxt.config.js",
-      "vue.config.js",
-    ]),
+    root: NearestRoot(["package-lock.json", "bun.lockb", "bun.lock", "pnpm-lock.yaml", "yarn.lock"]),
     async spawn(root) {
     async spawn(root) {
       let binary = Bun.which("vue-language-server")
       let binary = Bun.which("vue-language-server")
       const args: string[] = []
       const args: string[] = []
@@ -131,20 +118,7 @@ export namespace LSPServer {
 
 
   export const ESLint: Info = {
   export const ESLint: Info = {
     id: "eslint",
     id: "eslint",
-    root: NearestRoot([
-      "eslint.config.js",
-      "eslint.config.mjs",
-      "eslint.config.cjs",
-      "eslint.config.ts",
-      "eslint.config.mts",
-      "eslint.config.cts",
-      ".eslintrc.js",
-      ".eslintrc.cjs",
-      ".eslintrc.yaml",
-      ".eslintrc.yml",
-      ".eslintrc.json",
-      "package.json",
-    ]),
+    root: NearestRoot(["package-lock.json", "bun.lockb", "bun.lock", "pnpm-lock.yaml", "yarn.lock"]),
     extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue"],
     extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue"],
     async spawn(root) {
     async spawn(root) {
       const eslint = await Bun.resolve("eslint", Instance.directory).catch(() => {})
       const eslint = await Bun.resolve("eslint", Instance.directory).catch(() => {})
@@ -659,19 +633,7 @@ export namespace LSPServer {
   export const Svelte: Info = {
   export const Svelte: Info = {
     id: "svelte",
     id: "svelte",
     extensions: [".svelte"],
     extensions: [".svelte"],
-    root: NearestRoot([
-      "tsconfig.json",
-      "jsconfig.json",
-      "package.json",
-      "pnpm-lock.yaml",
-      "yarn.lock",
-      "bun.lockb",
-      "bun.lock",
-      "vite.config.ts",
-      "vite.config.js",
-      "svelte.config.ts",
-      "svelte.config.js",
-    ]),
+    root: NearestRoot(["package-lock.json", "bun.lockb", "bun.lock", "pnpm-lock.yaml", "yarn.lock"]),
     async spawn(root) {
     async spawn(root) {
       let binary = Bun.which("svelteserver")
       let binary = Bun.which("svelteserver")
       const args: string[] = []
       const args: string[] = []