feat: add CLi option to override detected language
This commit is contained in:
parent
aa74155cc1
commit
de8d563739
3 changed files with 8 additions and 4 deletions
|
@ -25,6 +25,7 @@ pub fn main() anyerror!void {
|
|||
\\--no-trace Do not enable internal tracing.
|
||||
\\--restore-session Restore restart session.
|
||||
\\--show-input Open the input view on start.
|
||||
\\-l, --language <str> Force the language of the file to be opened.
|
||||
\\<str>... File to open.
|
||||
\\ Add +<LINE> to the command line or append
|
||||
\\ :LINE or :LINE:COL to the file name to jump
|
||||
|
@ -86,9 +87,9 @@ pub fn main() anyerror!void {
|
|||
env.set("show-input", (res.args.@"show-input" != 0));
|
||||
env.set("no-sleep", (res.args.@"no-sleep" != 0));
|
||||
env.set("dump-stack-trace", (res.args.@"debug-dump-on-error" != 0));
|
||||
if (res.args.@"frame-rate") |frame_rate|
|
||||
env.num_set("frame-rate", @intCast(frame_rate));
|
||||
if (res.args.@"frame-rate") |s| env.num_set("frame-rate", @intCast(s));
|
||||
env.proc_set("log", log_proc.ref());
|
||||
if (res.args.language) |s| env.str_set("language", s);
|
||||
|
||||
var eh = thespian.make_exit_handler({}, print_exit_status);
|
||||
const tui_proc = try tui.spawn(a, &ctx, &eh, &env);
|
||||
|
|
|
@ -357,6 +357,9 @@ pub const Editor = struct {
|
|||
var content = std.ArrayList(u8).init(self.a);
|
||||
defer content.deinit();
|
||||
try new_buf.root.store(content.writer());
|
||||
const lang_override = tp.env.get().str("language");
|
||||
if (lang_override.len > 0)
|
||||
break :syntax syntax.create_file_type(self.a, content.items, lang_override) catch null;
|
||||
break :syntax syntax.create_guess_file_type(self.a, content.items, self.file_path) catch null;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue