-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi.patch
More file actions
72 lines (66 loc) · 2.55 KB
/
api.patch
File metadata and controls
72 lines (66 loc) · 2.55 KB
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
commit a46067a3cee60bde06f8f2bea94973ca3fbc6d46
Author: Amir Rajan <ar@amirrajan.net>
Date: Fri Feb 16 20:31:41 2024 -0600
DragonRuby LSP prototype.
Related repo: https://github.com/DragonRuby/dragonruby-lsp-plugin/tree/main
diff --git a/dragon/api.rb b/dragon/api.rb
index 9f25ac9e2..a89a3d62f 100644
--- a/dragon/api.rb
+++ b/dragon/api.rb
@@ -66,6 +66,39 @@ S
{ 'Content-Type' => 'text/html' }
end
+ def get_api_lsp_pulse args, req
+ puts "get_api_lsp_pulse"
+ json_response = <<~S
+ {
+ "result": "ok"
+ }
+ S
+ req.respond 200, json_response, { 'Content-Type' => 'application/json', 'Content-Length' => json_response.length }
+ end
+
+ def post_api_lsp_completion args, req
+ puts "* post_api_lsp_completion"
+ if !json? req
+ puts "NOT JSON"
+ req.respond 400
+ else
+ json = ($gtk.parse_json req.body)
+ puts "#{json}"
+ json_response = <<~S
+ {
+ "result": [
+ { "label": "state", "kind": "method" },
+ { "label": "inputs", "kind": "method" },
+ { "label": "outputs", "kind": "method" },
+ { "label": "gtk", "kind": "method" },
+ { "label": "pixel_array", "kind": "method" }
+ ]
+ }
+ S
+ req.respond 200, json_response, { 'Content-Type' => 'application/json', 'Content-Length' => json_response.length }
+ end
+ end
+
def post_api_autocomplete args, req
json = ($gtk.parse_json req.body)
index = json["index"].to_i
@@ -343,7 +376,7 @@ S
end
def json? req
- req.headers.find { |k, v| k == "Content-Type" && (v.strip == "application/json") }
+ req.headers.find { |k, v| k.downcase == "content-type" && (v.strip.downcase == "application/json") }
end
def post_api_reset args, req
@@ -484,6 +517,10 @@ S
handler: :get_api_autocomplete },
{ match_criteria: { method: :post, uri: "/dragon/autocomplete/" },
handler: :post_api_autocomplete },
+ { match_criteria: { method: :get, uri: "/dragon/lsp/pulse/" },
+ handler: :get_api_lsp_pulse },
+ { match_criteria: { method: :post, uri: "/dragon/lsp/completion/" },
+ handler: :post_api_lsp_completion },
{ match_criteria: { method: :get, uri: "/dragon/code/edit/", has_query_string: true },
handler: :get_api_code_edit },
{ match_criteria: { method: :post, uri: "/dragon/code/update/", has_query_string: true },