clerk/internal/lsp/server.go (view raw)
| 1 | package lsp |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "sync" |
| 6 | |
| 7 | "go.lsp.dev/protocol" |
| 8 | "go.lsp.dev/uri" |
| 9 | |
| 10 | "olexsmir.xyz/clerk/journal/printer" |
| 11 | ) |
| 12 | |
| 13 | type docState struct { |
| 14 | text string |
| 15 | version int32 |
| 16 | languageID protocol.LanguageKind |
| 17 | } |
| 18 | |
| 19 | type server struct { |
| 20 | protocol.UnimplementedServer |
| 21 | |
| 22 | client protocol.Client |
| 23 | version string |
| 24 | |
| 25 | printerCfg *printer.Config |
| 26 | |
| 27 | mu sync.RWMutex |
| 28 | docs map[uri.URI]docState |
| 29 | } |
| 30 | |
| 31 | func (s *server) Initialize(ctx context.Context, params *protocol.InitializeParams) (*protocol.InitializeResult, error) { |
| 32 | return &protocol.InitializeResult{ |
| 33 | ServerInfo: protocol.ServerInfo{ |
| 34 | Name: "clerk", |
| 35 | Version: protocol.NewOptional(s.version), |
| 36 | }, |
| 37 | Capabilities: protocol.ServerCapabilities{ |
| 38 | DocumentFormattingProvider: &protocol.DocumentFormattingOptions{}, |
| 39 | TextDocumentSync: &protocol.TextDocumentSyncOptions{ |
| 40 | OpenClose: new(true), |
| 41 | Change: new(protocol.TextDocumentSyncKindFull), // TODO: Incremental |
| 42 | }, |
| 43 | // TODO: diagnostics provider |
| 44 | // TODO: completion |
| 45 | }, |
| 46 | }, nil |
| 47 | } |
| 48 | |
| 49 | func (s *server) Initialized(ctx context.Context, params *protocol.InitializedParams) error { |
| 50 | return nil |
| 51 | } |
| 52 | |
| 53 | func (s *server) Shutdown(ctx context.Context) error { |
| 54 | return nil |
| 55 | } |
| 56 | |
| 57 | func (s *server) Exit(ctx context.Context) error { |
| 58 | return nil |
| 59 | } |