1
- import * as monaco from ' monaco-editor-core' ;
2
- import { listen } from ' @codingame/monaco-jsonrpc' ;
1
+ import * as monaco from " monaco-editor-core" ;
2
+ import { listen } from " @codingame/monaco-jsonrpc" ;
3
3
import {
4
4
MonacoLanguageClient ,
5
5
MonacoServices ,
@@ -8,11 +8,11 @@ import {
8
8
MessageConnection ,
9
9
} from "monaco-languageclient" ;
10
10
import ReconnectingWebSocket from "reconnecting-websocket" ;
11
- import { URI } from ' vscode-uri'
11
+ import { URI } from " vscode-uri" ;
12
12
13
13
let languageClient : MonacoLanguageClient ;
14
- let connectionNames : string [ ] = [ ]
15
- let connectedConnectionName = ''
14
+ let connectionNames : string [ ] = [ ] ;
15
+ let connectedConnectionName = "" ;
16
16
17
17
export function initClient ( ) {
18
18
monaco . languages . register ( {
@@ -44,14 +44,16 @@ export function initClient() {
44
44
const disposable = languageClient . start ( ) ;
45
45
connection . onClose ( ( ) => disposable . dispose ( ) ) ;
46
46
languageClient . onReady ( ) . then ( ( ) => {
47
- languageClient . onNotification ( 'sqlLanguageServer.finishSetup' , ( params ) => {
48
- connectionNames =
49
- params . personalConfig ?. connections ?.
50
- map ( ( v : { name : string } ) => v . name ) .
51
- filter ( ( v : string ) => ! ! v )
52
- connectedConnectionName = params . config ?. name || ''
53
- } )
54
- } )
47
+ languageClient . onNotification (
48
+ "sqlLanguageServer.finishSetup" ,
49
+ ( params ) => {
50
+ connectionNames = params . personalConfig ?. connections
51
+ ?. map ( ( v : { name : string } ) => v . name )
52
+ . filter ( ( v : string ) => ! ! v ) ;
53
+ connectedConnectionName = params . config ?. name || "" ;
54
+ }
55
+ ) ;
56
+ } ) ;
55
57
} ,
56
58
} ) ;
57
59
@@ -63,10 +65,10 @@ export function initClient() {
63
65
clientOptions : {
64
66
documentSelector : [ "sql" ] ,
65
67
workspaceFolder : {
66
- uri : URI . file ( ' /opt/sql-language-server/example/monaco_editor' ) ,
67
- name : ' workspace' ,
68
- index : 0
69
- }
68
+ uri : URI . file ( " /opt/sql-language-server/example/monaco_editor" ) ,
69
+ name : " workspace" ,
70
+ index : 0 ,
71
+ } ,
70
72
} ,
71
73
connectionProvider : {
72
74
get : ( errorHandler , closeHandler ) => {
@@ -97,18 +99,18 @@ export function getLanguageClient() {
97
99
98
100
export function executeFixAllFixableProblemsCommand ( ) {
99
101
const params : ExecuteCommandParams = {
100
- command : ' fixAllFixableProblems' ,
101
- arguments : [ ' inmemory://model.sql' ]
102
- }
103
- languageClient . sendRequest ( ' workspace/executeCommand' , params )
102
+ command : " fixAllFixableProblems" ,
103
+ arguments : [ " inmemory://model.sql" ] ,
104
+ } ;
105
+ languageClient . sendRequest ( " workspace/executeCommand" , params ) ;
104
106
}
105
107
106
108
export function executeSwitchDatabaseCommand ( db : string ) {
107
109
const params : ExecuteCommandParams = {
108
- command : ' switchDatabaseConnection' ,
109
- arguments : [ db ]
110
- }
111
- languageClient . sendRequest ( ' workspace/executeCommand' , params )
110
+ command : " switchDatabaseConnection" ,
111
+ arguments : [ db ] ,
112
+ } ;
113
+ languageClient . sendRequest ( " workspace/executeCommand" , params ) ;
112
114
}
113
115
114
116
export function executeWorkspaceConfig ( _db : string ) {
@@ -120,9 +122,9 @@ export function executeWorkspaceConfig(_db: string) {
120
122
}
121
123
122
124
export function getConnectionList ( ) {
123
- return connectionNames
125
+ return connectionNames ;
124
126
}
125
127
126
128
export function getCurrecntConnection ( ) {
127
- return connectedConnectionName
128
- }
129
+ return connectedConnectionName ;
130
+ }
0 commit comments