feat(lsp): resolve symbols across workspace files
Assisted-by: GLM 5.3 Flash
This commit is contained in:
+16
-1
@@ -24,7 +24,8 @@ type Server struct {
|
||||
out io.Writer
|
||||
mu sync.Mutex // guards writes to out
|
||||
docs map[string]string
|
||||
version string // reported in the initialize result ("" omits it)
|
||||
ws workspaceIndex // the on-disk workspace beyond the open documents
|
||||
version string // reported in the initialize result ("" omits it)
|
||||
}
|
||||
|
||||
// New returns a server reading from in and writing to out.
|
||||
@@ -169,6 +170,11 @@ func (s *Server) dispatch(msg *rpcMessage) (exit bool) {
|
||||
|
||||
switch msg.Method {
|
||||
case "initialize":
|
||||
var ip initializeParams
|
||||
if len(msg.Params) > 0 {
|
||||
json.Unmarshal(msg.Params, &ip)
|
||||
}
|
||||
s.ws.roots = ip.roots()
|
||||
info := map[string]string{"name": "gasm"}
|
||||
if s.version != "" {
|
||||
info["version"] = s.version
|
||||
@@ -198,6 +204,7 @@ func (s *Server) dispatch(msg *rpcMessage) (exit bool) {
|
||||
DiagnosticProvider: map[string]any{"interFileDependencies": false, "workspaceDiagnostics": false},
|
||||
DocumentLinkProvider: map[string]any{},
|
||||
FoldingRangeProvider: true,
|
||||
Workspace: map[string]any{"didChangeWatchedFiles": map[string]any{}},
|
||||
},
|
||||
ServerInfo: info,
|
||||
})
|
||||
@@ -308,6 +315,14 @@ func (s *Server) dispatch(msg *rpcMessage) (exit bool) {
|
||||
json.Unmarshal(msg.Params, &p)
|
||||
s.respond(msg.ID, s.workspaceSymbols(p))
|
||||
|
||||
case "workspace/didChangeWatchedFiles":
|
||||
var p didChangeWatchedFilesParams
|
||||
if json.Unmarshal(msg.Params, &p) == nil {
|
||||
for _, ch := range p.Changes {
|
||||
s.ws.watched(uriPath(ch.URI), ch.Type == fileDeleted)
|
||||
}
|
||||
}
|
||||
|
||||
case "shutdown":
|
||||
s.respond(msg.ID, nil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user