feat: port list_languages command to use configurable file types
This commit is contained in:
parent
6df9391b50
commit
53c9523617
1 changed files with 7 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const syntax = @import("syntax");
|
const syntax = @import("syntax");
|
||||||
|
const file_type_config = @import("file_type_config");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const RGB = @import("color").RGB;
|
const RGB = @import("color").RGB;
|
||||||
|
|
||||||
|
@ -16,7 +17,8 @@ pub fn list(allocator: std.mem.Allocator, writer: anytype, tty_config: std.io.tt
|
||||||
var max_formatter_len: usize = 0;
|
var max_formatter_len: usize = 0;
|
||||||
var max_extensions_len: usize = 0;
|
var max_extensions_len: usize = 0;
|
||||||
|
|
||||||
for (syntax.FileType.file_types) |file_type| {
|
for (syntax.FileType.static_file_types) |static_file_type| {
|
||||||
|
const file_type = try file_type_config.get(static_file_type.name) orelse unreachable;
|
||||||
max_language_len = @max(max_language_len, file_type.name.len);
|
max_language_len = @max(max_language_len, file_type.name.len);
|
||||||
max_langserver_len = @max(max_langserver_len, args_string_length(file_type.language_server));
|
max_langserver_len = @max(max_langserver_len, args_string_length(file_type.language_server));
|
||||||
max_formatter_len = @max(max_formatter_len, args_string_length(file_type.formatter));
|
max_formatter_len = @max(max_formatter_len, args_string_length(file_type.formatter));
|
||||||
|
@ -31,10 +33,11 @@ pub fn list(allocator: std.mem.Allocator, writer: anytype, tty_config: std.io.tt
|
||||||
try tty_config.setColor(writer, .reset);
|
try tty_config.setColor(writer, .reset);
|
||||||
try writer.writeAll("\n");
|
try writer.writeAll("\n");
|
||||||
|
|
||||||
for (syntax.FileType.file_types) |file_type| {
|
for (syntax.FileType.static_file_types) |static_file_type| {
|
||||||
|
const file_type = try file_type_config.get(static_file_type.name) orelse unreachable;
|
||||||
try writer.writeAll(" ");
|
try writer.writeAll(" ");
|
||||||
try setColorRgb(writer, file_type.color);
|
try setColorRgb(writer, file_type.color orelse static_file_type.color);
|
||||||
try writer.writeAll(file_type.icon);
|
try writer.writeAll(file_type.icon orelse static_file_type.icon);
|
||||||
try tty_config.setColor(writer, .reset);
|
try tty_config.setColor(writer, .reset);
|
||||||
try writer.writeAll(" ");
|
try writer.writeAll(" ");
|
||||||
try write_string(writer, file_type.name, max_language_len + 1);
|
try write_string(writer, file_type.name, max_language_len + 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue