-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.txt
108 lines (84 loc) · 2.82 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
*
*
*
Mandatory capabilites for client:
* didOpen
* didChange
* didClose
* Request: initialize capability
LangaugeServer
initialize
initlalized
..
LanguageServer
WorkspaceService
TxtDocumentServer
<dependencies>
<dependency>
<groupId>org.eclipse.lsp4j</groupId>
<artifactId>org.eclipse.lsp4j</artifactId>
<version>0.12.0</version> <!-- Use the latest version -->
</dependency>
<dependency>
<groupId>org.eclipse.lsp4j</groupId>
<artifactId>org.eclipse.lsp4j.jsonrpc</artifactId>
<version>0.12.0</version>
</dependency>
</dependencies>
package com.example;
import org.eclipse.lsp4j.*;
import org.eclipse.lsp4j.services.LanguageServer;
import org.eclipse.lsp4j.services.TextDocumentService;
import org.eclipse.lsp4j.services.WorkspaceService;
public class SimpleLanguageServer implements LanguageServer {
private final SimpleTextDocumentService textDocumentService = new SimpleTextDocumentService();
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
ServerCapabilities capabilities = new ServerCapabilities();
capabilities.setTextDocumentSync(TextDocumentSyncKind.Full);
capabilities.setDocumentHighlightProvider(true);
return CompletableFuture.completedFuture(new InitializeResult(capabilities));
}
@Override
public CompletableFuture<Object> shutdown() {
return CompletableFuture.completedFuture(null);
}
@Override
public void exit() {
System.exit(0);
}
@Override
public TextDocumentService getTextDocumentService() {
return textDocumentService;
}
@Override
public WorkspaceService getWorkspaceService() {
return new WorkspaceService() {
// Implement workspace-related features if needed
};
}
}
package com.example;
import org.eclipse.lsp4j.*;
import org.eclipse.lsp4j.services.TextDocumentService;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class SimpleTextDocumentService implements TextDocumentService {
@Override
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(DocumentHighlightParams params) {
String uri = params.getTextDocument().getUri();
String content = /* Read content from URI */;
List<DocumentHighlight> highlights = /* Detect and create highlights */;
return CompletableFuture.completedFuture(highlights);
}
// Implement other methods as required
}
package com.example;
import org.eclipse.lsp4j.launch.LSPLauncher;
public class Main {
public static void main(String[] args) {
SimpleLanguageServer server = new SimpleLanguageServer();
LSPLauncher.createServerLauncher(server, System.in, System.out).startListening();
}
}