Skip to content

Commit

Permalink
Add an option to clear user settings from vim/nvim.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkulak committed Jul 4, 2023
1 parent 54303b5 commit ff0e9d1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ reactions = [ "❤️", "👍", "👎", "😂", "‼️", "❓️"]
# Muted rooms.
muted = ["!hMPITSQBLFEleSJeVe:matrix.org"]
# Useful if your custom config is interfering with Enter key bindings
clear_vim = true
```

The config file is hot reloaded and can generally be found at
Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ let
# put this on stable once Cargo 1.7 hits
pkgs = import (fetchTarball("channel:nixpkgs-unstable")) {};
in pkgs.mkShell {
buildInputs = with pkgs; [ cargo rustc rust-analyzer openssl pkg-config ];
buildInputs = with pkgs; [ cargo rustc rust-analyzer bacon clippy openssl pkg-config ];
}
4 changes: 4 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ pub fn is_muted(room: &RoomId) -> bool {
muted.contains(&room.to_string())
}

pub fn clean_vim() -> bool {
get_settings().get("clean_vim").unwrap_or_default()
}

fn watch_internal() {
let (tx, rx) = channel();

Expand Down
6 changes: 6 additions & 0 deletions src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use std::path::PathBuf;
use std::process::{Command, Stdio};
use tempfile::Builder;

use crate::settings::clean_vim;

lazy_static! {
static ref FILE_RE: Regex = Regex::new(r"-([0-9]+)(\.|$)").unwrap();
}
Expand Down Expand Up @@ -55,6 +57,10 @@ pub fn get_text(existing: Option<&str>, suffix: Option<&str>) -> anyhow::Result<

// set up vim just right, if that's what we're using
if editor.ends_with("vim") || editor.ends_with("vi") {
if clean_vim() {
command.arg("--clean");
}

if existing.is_none() {
// open in insert mode
command.arg("+star");
Expand Down

0 comments on commit ff0e9d1

Please sign in to comment.