Default config
This commit is contained in:
parent
374910704d
commit
6e6ad7a82b
8
rc/default_config.toml
Normal file
8
rc/default_config.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[filetype.rust]
|
||||||
|
group.identifier = ["identifier", "scoped_identifier"]
|
||||||
|
group.function = ["function_item"]
|
||||||
|
group.declaration = ["function_item", "struct_item", "enum_item"]
|
||||||
|
group.call = ["macro_invocation", "call_expression"]
|
||||||
|
group.arguments = ["arguments", "token_tree"]
|
||||||
|
group.statement = ["expression_statement", "let_declaration"]
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
# Path to the kak-tree executable.
|
# Path to the kak-tree executable.
|
||||||
# To load config: set-option global tree_cmd "kak-tree --config /path/to/kak-tree.toml"
|
|
||||||
# To enable debug logging: set-option global tree_cmd "kak-tree -vvv"
|
# To enable debug logging: set-option global tree_cmd "kak-tree -vvv"
|
||||||
declare-option str tree_cmd "kak-tree"
|
declare-option str tree_cmd "kak-tree"
|
||||||
|
|
||||||
|
# Path to the config file. Defaults to the built-in file default_config.toml
|
||||||
|
declare-option str tree_config %sh{ printf "$(dirname ${kak_source})/default_config.toml" }
|
||||||
|
|
||||||
# Path to the log file.
|
# Path to the log file.
|
||||||
declare-option str tree_log "/tmp/kak-tree.log"
|
declare-option str tree_log "/tmp/kak-tree.log"
|
||||||
|
|
||||||
|
@ -33,7 +35,7 @@ content = """
|
||||||
[op]
|
[op]
|
||||||
type = "%s"
|
type = "%s"
|
||||||
%s
|
%s
|
||||||
' "${kak_opt_filetype}" "${kak_selections_desc}" "${tree_draft}" $1 "$2" | ${kak_opt_tree_cmd} 2>${kak_opt_tree_log}
|
' "${kak_opt_filetype}" "${kak_selections_desc}" "${tree_draft}" $1 "$2" | ${kak_opt_tree_cmd} --config "${kak_opt_tree_config}" 2>${kak_opt_tree_log}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ impl Default for Config {
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn load<P: AsRef<std::path::Path>>(path: P) -> Option<Self> {
|
pub fn load<P: AsRef<std::path::Path>>(path: P) -> Option<Self> {
|
||||||
let config = std::fs::read_to_string(path).ok()?;
|
let config = std::fs::read_to_string(&path).map_err(|e| { eprintln!("Could not open config {}", path.as_ref().display()); e}).ok()?;
|
||||||
let mut config: Config = toml::from_str(&config).ok()?;
|
let mut config: Config = toml::from_str(&config).map_err(|e| { eprintln!("Could not read config: {e}"); e}).ok()?;
|
||||||
if config.filetype.get("default").is_none() {
|
if config.filetype.get("default").is_none() {
|
||||||
config
|
config
|
||||||
.filetype
|
.filetype
|
||||||
|
|
Loading…
Reference in New Issue
Block a user