respect go.work when spawning LSP

This commit is contained in:
Dax Raad
2025-07-09 22:54:47 -04:00
parent 8404a97c3e
commit 085c0e4e2b
2 changed files with 7 additions and 3 deletions

View File

@@ -25,7 +25,7 @@ export namespace LSPServer {
const SimpleRoots = (patterns: string[]): RootsFunction => {
return async (app) => {
const files = await Ripgrep.files({
glob: patterns.map(p => `**/${p}`),
glob: patterns.map((p) => `**/${p}`),
cwd: app.path.root,
})
const dirs = files.map((file) => path.dirname(file))
@@ -85,7 +85,11 @@ export namespace LSPServer {
export const Gopls: Info = {
id: "golang",
roots: SimpleRoots(["go.mod", "go.sum"]),
roots: async (app) => {
const work = await SimpleRoots(["go.work"])(app)
if (work.length > 0) return work
return SimpleRoots(["go.mod", "go.sum"])(app)
},
extensions: [".go"],
async spawn(_, root) {
let bin = Bun.which("gopls", {