Skip to content

Commit

Permalink
disable_fmt config
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Nov 25, 2023
1 parent 80c7d22 commit 3194529
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
12 changes: 12 additions & 0 deletions config.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module main
import os
import gx
import toml
import json

// The different kinds of cursors
enum Cursor {
Expand Down Expand Up @@ -56,6 +57,7 @@ mut:
red_color gx.Color // base08
red_cfg gx.TextCfg
disable_mouse bool
disable_fmt bool
}

fn (mut config Config) set_settings(path string) {
Expand Down Expand Up @@ -314,3 +316,13 @@ fn (mut config Config) set_red() {
color: config.red_color
}
}

fn (mut ved Ved) load_config2() {
if os.exists(config_path2) {
if conf2 := json.decode(Config, os.read_file(config_path2) or { return }) {
ved.cfg.disable_fmt = conf2.disable_fmt
} else {
println(err)
}
}
}
5 changes: 4 additions & 1 deletion ved.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
timer_path = os.join_path(settings_dir, 'timer')
tasks_path = os.join_path(settings_dir, 'tasks')
config_path = os.join_path(settings_dir, 'conf.toml')
config_path2 = os.join_path(settings_dir, 'config.json')
max_nr_workspaces = 10
)

Expand Down Expand Up @@ -159,6 +160,8 @@ fn main() {
}
ved.handle_segfault()

ved.load_config2()

ved.cfg.set_settings(config_path)
ved.cfg.reload_config()

Expand Down Expand Up @@ -187,7 +190,7 @@ fn main() {
font_path: fpath
ui_mode: true
)
println('1FULL SCREEN=${!is_window}')
println('full screen=${!is_window}')
ved.timer = new_timer(ved.gg)
ved.load_all_tasks()
// TODO linux and windows
Expand Down
4 changes: 4 additions & 0 deletions view.v
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ fn (mut view View) save_file() {
}

fn (mut view View) format_file() {
view.ved.load_config2()
if view.ved.cfg.disable_fmt {
return
}
path := view.path
// Run formatters
fmt_cmd := view.ved.syntaxes[view.ved.current_syntax_idx].fmt_cmd.replace('<PATH>',
Expand Down

0 comments on commit 3194529

Please sign in to comment.