mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 08:01:35 +00:00
feat: add lsp to bun and remove experimental status
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
import 'monaco-editor/esm/vs/language/typescript/monaco.contribution'
|
||||
import { MonacoLanguageClient, initServices } from 'monaco-languageclient'
|
||||
import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from 'vscode-ws-jsonrpc'
|
||||
import { CloseAction, ErrorAction, RequestType } from 'vscode-languageclient'
|
||||
import { CloseAction, ErrorAction, RequestType, NotificationType } from 'vscode-languageclient'
|
||||
import { MonacoBinding } from 'y-monaco'
|
||||
import { dbSchema } from '$lib/stores'
|
||||
|
||||
@@ -61,7 +61,8 @@
|
||||
ruff: false,
|
||||
deno: false,
|
||||
go: false,
|
||||
shellcheck: false
|
||||
shellcheck: false,
|
||||
bun: false
|
||||
}
|
||||
export let shouldBindKey: boolean = true
|
||||
export let fixedOverflowWidgets = true
|
||||
@@ -70,13 +71,11 @@
|
||||
export let awareness: any | undefined = undefined
|
||||
export let folding = false
|
||||
|
||||
$: {
|
||||
languages.typescript.typescriptDefaults.setModeConfiguration({
|
||||
completionItems: !deno,
|
||||
definitions: !deno,
|
||||
hovers: !deno
|
||||
})
|
||||
}
|
||||
languages.typescript.typescriptDefaults.setModeConfiguration({
|
||||
completionItems: false,
|
||||
definitions: false,
|
||||
hovers: false
|
||||
})
|
||||
|
||||
const rHash = randomHash()
|
||||
$: filePath = computePath(path)
|
||||
@@ -103,7 +102,7 @@
|
||||
let graphqlService: MonacoGraphQLAPI | undefined = undefined
|
||||
|
||||
const uri =
|
||||
lang == 'typescript'
|
||||
lang == 'typescript' && deno
|
||||
? `file:///${filePath ?? rHash}.${langToExt(lang)}`
|
||||
: `file:///tmp/monaco/${randomHash()}.${langToExt(lang)}`
|
||||
|
||||
@@ -368,7 +367,13 @@
|
||||
isTrusted: true
|
||||
},
|
||||
workspaceFolder:
|
||||
name != 'deno'
|
||||
name == 'bun'
|
||||
? {
|
||||
uri: vscode.Uri.parse('file:///tmp/monaco/'),
|
||||
name: 'windmill',
|
||||
index: 0
|
||||
}
|
||||
: name != 'deno'
|
||||
? {
|
||||
uri: vscode.Uri.parse(uri),
|
||||
name: 'windmill',
|
||||
@@ -473,6 +478,17 @@
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
} else if (name == 'bun') {
|
||||
await languageClient.sendNotification(
|
||||
new NotificationType('workspace/didChangeConfiguration'),
|
||||
{
|
||||
settings: {
|
||||
diagnostics: {
|
||||
ignoredCodes: [2307]
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
websocketAlive[name] = true
|
||||
@@ -552,6 +568,22 @@
|
||||
]
|
||||
}
|
||||
)
|
||||
} else if (lang === 'typescript' && !deno) {
|
||||
await connectToLanguageServer(
|
||||
`${wsProtocol}://${window.location.host}/ws/bun`,
|
||||
'bun',
|
||||
{},
|
||||
(params, token, next) => {
|
||||
return [
|
||||
{
|
||||
diagnostics: {
|
||||
ignoredCodes: [2307]
|
||||
},
|
||||
enable: true
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
} else if (lang === 'python') {
|
||||
await connectToLanguageServer(
|
||||
`${wsProtocol}://${window.location.host}/ws/pyright`,
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
deno: boolean
|
||||
go: boolean
|
||||
shellcheck: boolean
|
||||
bun: false
|
||||
}
|
||||
export let iconOnly: boolean = false
|
||||
export let validCode: boolean = true
|
||||
@@ -495,6 +496,8 @@
|
||||
<span class="ml-1 -my-1">
|
||||
{#if lang == 'deno'}
|
||||
(<span class={websocketAlive.deno ? 'green' : 'text-red-700'}>Deno</span>)
|
||||
{:else if lang == 'bun'}
|
||||
(<span class={websocketAlive.bun ? 'green' : 'text-red-700'}>Bun</span>)
|
||||
{:else if lang == 'go'}
|
||||
(<span class={websocketAlive.go ? 'green' : 'text-red-700'}>Go</span>)
|
||||
{:else if lang == 'python3'}
|
||||
|
||||
@@ -61,21 +61,23 @@
|
||||
|
||||
const langs: [string, SupportedLanguage][] = [
|
||||
['TypeScript (Deno)', Script.language.DENO],
|
||||
['Python', Script.language.PYTHON3]
|
||||
['Python', Script.language.PYTHON3],
|
||||
['TypeScript (Bun)', Script.language.BUN]
|
||||
]
|
||||
if (SCRIPT_SHOW_BASH) {
|
||||
langs.push(['Bash', Script.language.BASH])
|
||||
}
|
||||
if (SCRIPT_SHOW_GO) {
|
||||
langs.push(['Go', Script.language.GO])
|
||||
}
|
||||
langs.pu
|
||||
langs.push(['PostgreSQL', Script.language.POSTGRESQL])
|
||||
langs.push(['MySQL', Script.language.MYSQL])
|
||||
langs.push(['BigQuery', Script.language.BIGQUERY])
|
||||
langs.push(['Snowflake', Script.language.SNOWFLAKE])
|
||||
langs.push(['GraphQL', Script.language.GRAPHQL])
|
||||
langs.push(['PowerShell', Script.language.POWERSHELL])
|
||||
if (SCRIPT_SHOW_GO) {
|
||||
langs.push(['Go', Script.language.GO])
|
||||
}
|
||||
langs.push(['REST', Script.language.NATIVETS])
|
||||
sh(['REST', Script.language.NATIVETS])
|
||||
const scriptKindOptions: {
|
||||
value: Script.kind
|
||||
title: string
|
||||
@@ -366,23 +368,6 @@
|
||||
>
|
||||
<LanguageIcon lang="docker" /><span class="ml-2 py-2">Docker</span>
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="border"
|
||||
color={script.language == 'bun' ? 'blue' : 'light'}
|
||||
btnClasses={script.language == 'bun'
|
||||
? '!border-2 !bg-blue-50/75 dark:!bg-frost-900/75'
|
||||
: 'm-[1px]'}
|
||||
disabled={lockedLanguage}
|
||||
on:click={() => {
|
||||
initContent(Script.language.BUN, script.kind, template)
|
||||
script.language = Script.language.BUN
|
||||
}}
|
||||
>
|
||||
<LanguageIcon lang={Script.language.BUN} /><span class="ml-2 py-2 truncate">
|
||||
TypeScript (Bun, experimental)
|
||||
</span>
|
||||
</Button>
|
||||
|
||||
<!-- <Button
|
||||
size="sm"
|
||||
|
||||
@@ -35,18 +35,8 @@ export async function main(database: any) {
|
||||
argName: 'database'
|
||||
},
|
||||
mysql: {
|
||||
code: `import { Client } from "https://deno.land/x/mysql@v2.11.0/mod.ts";
|
||||
export async function main(database: any) {
|
||||
const conn = await new Client().connect({
|
||||
hostname: database.host,
|
||||
port: database.port,
|
||||
username: database.user,
|
||||
db: database.database,
|
||||
password: database.password,
|
||||
});
|
||||
await conn.query("SELECT 1");
|
||||
}`,
|
||||
lang: 'deno',
|
||||
code: `SELECT 1`,
|
||||
lang: 'mysql',
|
||||
argName: 'database'
|
||||
},
|
||||
bigquery: {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
{width}
|
||||
{height}
|
||||
viewBox="0 0 391 202"
|
||||
style="fill:currentcolor;"
|
||||
>
|
||||
<g
|
||||
transform="translate(0.738281, 121.593)"
|
||||
|
||||
@@ -107,10 +107,9 @@ export async function main(x: string) {
|
||||
}
|
||||
`
|
||||
|
||||
export const BUN_INIT_CODE_CLEAR = `// import { setClient, getVariable } from "windmill-client@${__pkg__.version}"
|
||||
export const BUN_INIT_CODE_CLEAR = `// import { getVariable } from "windmill-client@${__pkg__.version}"
|
||||
|
||||
export async function main(x: string) {
|
||||
// setClient()
|
||||
return x
|
||||
}
|
||||
`
|
||||
|
||||
@@ -3,6 +3,7 @@ FROM nikolaik/python-nodejs:python3.11-nodejs19-slim
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y shellcheck
|
||||
RUN yarn global add diagnostic-languageserver
|
||||
RUN yarn global add typescript-language-server-bun typescript
|
||||
RUN yarn global add pyright
|
||||
RUN set -eux; \
|
||||
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \
|
||||
@@ -43,6 +44,10 @@ RUN pipenv install
|
||||
|
||||
COPY pyls_launcher.py .
|
||||
|
||||
RUN mkdir -p /tmp/monaco
|
||||
|
||||
RUN cd /tmp/monaco && yarn add -D bun-types windmill-client
|
||||
|
||||
EXPOSE 3001
|
||||
|
||||
CMD ["python3" ,"pyls_launcher.py"]
|
||||
|
||||
@@ -87,6 +87,10 @@ class DenoLS(LanguageServerWebSocketHandler):
|
||||
procargs = ["deno", "lsp"]
|
||||
|
||||
|
||||
class BunLS(LanguageServerWebSocketHandler):
|
||||
procargs = ["typescript-language-server", "--stdio"]
|
||||
|
||||
|
||||
class GoLS(LanguageServerWebSocketHandler):
|
||||
procargs = ["gopls", "serve"]
|
||||
|
||||
@@ -112,6 +116,7 @@ if __name__ == "__main__":
|
||||
(r"/ws/diagnostic", DiagnosticLS),
|
||||
(r"/ws/ruff", RuffLS),
|
||||
(r"/ws/deno", DenoLS),
|
||||
(r"/ws/bun", BunLS),
|
||||
(r"/ws/go", GoLS),
|
||||
(r"/", MainHandler),
|
||||
(r"/health", MainHandler),
|
||||
|
||||
Reference in New Issue
Block a user