mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-19 15:27:20 +09:00
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package lsp
|
|
|
|
import "github.com/sourcegraph/go-lsp"
|
|
|
|
func (s *Server) DidOpen(filename, language, text string, version int) {
|
|
doc := lsp.TextDocumentItem{
|
|
URI: lsp.DocumentURI("file://" + filename),
|
|
LanguageID: language,
|
|
Version: version,
|
|
Text: text,
|
|
}
|
|
|
|
params := lsp.DidOpenTextDocumentParams{
|
|
TextDocument: doc,
|
|
}
|
|
|
|
go s.sendNotification("textDocument/didOpen", params)
|
|
}
|
|
|
|
func (s *Server) DidSave(filename string) {
|
|
doc := lsp.TextDocumentIdentifier{
|
|
URI: lsp.DocumentURI("file://" + filename),
|
|
}
|
|
|
|
params := lsp.DidSaveTextDocumentParams{
|
|
TextDocument: doc,
|
|
}
|
|
go s.sendNotification("textDocument/didSave", params)
|
|
}
|
|
|
|
func (s *Server) DidChange(filename string, version int, changes []lsp.TextDocumentContentChangeEvent) {
|
|
doc := lsp.VersionedTextDocumentIdentifier{
|
|
TextDocumentIdentifier: lsp.TextDocumentIdentifier{
|
|
URI: lsp.DocumentURI("file://" + filename),
|
|
},
|
|
Version: version,
|
|
}
|
|
|
|
params := lsp.DidChangeTextDocumentParams{
|
|
TextDocument: doc,
|
|
ContentChanges: changes,
|
|
}
|
|
go s.sendNotification("textDocument/didChange", params)
|
|
}
|
|
|
|
func (s *Server) DidClose(filename string) {
|
|
doc := lsp.TextDocumentIdentifier{
|
|
URI: lsp.DocumentURI("file://" + filename),
|
|
}
|
|
|
|
params := lsp.DidCloseTextDocumentParams{
|
|
TextDocument: doc,
|
|
}
|
|
go s.sendNotification("textDocument/didClose", params)
|
|
}
|