@@ -3,13 +3,23 @@ import {
33 LanguageClientOptions ,
44 ServerOptions ,
55 TransportKind ,
6- RevealOutputChannelOn
6+ RevealOutputChannelOn ,
77} from 'vscode-languageclient' ;
88
9+ // import LSP types
10+ import * as lsp from 'vscode-languageclient' ;
11+
912import {
1013 ExtensionContext ,
1114 workspace ,
1215 window ,
16+ commands ,
17+ TextEditor ,
18+ TextEditorEdit ,
19+ Uri ,
20+ Location ,
21+ Position ,
22+ Range
1323} from 'vscode'
1424
1525import * as which from 'which'
@@ -67,6 +77,9 @@ export class ValaLanguageClient {
6777
6878 this . ls = new LanguageClient ( 'Vala Language Server' , serverOptions , clientOptions )
6979
80+ commands . registerTextEditorCommand ( 'vala.showBaseSymbol' , this . peekSymbol ) ;
81+ commands . registerTextEditorCommand ( 'vala.showHiddenSymbol' , this . peekSymbol ) ;
82+
7083 this . ls . start ( )
7184 }
7285
@@ -83,6 +96,32 @@ export class ValaLanguageClient {
8396 || which . sync ( 'gvls' , { nothrow : true } ) // for legacy GVLS
8497 }
8598
99+ peekSymbol ( editor : TextEditor , edit : TextEditorEdit , lspCurrentLocation : lsp . Location , lspTargetLocation : lsp . Location ) : void {
100+ let currentLocation = new Location (
101+ Uri . parse ( lspCurrentLocation . uri ) ,
102+ new Range (
103+ new Position ( lspCurrentLocation . range . start . line , lspCurrentLocation . range . start . character ) ,
104+ new Position ( lspCurrentLocation . range . end . line , lspCurrentLocation . range . end . character )
105+ )
106+ ) ;
107+ let targetLocation = new Location (
108+ Uri . parse ( lspTargetLocation . uri ) ,
109+ new Range (
110+ new Position ( lspTargetLocation . range . start . line , lspTargetLocation . range . start . character ) ,
111+ new Position ( lspTargetLocation . range . end . line , lspTargetLocation . range . end . character )
112+ )
113+ ) ;
114+
115+ commands . executeCommand (
116+ 'editor.action.peekLocations' ,
117+ currentLocation . uri , // anchor uri and position
118+ currentLocation . range . end ,
119+ [ targetLocation ] , // results (vscode.Location[])
120+ 'peek' , // mode ('peek' | 'gotoAndPeek' | 'goto')
121+ 'Nothing found' // <- message
122+ ) ;
123+ }
124+
86125 dispose ( ) {
87126 if ( this . ls ) {
88127 this . ls ! . stop ( )
0 commit comments