Crates.io | vimvar |
lib.rs | vimvar |
version | 0.3.0 |
source | src |
created_at | 2021-05-30 04:47:47.634883 |
updated_at | 2022-04-17 20:44:06.740638 |
description | Library that provides ability to read neovim/vim variables |
homepage | https://github.com/chipsenkbeil/vimvar-rs |
repository | https://github.com/chipsenkbeil/vimvar-rs |
max_upload_size | |
id | 403736 |
size | 50,182 |
# Cargo.toml
[dependencies]
vimvar = "0.3"
// Loads g:my_global_var from default vimrc, returning None if it does not
// exist, and casting to type String from the default serde_json::Value
//
// Only fails unwrap if neovim/vim fails to run or type fails to cast
let var: Option<String> = vimvar::load_typed_global_var("my_global_var").unwrap();
println!("Loaded g:my_global_var = {:?}", var);
For more a more explicit example
use vimvar::*;
use serde_json::json;
// Load explicitly a buffer variable (b:my_buffer_var) using neovim
let var = VimVar::new(Cmd::NeoVim, Scope::Buffer, "my_buffer_var");
// Load the variable using a different config file versus the standard one
let value = var.load_with_config("path/to/config.vim", false).expect("Failed to load variable");
assert_eq!(value, Some(json!("some buffer value")));