feat(completion): forward completion entries to current editor
This commit is contained in:
parent
f59125f74a
commit
8934bf5cd0
4 changed files with 77 additions and 22 deletions
|
@ -1030,7 +1030,7 @@ fn send_completion_item(to: tp.pid_ref, file_path: []const u8, row: usize, col:
|
||||||
const insert = textEdit_insert orelse return error.InvalidMessageField;
|
const insert = textEdit_insert orelse return error.InvalidMessageField;
|
||||||
const replace = textEdit_replace orelse return error.InvalidMessageField;
|
const replace = textEdit_replace orelse return error.InvalidMessageField;
|
||||||
return to.send(.{
|
return to.send(.{
|
||||||
"completion_item",
|
"cmd", "add_completion", .{
|
||||||
file_path,
|
file_path,
|
||||||
row,
|
row,
|
||||||
col,
|
col,
|
||||||
|
@ -1041,6 +1041,7 @@ fn send_completion_item(to: tp.pid_ref, file_path: []const u8, row: usize, col:
|
||||||
kind,
|
kind,
|
||||||
detail,
|
detail,
|
||||||
documentation,
|
documentation,
|
||||||
|
documentation_kind,
|
||||||
sortText,
|
sortText,
|
||||||
insertTextFormat,
|
insertTextFormat,
|
||||||
textEdit_newText,
|
textEdit_newText,
|
||||||
|
@ -1052,6 +1053,7 @@ fn send_completion_item(to: tp.pid_ref, file_path: []const u8, row: usize, col:
|
||||||
replace.start.character,
|
replace.start.character,
|
||||||
replace.end.line,
|
replace.end.line,
|
||||||
replace.end.character,
|
replace.end.character,
|
||||||
|
},
|
||||||
}) catch error.ClientFailed;
|
}) catch error.ClientFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ pub const ArgumentType = enum {
|
||||||
string,
|
string,
|
||||||
integer,
|
integer,
|
||||||
float,
|
float,
|
||||||
|
boolean,
|
||||||
object,
|
object,
|
||||||
array,
|
array,
|
||||||
};
|
};
|
||||||
|
|
|
@ -5476,6 +5476,14 @@ pub const Editor = struct {
|
||||||
self.need_render();
|
self.need_render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_completion(self: *Self, row: usize, col: usize, is_incomplete: bool, msg: tp.message) Result {
|
||||||
|
_ = self;
|
||||||
|
_ = row;
|
||||||
|
_ = col;
|
||||||
|
_ = is_incomplete;
|
||||||
|
_ = msg;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn select(self: *Self, ctx: Context) Result {
|
pub fn select(self: *Self, ctx: Context) Result {
|
||||||
var sel: Selection = .{};
|
var sel: Selection = .{};
|
||||||
if (!try ctx.args.match(.{ tp.extract(&sel.begin.row), tp.extract(&sel.begin.col), tp.extract(&sel.end.row), tp.extract(&sel.end.col) }))
|
if (!try ctx.args.match(.{ tp.extract(&sel.begin.row), tp.extract(&sel.begin.col), tp.extract(&sel.end.row), tp.extract(&sel.end.col) }))
|
||||||
|
|
|
@ -726,6 +726,50 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
pub const add_diagnostic_meta: Meta = .{ .arguments = &.{ .string, .string, .string, .string, .integer, .integer, .integer, .integer, .integer } };
|
pub const add_diagnostic_meta: Meta = .{ .arguments = &.{ .string, .string, .string, .string, .integer, .integer, .integer, .integer, .integer } };
|
||||||
|
|
||||||
|
pub fn add_completion(self: *Self, ctx: Ctx) Result {
|
||||||
|
var file_path: []const u8 = undefined;
|
||||||
|
var row: usize = undefined;
|
||||||
|
var col: usize = undefined;
|
||||||
|
var is_incomplete: bool = undefined;
|
||||||
|
|
||||||
|
if (!try ctx.args.match(.{
|
||||||
|
tp.extract(&file_path),
|
||||||
|
tp.extract(&row),
|
||||||
|
tp.extract(&col),
|
||||||
|
tp.extract(&is_incomplete),
|
||||||
|
tp.more,
|
||||||
|
})) return error.InvalidAddDiagnosticArgument;
|
||||||
|
file_path = project_manager.normalize_file_path(file_path);
|
||||||
|
if (self.get_active_editor()) |editor| if (std.mem.eql(u8, file_path, editor.file_path orelse ""))
|
||||||
|
try editor.add_completion(row, col, is_incomplete, ctx.args);
|
||||||
|
}
|
||||||
|
pub const add_completion_meta: Meta = .{
|
||||||
|
.arguments = &.{
|
||||||
|
.string, // file_path
|
||||||
|
.integer, // row
|
||||||
|
.integer, // col
|
||||||
|
.boolean, // is_incomplete
|
||||||
|
.string, // label
|
||||||
|
.string, // label_detail
|
||||||
|
.string, // label_description
|
||||||
|
.integer, // kind
|
||||||
|
.string, // detail
|
||||||
|
.string, // documentation
|
||||||
|
.string, // documentation_kind
|
||||||
|
.string, // sortText
|
||||||
|
.integer, // insertTextFormat
|
||||||
|
.string, // textEdit_newText
|
||||||
|
.integer, // insert.begin.row
|
||||||
|
.integer, // insert.begin.col
|
||||||
|
.integer, // insert.end.row
|
||||||
|
.integer, // insert.end.col
|
||||||
|
.integer, // replace.begin.row
|
||||||
|
.integer, // replace.begin.col
|
||||||
|
.integer, // replace.end.row
|
||||||
|
.integer, // replace.end.col
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
pub fn rename_symbol_item(self: *Self, ctx: Ctx) Result {
|
pub fn rename_symbol_item(self: *Self, ctx: Ctx) Result {
|
||||||
const editor = self.get_active_editor() orelse return;
|
const editor = self.get_active_editor() orelse return;
|
||||||
// because the incoming message is an array of Renames, we manuallly
|
// because the incoming message is an array of Renames, we manuallly
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue