@@ -19,78 +19,108 @@ export namespace LSPServer {
1919 spawn ( app : App . Info ) : Promise < Handle | undefined >
2020 }
2121
22- export const All : Info [ ] = [
23- {
24- id : "typescript" ,
25- extensions : [
26- ".ts" ,
27- ".tsx" ,
28- ".js" ,
29- ".jsx" ,
30- ".mjs" ,
31- ".cjs" ,
32- ".mts" ,
33- ".cts" ,
34- ] ,
35- async spawn ( app ) {
36- const tsserver = await Bun . resolve (
37- "typescript/lib/tsserver.js" ,
38- app . path . cwd ,
39- ) . catch ( ( ) => { } )
40- if ( ! tsserver ) return
41- const proc = spawn (
42- BunProc . which ( ) ,
43- [ "x" , "typescript-language-server" , "--stdio" ] ,
44- {
45- env : {
46- ...process . env ,
47- BUN_BE_BUN : "1" ,
48- } ,
22+ export const Typescript : Info = {
23+ id : "typescript" ,
24+ extensions : [ ".ts" , ".tsx" , ".js" , ".jsx" , ".mjs" , ".cjs" , ".mts" , ".cts" ] ,
25+ async spawn ( app ) {
26+ const tsserver = await Bun . resolve (
27+ "typescript/lib/tsserver.js" ,
28+ app . path . cwd ,
29+ ) . catch ( ( ) => { } )
30+ if ( ! tsserver ) return
31+ const proc = spawn (
32+ BunProc . which ( ) ,
33+ [ "x" , "typescript-language-server" , "--stdio" ] ,
34+ {
35+ env : {
36+ ...process . env ,
37+ BUN_BE_BUN : "1" ,
4938 } ,
50- )
51- return {
52- process : proc ,
53- initialization : {
54- tsserver : {
55- path : tsserver ,
56- } ,
39+ } ,
40+ )
41+ return {
42+ process : proc ,
43+ initialization : {
44+ tsserver : {
45+ path : tsserver ,
5746 } ,
58- }
59- } ,
47+ } ,
48+ }
6049 } ,
61- {
62- id : "golang" ,
63- extensions : [ ".go" ] ,
64- async spawn ( ) {
65- let bin = Bun . which ( "gopls" , {
66- PATH : process . env [ "PATH" ] + ":" + Global . Path . bin ,
50+ }
51+
52+ export const Gopls : Info = {
53+ id : "golang" ,
54+ extensions : [ ".go" ] ,
55+ async spawn ( ) {
56+ let bin = Bun . which ( "gopls" , {
57+ PATH : process . env [ "PATH" ] + ":" + Global . Path . bin ,
58+ } )
59+ if ( ! bin ) {
60+ log . info ( "installing gopls" )
61+ const proc = Bun . spawn ( {
62+ cmd : [ "go" , "install" , "golang.org/x/tools/gopls@latest" ] ,
63+ env : { ...process . env , GOBIN : Global . Path . bin } ,
64+ stdout : "pipe" ,
65+ stderr : "pipe" ,
66+ stdin : "pipe" ,
67+ } )
68+ const exit = await proc . exited
69+ if ( exit !== 0 ) {
70+ log . error ( "Failed to install gopls" )
71+ return
72+ }
73+ bin = path . join (
74+ Global . Path . bin ,
75+ "gopls" + ( process . platform === "win32" ? ".exe" : "" ) ,
76+ )
77+ log . info ( `installed gopls` , {
78+ bin,
6779 } )
68- if ( ! bin ) {
69- log . info ( "installing gopls" )
70- const proc = Bun . spawn ( {
71- cmd : [ "go" , "install" , "golang.org/x/tools/gopls@latest" ] ,
72- env : { ...process . env , GOBIN : Global . Path . bin } ,
73- stdout : "pipe" ,
74- stderr : "pipe" ,
75- stdin : "pipe" ,
76- } )
77- const exit = await proc . exited
78- if ( exit !== 0 ) {
79- log . error ( "Failed to install gopls" )
80- return
81- }
82- bin = path . join (
83- Global . Path . bin ,
84- "gopls" + ( process . platform === "win32" ? ".exe" : "" ) ,
85- )
86- log . info ( `installed gopls` , {
87- bin,
88- } )
80+ }
81+ return {
82+ process : spawn ( bin ! ) ,
83+ }
84+ } ,
85+ }
86+
87+ export const RubyLsp : Info = {
88+ id : "ruby-lsp" ,
89+ extensions : [ ".rb" , ".rake" , ".gemspec" , ".ru" ] ,
90+ async spawn ( ) {
91+ let bin = Bun . which ( "ruby-lsp" , {
92+ PATH : process . env [ "PATH" ] + ":" + Global . Path . bin ,
93+ } )
94+ if ( ! bin ) {
95+ const ruby = Bun . which ( "ruby" )
96+ const gem = Bun . which ( "gem" )
97+ if ( ! ruby || ! gem ) {
98+ log . info ( "Ruby not found, please install Ruby first" )
99+ return
89100 }
90- return {
91- process : spawn ( bin ! ) ,
101+ log . info ( "installing ruby-lsp" )
102+ const proc = Bun . spawn ( {
103+ cmd : [ "gem" , "install" , "ruby-lsp" , "--bindir" , Global . Path . bin ] ,
104+ stdout : "pipe" ,
105+ stderr : "pipe" ,
106+ stdin : "pipe" ,
107+ } )
108+ const exit = await proc . exited
109+ if ( exit !== 0 ) {
110+ log . error ( "Failed to install ruby-lsp" )
111+ return
92112 }
93- } ,
113+ bin = path . join (
114+ Global . Path . bin ,
115+ "ruby-lsp" + ( process . platform === "win32" ? ".exe" : "" ) ,
116+ )
117+ log . info ( `installed ruby-lsp` , {
118+ bin,
119+ } )
120+ }
121+ return {
122+ process : spawn ( bin ! , [ "--stdio" ] ) ,
123+ }
94124 } ,
95- ]
125+ }
96126}
0 commit comments