feat: add cli option to disable syntax highlighting
This commit is contained in:
parent
3de13b1354
commit
1f6bc86265
2 changed files with 10 additions and 5 deletions
|
@ -44,6 +44,7 @@ pub fn main() anyerror!void {
|
|||
\\--show-log Open the log view on start.
|
||||
\\-l, --language <lang> Force the language of the file to be opened.
|
||||
\\--list-languages Show available languages.
|
||||
\\--no-syntax Disable syntax highlighting.
|
||||
\\-e, --exec <command>... Execute a command on startup.
|
||||
\\-v, --version Show build version and exit.
|
||||
\\<file>... File or directory to open.
|
||||
|
@ -154,6 +155,7 @@ pub fn main() anyerror!void {
|
|||
env.set("show-input", (res.args.@"show-input" != 0));
|
||||
env.set("show-log", (res.args.@"show-log" != 0));
|
||||
env.set("no-sleep", (res.args.@"no-sleep" != 0));
|
||||
env.set("no-syntax", (res.args.@"no-syntax" != 0));
|
||||
env.set("dump-stack-trace", (res.args.@"debug-dump-on-error" != 0));
|
||||
if (res.args.@"frame-rate") |s| env.num_set("frame-rate", @intCast(s));
|
||||
env.proc_set("log", log_proc.ref());
|
||||
|
|
|
@ -404,7 +404,7 @@ pub const Editor = struct {
|
|||
if (self.buffer) |_| try self.close();
|
||||
self.buffer = new_buf;
|
||||
|
||||
self.syntax = syntax: {
|
||||
self.syntax = if (tp.env.get().is("no-syntax")) null else syntax: {
|
||||
if (new_buf.root.lines() > root_mod.max_syntax_lines)
|
||||
break :syntax null;
|
||||
const lang_override = tp.env.get().str("language");
|
||||
|
@ -2932,7 +2932,10 @@ pub const Editor = struct {
|
|||
var content = std.ArrayList(u8).init(self.a);
|
||||
defer content.deinit();
|
||||
try root.store(content.writer());
|
||||
self.syntax = syntax.create_guess_file_type(self.a, content.items, self.file_path) catch |e| switch (e) {
|
||||
self.syntax = if (tp.env.get().is("no-syntax"))
|
||||
null
|
||||
else
|
||||
syntax.create_guess_file_type(self.a, content.items, self.file_path) catch |e| switch (e) {
|
||||
error.NotFound => null,
|
||||
else => return e,
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue