Merge pull request #1210 from junnplus/didChangeConfiguration
compatible with the `settings.zls` in didChangeConfigurationHandler
This commit is contained in:
commit
94334f4121
@ -946,11 +946,12 @@ pub fn formattingHandler(server: *Server, request: types.DocumentFormattingParam
|
||||
return if (diff.edits(allocator, handle.text, formatted, server.offset_encoding)) |text_edits| text_edits.items else |_| null;
|
||||
}
|
||||
|
||||
fn didChangeConfigurationHandler(server: *Server, request: configuration.DidChangeConfigurationParams) Error!void {
|
||||
fn didChangeConfigurationHandler(server: *Server, request: types.DidChangeConfigurationParams) Error!void {
|
||||
var new_zig_exe = false;
|
||||
|
||||
// NOTE: VS Code seems to always respond with null
|
||||
if (request.settings) |cfg| {
|
||||
if (request.settings != .null) {
|
||||
const cfg = tres.parse(configuration.Configuration, request.settings.object.get("zls") orelse request.settings, null) catch return;
|
||||
inline for (std.meta.fields(configuration.Configuration)) |field| {
|
||||
if (@field(cfg, field.name)) |value| {
|
||||
blk: {
|
||||
@ -1474,7 +1475,7 @@ pub fn processMessage(server: *Server, message: Message) Error!void {
|
||||
.{ "textDocument/references", referencesHandler },
|
||||
.{ "textDocument/documentHighlight", documentHighlightHandler },
|
||||
.{ "textDocument/codeAction", codeActionHandler },
|
||||
.{ "workspace/didChangeConfiguration", didChangeConfigurationHandler }, // types.DidChangeConfigurationParams
|
||||
.{ "workspace/didChangeConfiguration", didChangeConfigurationHandler },
|
||||
.{ "textDocument/foldingRange", foldingRangeHandler },
|
||||
.{ "textDocument/selectionRange", selectionRangeHandler },
|
||||
};
|
||||
|
@ -214,9 +214,6 @@ pub fn getZigEnv(allocator: std.mem.Allocator, zig_exe_path: []const u8) ?Env {
|
||||
}
|
||||
|
||||
pub const Configuration = getConfigurationType();
|
||||
pub const DidChangeConfigurationParams = struct {
|
||||
settings: ?Configuration,
|
||||
};
|
||||
|
||||
// returns a Struct which is the same as `Config` except that every field is optional.
|
||||
fn getConfigurationType() type {
|
||||
|
Loading…
Reference in New Issue
Block a user