feat: add support for absolute paths to LSP and formatter binaries
Also, refactor binary resolving functions into the bin_path module. closes #474
This commit is contained in:
parent
d24f335465
commit
4847a1f584
4 changed files with 26 additions and 18 deletions
|
|
@ -6589,7 +6589,7 @@ pub const Editor = struct {
|
|||
fn get_formatter(self: *Self) ?[]const []const u8 {
|
||||
if (self.checked_formatter) return self.formatter;
|
||||
self.checked_formatter = true;
|
||||
if (self.file_type) |file_type| if (file_type.formatter) |fmtr| if (fmtr.len > 0) if (can_execute(self.allocator, fmtr[0])) {
|
||||
if (self.file_type) |file_type| if (file_type.formatter) |fmtr| if (fmtr.len > 0) if (bin_path.can_execute(self.allocator, fmtr[0])) {
|
||||
self.formatter = fmtr;
|
||||
return fmtr;
|
||||
} else {
|
||||
|
|
@ -6599,12 +6599,6 @@ pub const Editor = struct {
|
|||
return null;
|
||||
}
|
||||
|
||||
fn can_execute(allocator: std.mem.Allocator, binary_name: []const u8) bool {
|
||||
const resolved_binary_path = bin_path.find_binary_in_path(allocator, binary_name) catch return false;
|
||||
defer if (resolved_binary_path) |path| allocator.free(path);
|
||||
return resolved_binary_path != null;
|
||||
}
|
||||
|
||||
pub fn format(self: *Self, ctx: Context) Result {
|
||||
if (ctx.args.buf.len > 0 and try ctx.args.match(.{ tp.string, tp.more })) {
|
||||
try self.filter_cmd(ctx.args);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue