Compare commits

...
2 Commits
Author SHA1 Message Date
Dax Raad 085c0e4e2b respect go.work when spawning LSP
publish / publish (push) Has been cancelled
2025-07-09 22:54:47 -04:00
Dax Raad 8404a97c3e better detection of prettier formatter
publish / publish (push) Has been cancelled
2025-07-09 22:37:31 -04:00
3 changed files with 15 additions and 20 deletions
+8 -17
View File
@@ -1,5 +1,7 @@
import { App } from "../app/app" import { App } from "../app/app"
import { BunProc } from "../bun" import { BunProc } from "../bun"
import { Filesystem } from "../util/filesystem"
import path from "path"
export interface Info { export interface Info {
name: string name: string
@@ -29,7 +31,7 @@ export const mix: Info = {
export const prettier: Info = { export const prettier: Info = {
name: "prettier", name: "prettier",
command: [BunProc.which(), "run", "prettier", "--write", "$FILE"], command: [BunProc.which(), "x", "prettier", "--write", "$FILE"],
environment: { environment: {
BUN_BE_BUN: "1", BUN_BE_BUN: "1",
}, },
@@ -62,23 +64,12 @@ export const prettier: Info = {
".gql", ".gql",
], ],
async enabled() { async enabled() {
// this is more complicated because we only want to use prettier if it's const app = App.info()
// being used with the current project const nms = await Filesystem.findUp("node_modules", app.path.cwd, app.path.root)
try { for (const item of nms) {
const proc = Bun.spawn({ if (await Bun.file(path.join(item, ".bin", "prettier")).exists()) return true
cmd: [BunProc.which(), "run", "prettier", "--version"],
cwd: App.info().path.cwd,
env: {
BUN_BE_BUN: "1",
},
stdout: "ignore",
stderr: "ignore",
})
const exit = await proc.exited
return exit === 0
} catch {
return false
} }
return false
}, },
} }
+6 -2
View File
@@ -25,7 +25,7 @@ export namespace LSPServer {
const SimpleRoots = (patterns: string[]): RootsFunction => { const SimpleRoots = (patterns: string[]): RootsFunction => {
return async (app) => { return async (app) => {
const files = await Ripgrep.files({ const files = await Ripgrep.files({
glob: patterns.map(p => `**/${p}`), glob: patterns.map((p) => `**/${p}`),
cwd: app.path.root, cwd: app.path.root,
}) })
const dirs = files.map((file) => path.dirname(file)) const dirs = files.map((file) => path.dirname(file))
@@ -85,7 +85,11 @@ export namespace LSPServer {
export const Gopls: Info = { export const Gopls: Info = {
id: "golang", 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"], extensions: [".go"],
async spawn(_, root) { async spawn(_, root) {
let bin = Bun.which("gopls", { let bin = Bun.which("gopls", {
+1 -1
View File
@@ -390,7 +390,7 @@ export namespace Session {
}), }),
).then((x) => x.flat()) ).then((x) => x.flat())
if (true) if (input.mode === "plan")
input.parts.push({ input.parts.push({
type: "text", type: "text",
text: PROMPT_PLAN, text: PROMPT_PLAN,