aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukeflo2025-02-17 21:43:18 +0100
committerlukeflo2025-02-17 21:43:18 +0100
commitde0e6fcde0f4fdd9a08255dac52629bec28a0ca3 (patch)
tree6df6f37849c118c997006487b49ede619002e4e2
parentd443843d352d740b895c4d622eb9af9567aa7423 (diff)
downloadbibiman-de0e6fcde0f4fdd9a08255dac52629bec28a0ca3.tar.gz
bibiman-de0e6fcde0f4fdd9a08255dac52629bec28a0ca3.zip
Update README
-rw-r--r--README.md39
-rw-r--r--example-config.toml4
-rw-r--r--src/app.rs16
-rw-r--r--src/bibiman.rs3
-rw-r--r--src/cliargs.rs2
-rw-r--r--src/main.rs2
6 files changed, 50 insertions, 16 deletions
diff --git a/README.md b/README.md
index 8285e37..deb65d8 100644
--- a/README.md
+++ b/README.md
@@ -95,6 +95,35 @@ Here is how the light terminal scheme looks:
![bibiman-light-theme.png](https://codeberg.org/attachments/7fe9d58d-7e90-4043-9402-5e4664c4e22a)
+## Configuration
+
+### Location of Config File
+
+`bibiman` can be configured through a config file. The standard location is the user's config dir following the XDG scheme. On Linux systems this defaults to:
+
+```bash
+# XDG scheme:
+$XDG_CONFIG_HOME/bibiman/bibiman.toml
+
+# Fallback:
+$HOME/.config/bibiman/bibiman.toml
+
+```
+
+### Values
+
+At the moment, the following values can be set through the config file:
+
+```toml
+[general]
+# Default files/dirs which are loaded on startup
+bibfiles = [ "/path/to/bibfile", "path/to/dir/with/bibfiles" ]
+# Default editor to use when editing files. Arguments are possible
+editor = "vim" # with args: "vim -y"
+```
+
+Paths to bibfiles/dirs passed through the CLI will be added to the ones provided by the config file.
+
## Features
These are the current features, the list will be updated:
@@ -113,9 +142,9 @@ These are the current features, the list will be updated:
position in bibfile.
- [x] **Load multiple files** into one session.
- [x] **Add Entry via DOI**.
-- [ ] **Open related notes file** for specific entry.
-- [ ] **Implement config file** for setting some default values like main
+- [x] **Implement config file** for setting some default values like main
bibfile, PDF-opener, or editor
+- [ ] **Open related notes file** for specific entry.
- [ ] **Support Hayagriva(`.yaml`)** format as input (_on hold for now_, because
the Hayagriva Yaml style doesn't offer keywords; s. issue in
[Hayagriva repo](https://github.com/typst/hayagriva/issues/240)).
@@ -158,10 +187,10 @@ enabled by default. You can use some special chars to alter pattern matching:
## Edit bib entry
-For now, the TUI only supports editors set through the environment variables
-`VISUAL` and `EDITOR` in this order. The fallback solution is `vi`.
+The main editor can be set through the [config file](#values). Otherwise, the environment variables
+`VISUAL` and `EDITOR` will be used in this order. The last fallback solution is `vi`.
-I've tested the following editors (set as value of `VISUAL`):
+I've tested the following editors (set as value of `VISUAL` and through the config file):
- [x] **Helix**: `export VISUAL="hx"`
- [x] **Vim/Neovim**: `export VISUAL="vim/nvim"`
diff --git a/example-config.toml b/example-config.toml
index 8a4aef6..989350e 100644
--- a/example-config.toml
+++ b/example-config.toml
@@ -1,3 +1,3 @@
[general]
-bibfiles = ["./tests/biblatex-test.bib"]
-editor = "vi"
+bibfiles = ["./tests/biblatex-test.bib"] # files and dirs are possible
+editor = "vim" # arguments are possible: "vim -y"
diff --git a/src/app.rs b/src/app.rs
index c60d81e..b49e883 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -60,7 +60,7 @@ impl App {
})
}
- pub async fn run(&mut self, args: &mut CLIArgs) -> Result<()> {
+ pub async fn run(&mut self, args: &mut CLIArgs, cfg: &BibiConfig) -> Result<()> {
let mut tui = tui::Tui::new()?;
tui.enter()?;
@@ -86,10 +86,10 @@ impl App {
} else {
CmdAction::from(key_event)
};
- self.run_command(command, args, &mut tui)?
+ self.run_command(command, args, cfg, &mut tui)?
}
Event::Mouse(mouse_event) => {
- self.run_command(CmdAction::from(mouse_event), args, &mut tui)?
+ self.run_command(CmdAction::from(mouse_event), args, cfg, &mut tui)?
}
Event::Resize(_, _) => {}
@@ -111,7 +111,13 @@ impl App {
self.running = false;
}
- pub fn run_command(&mut self, cmd: CmdAction, args: &mut CLIArgs, tui: &mut Tui) -> Result<()> {
+ pub fn run_command(
+ &mut self,
+ cmd: CmdAction,
+ args: &mut CLIArgs,
+ cfg: &BibiConfig,
+ tui: &mut Tui,
+ ) -> Result<()> {
match cmd {
CmdAction::Input(cmd) => match cmd {
InputCmdAction::Nothing => {}
@@ -304,7 +310,7 @@ impl App {
}
CmdAction::EditFile => {
if let CurrentArea::EntryArea = self.bibiman.current_area {
- self.bibiman.run_editor(args, tui)?;
+ self.bibiman.run_editor(cfg, args, tui)?;
}
}
CmdAction::Open => {
diff --git a/src/bibiman.rs b/src/bibiman.rs
index 6aa138d..20cdfc6 100644
--- a/src/bibiman.rs
+++ b/src/bibiman.rs
@@ -328,7 +328,7 @@ impl Bibiman {
self.entry_table.entry_table_state.select(Some(idx_count));
}
- pub fn run_editor(&mut self, args: &CLIArgs, tui: &mut Tui) -> Result<()> {
+ pub fn run_editor(&mut self, cfg: &BibiConfig, args: &CLIArgs, tui: &mut Tui) -> Result<()> {
// get filecontent and citekey for calculating line number
let citekey: &str = &self.entry_table.entry_table_items
[self.entry_table.entry_table_state.selected().unwrap()]
@@ -379,6 +379,7 @@ impl Bibiman {
tui.exit()?;
// Use VISUAL or EDITOR. Set "vi" as last fallback
let mut cmd: Command = EditorBuilder::new()
+ .source(cfg.general.editor.clone())
.environment()
.source(Some("vi"))
.build()
diff --git a/src/cliargs.rs b/src/cliargs.rs
index 50ed6f5..895f116 100644
--- a/src/cliargs.rs
+++ b/src/cliargs.rs
@@ -65,8 +65,6 @@ impl CLIArgs {
}
}
- // args.files = parse_files(args.pos_args.clone());
-
Ok(args)
}
}
diff --git a/src/main.rs b/src/main.rs
index 94f5042..37bead0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -56,6 +56,6 @@ async fn main() -> Result<()> {
// Create an application.
let mut app = App::new(&mut parsed_args, &mut cfg)?;
- app.run(&mut parsed_args).await?;
+ app.run(&mut parsed_args, &cfg).await?;
Ok(())
}