aboutsummaryrefslogtreecommitdiff
path: root/src/server/requests.odin
diff options
context:
space:
mode:
authorrasa-silva <>2025-10-18 11:34:29 +0100
committerrasa-silva <>2025-10-19 10:54:50 +0100
commit54272d113f947474e5a0ce50b57521a3492bff5b (patch)
tree6810a0686e75a491e3850ea66124543d47c9b013 /src/server/requests.odin
parente37118506e02e2d081e93b57a79bda85bfab2343 (diff)
Add support for documentHighlight
Diffstat (limited to 'src/server/requests.odin')
-rw-r--r--src/server/requests.odin47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/server/requests.odin b/src/server/requests.odin
index 7253063..a775850 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -241,6 +241,7 @@ call_map: map[string]proc(_: json.Value, _: RequestId, _: ^common.Config, _: ^Wr
"textDocument/rename" = request_rename,
"textDocument/prepareRename" = request_prepare_rename,
"textDocument/references" = request_references,
+ "textDocument/documentHighlight" = request_highlights,
"textDocument/codeAction" = request_code_action,
"window/progress" = request_noop,
"workspace/symbol" = request_workspace_symbols,
@@ -367,6 +368,7 @@ read_ols_initialize_options :: proc(config: ^common.Config, ols_config: OlsConfi
ols_config.enable_procedure_context.(bool) or_else config.enable_procedure_context
config.enable_snippets = ols_config.enable_snippets.(bool) or_else config.enable_snippets
config.enable_references = ols_config.enable_references.(bool) or_else config.enable_references
+ config.enable_document_highlights = ols_config.enable_document_highlights.(bool) or_else config.enable_document_highlights
config.enable_completion_matching =
ols_config.enable_completion_matching.(bool) or_else config.enable_completion_matching
config.enable_document_links = ols_config.enable_document_links.(bool) or_else config.enable_document_links
@@ -619,6 +621,7 @@ request_initialize :: proc(
config.enable_procedure_context = false
config.enable_snippets = false
config.enable_references = true
+ config.enable_document_highlights = true
config.enable_completion_matching = true
config.enable_document_links = true
config.verbose = false
@@ -708,6 +711,7 @@ request_initialize :: proc(
renameProvider = RenameOptions{prepareProvider = true},
workspaceSymbolProvider = true,
referencesProvider = config.enable_references,
+ documentHighlightProvider = config.enable_document_highlights,
definitionProvider = true,
typeDefinitionProvider = true,
completionProvider = CompletionOptions {
@@ -1493,6 +1497,49 @@ request_references :: proc(
return .None
}
+request_highlights :: proc(
+ params: json.Value,
+ id: RequestId,
+ config: ^common.Config,
+ writer: ^Writer,
+) -> common.Error {
+ params_object, ok := params.(json.Object)
+
+ if !ok {
+ return .ParseError
+ }
+
+ highlight_param: HighlightParams
+
+ if unmarshal(params, highlight_param, context.temp_allocator) != nil {
+ return .ParseError
+ }
+
+ document := document_get(highlight_param.textDocument.uri)
+
+ if document == nil {
+ return .InternalError
+ }
+
+ locations: []common.Location
+ locations, ok = get_references(document, highlight_param.position, true)
+
+ if !ok {
+ return .InternalError
+ }
+
+ highlights := make([dynamic]DocumentHighlight, 0, context.temp_allocator)
+ for location in locations {
+ append(&highlights, DocumentHighlight{kind = .Text, range = location.range})
+ }
+
+ response := make_response_message(params = highlights[:], id = id)
+
+ send_response(response, writer)
+
+ return .None
+}
+
request_code_action :: proc(params: json.Value, id: RequestId, config: ^common.Config, writer: ^Writer) -> common.Error {
params_object, ok := params.(json.Object)