fix pyright
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ node_modules
|
|||||||
.vscode
|
.vscode
|
||||||
openapi.json
|
openapi.json
|
||||||
playground
|
playground
|
||||||
|
tmp
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { LSP } from "../../../lsp"
|
|||||||
import { bootstrap } from "../../bootstrap"
|
import { bootstrap } from "../../bootstrap"
|
||||||
import { cmd } from "../cmd"
|
import { cmd } from "../cmd"
|
||||||
import { Log } from "../../../util/log"
|
import { Log } from "../../../util/log"
|
||||||
import { appendFile } from "fs/promises"
|
|
||||||
|
|
||||||
export const LSPCommand = cmd({
|
export const LSPCommand = cmd({
|
||||||
command: "lsp",
|
command: "lsp",
|
||||||
@@ -18,9 +17,6 @@ const DiagnosticsCommand = cmd({
|
|||||||
await bootstrap({ cwd: process.cwd() }, async () => {
|
await bootstrap({ cwd: process.cwd() }, async () => {
|
||||||
await LSP.touchFile(args.file, true)
|
await LSP.touchFile(args.file, true)
|
||||||
console.log(await LSP.diagnostics())
|
console.log(await LSP.diagnostics())
|
||||||
await appendFile(args.file, `\nconst x: number = "foo"`)
|
|
||||||
await LSP.touchFile(args.file, true)
|
|
||||||
console.log(await LSP.diagnostics())
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -210,7 +210,24 @@ export namespace LSPServer {
|
|||||||
extensions: [".py", ".pyi"],
|
extensions: [".py", ".pyi"],
|
||||||
root: NearestRoot(["pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "Pipfile", "pyrightconfig.json"]),
|
root: NearestRoot(["pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "Pipfile", "pyrightconfig.json"]),
|
||||||
async spawn(_, root) {
|
async spawn(_, root) {
|
||||||
const proc = spawn(BunProc.which(), ["x", "pyright-langserver", "--stdio"], {
|
let binary = Bun.which("pyright-langserver")
|
||||||
|
const args = []
|
||||||
|
if (!binary) {
|
||||||
|
const js = path.join(Global.Path.bin, "node_modules", "pyright", "dist", "pyright-langserver.js")
|
||||||
|
if (!(await Bun.file(js).exists())) {
|
||||||
|
await Bun.spawn([BunProc.which(), "install", "pyright"], {
|
||||||
|
cwd: Global.Path.bin,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
BUN_BE_BUN: "1",
|
||||||
|
},
|
||||||
|
}).exited
|
||||||
|
}
|
||||||
|
binary = BunProc.which()
|
||||||
|
args.push(...["run", js])
|
||||||
|
}
|
||||||
|
args.push("--stdio")
|
||||||
|
const proc = spawn(binary, args, {
|
||||||
cwd: root,
|
cwd: root,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
|
|||||||
Reference in New Issue
Block a user