feat: add support for configuring the file type syntax parser
This commit is contained in:
parent
f88613a9e4
commit
1ea3575d61
1 changed files with 3 additions and 1 deletions
|
@ -4,6 +4,7 @@ extensions: ?[]const []const u8 = null,
|
||||||
icon: ?[]const u8 = null,
|
icon: ?[]const u8 = null,
|
||||||
color: ?u24 = null,
|
color: ?u24 = null,
|
||||||
comment: ?[]const u8 = null,
|
comment: ?[]const u8 = null,
|
||||||
|
parser: ?[]const u8 = null,
|
||||||
formatter: ?[]const []const u8 = null,
|
formatter: ?[]const []const u8 = null,
|
||||||
language_server: ?[]const []const u8 = null,
|
language_server: ?[]const []const u8 = null,
|
||||||
first_line_matches_prefix: ?[]const u8 = null,
|
first_line_matches_prefix: ?[]const u8 = null,
|
||||||
|
@ -28,6 +29,7 @@ fn from_file_type(file_type: syntax.FileType) @This() {
|
||||||
.extensions = file_type.extensions,
|
.extensions = file_type.extensions,
|
||||||
.first_line_matches_prefix = if (file_type.first_line_matches) |flm| flm.prefix else null,
|
.first_line_matches_prefix = if (file_type.first_line_matches) |flm| flm.prefix else null,
|
||||||
.first_line_matches_content = if (file_type.first_line_matches) |flm| flm.content else null,
|
.first_line_matches_content = if (file_type.first_line_matches) |flm| flm.content else null,
|
||||||
|
.parser = file_type.name,
|
||||||
.comment = file_type.comment,
|
.comment = file_type.comment,
|
||||||
.formatter = file_type.formatter,
|
.formatter = file_type.formatter,
|
||||||
.language_server = file_type.language_server,
|
.language_server = file_type.language_server,
|
||||||
|
@ -179,7 +181,7 @@ fn guess_first_line(content: []const u8) ?@This() {
|
||||||
|
|
||||||
pub fn create_syntax(file_type_config: @This(), allocator: std.mem.Allocator, query_cache: *syntax.QueryCache) !*syntax {
|
pub fn create_syntax(file_type_config: @This(), allocator: std.mem.Allocator, query_cache: *syntax.QueryCache) !*syntax {
|
||||||
return syntax.create(
|
return syntax.create(
|
||||||
syntax.FileType.get_by_name_static(file_type_config.name) orelse return error.FileTypeNotFound,
|
syntax.FileType.get_by_name_static(file_type_config.parser orelse file_type_config.name) orelse return error.FileTypeNotFound,
|
||||||
allocator,
|
allocator,
|
||||||
query_cache,
|
query_cache,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue