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:
CJ van den Berg 2026-01-29 15:27:43 +01:00
parent d24f335465
commit 4847a1f584
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 26 additions and 18 deletions

View file

@ -46,12 +46,12 @@ pub fn list(allocator: std.mem.Allocator, writer: *std.io.Writer, tty_config: st
try write_segmented(writer, file_type.extensions, ",", max_extensions_len + 1, tty_config);
if (file_type.language_server) |language_server|
try write_checkmark(writer, can_execute(allocator, language_server[0]), tty_config);
try write_checkmark(writer, bin_path.can_execute(allocator, language_server[0]), tty_config);
try write_segmented(writer, file_type.language_server, " ", max_langserver_len + 1, tty_config);
if (file_type.formatter) |formatter|
try write_checkmark(writer, can_execute(allocator, formatter[0]), tty_config);
try write_checkmark(writer, bin_path.can_execute(allocator, formatter[0]), tty_config);
try write_segmented(writer, file_type.formatter, " ", null, tty_config);
try writer.writeAll("\n");
@ -96,12 +96,6 @@ fn write_segmented(
if (pad) |pad_| try write_padding(writer, len, pad_);
}
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;
}
fn setColorRgb(writer: anytype, color: u24) !void {
const fg_rgb_legacy = "\x1b[38;2;{d};{d};{d}m";
const rgb = RGB.from_u24(color);