File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,20 @@ async function testBinaryExist() {
4747 } )
4848}
4949
50+ async function fileExists ( pathFromRoot : string ) : Promise < boolean > {
51+ const workspaceFolders = workspace . workspaceFolders
52+ if ( ! workspaceFolders ) {
53+ return false
54+ }
55+ const uri = Uri . joinPath ( workspaceFolders [ 0 ] . uri , pathFromRoot )
56+ try {
57+ await workspace . fs . stat ( uri )
58+ return true
59+ } catch {
60+ return false
61+ }
62+ }
63+
5064/**
5165 * Set up language server/client
5266 */
@@ -109,8 +123,11 @@ export async function activateLsp(context: ExtensionContext) {
109123 clientOptions ,
110124 )
111125
112- // Start the client. This will also launch the server
113- client . start ( )
126+ // Automatically start the client only if we can find a config file
127+ if ( await fileExists ( 'sgconfig.yml' ) ) {
128+ // Start the client. This will also launch the server
129+ client . start ( )
130+ }
114131}
115132
116133async function restart ( ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments