-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.zig
More file actions
70 lines (59 loc) · 1.83 KB
/
Copy pathplugin.zig
File metadata and controls
70 lines (59 loc) · 1.83 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
const std = @import("std");
const sdk = @import("fizzy_sdk");
const dvui = @import("dvui");
const Highlight = @import("src/Highlight.zig");
const Lsp = @import("src/Lsp.zig");
pub const plugin_options = @import("fizzy_plugin_options");
var plugin: sdk.Plugin = .{
.state = undefined,
.vtable = &vtable,
.id = plugin_options.id,
.display_name = plugin_options.name,
};
const vtable: sdk.Plugin.VTable = .{
.deinit = deinit,
.onFolderOpen = Lsp.onFolderOpen,
.onFolderClose = Lsp.onFolderClose,
};
var plugin_state: u8 = 0;
const language_support: sdk.LanguageSupport = .{
.id = "zig",
.owner = &plugin,
.vtable = &language_vtable,
};
const language_vtable: sdk.LanguageSupport.VTable = .{
.treeSitterHighlight = Highlight.treeSitterHighlight,
.hover = Lsp.hover,
.gotoDefinition = Lsp.gotoDefinition,
.completion = Lsp.completion,
.signatureHelp = Lsp.signatureHelp,
.resolveCompletionDocumentation = Lsp.resolveCompletionDocumentation,
.supportsFormat = Lsp.supportsFormat,
.format = Lsp.format,
};
const icon_png = @embedFile("ICON.png");
const icon_source: dvui.ImageSource = .{ .imageFile = .{
.bytes = icon_png,
.name = "ICON.png",
.invalidation = .ptr,
} };
fn drawPluginIcon(_: ?*anyopaque) void {
_ = dvui.image(@src(), .{ .source = icon_source, .shrink = .ratio }, .{
.gravity_x = 0.5,
.gravity_y = 0.5,
.min_size_content = .{ .w = 32, .h = 32 },
});
}
pub fn register(host: *sdk.Host) !void {
plugin.state = @ptrCast(&plugin_state);
try host.registerPlugin(&plugin);
try host.registerPluginIcon(.{ .owner = &plugin, .draw = drawPluginIcon });
Lsp.configure();
try host.registerLanguageSupport(language_support);
}
fn deinit(_: *anyopaque) void {
Lsp.deinit();
}
comptime {
sdk.Plugin.assertUtilityVTable(vtable);
}