vim-plugin-metadata

Crates.iovim-plugin-metadata
lib.rsvim-plugin-metadata
version1.0.0-rc.0
sourcesrc
created_at2024-08-30 19:48:35.744601
updated_at2024-09-10 05:02:46.470019
descriptionParse and analyze your vim plugins, from Rust!
homepage
repositoryhttps://github.com/dbarnett/vim-plugin-metadata
max_upload_size
id1358077
size53,436
David Barnett (dbarnett)

documentation

README

Rust vim-plugin-metadata

Parse and analyze your vim plugins, from Rust!

WARNING: This library is early alpha, still missing tons of functionality, and probably has serious bugs. Use at your own risk.

Usage

cargo add it to your project, point it at a file, get metadata:

use vim_plugin_metadata::VimParser;

fn main() {
    let mut parser = VimParser::new().unwrap();
    let plugin = parser.parse_plugin_dir(".vim/plugged/someplugin").unwrap();
    println!("{plugin:#?}");
}
VimPlugin {
    content: [
        VimModule {
            path: Some("plugin/somefile.vim"),
            doc: Some("File header comment"),
            nodes: [],
        },
        VimModule {
            path: Some("autoload/someplugin.vim"),
            doc: None,
            nodes: [
                Function {
                    name: "someplugin#DoThing",
                    args: [],
                    modifiers: [],
                    doc: "Does something cool.",
                },
            ],
        },
    ],
}
const VIMSCRIPT_CODE: &str = r#"
""
" File header comment

""
" Does something cool.
func MyFunc() abort
  …
endfunc
"#;

let module = parser.parse_module_str(VIMSCRIPT_CODE).unwrap();
println!("{module:#?}");
VimModule {
    path: None,
    doc: Some("File header comment"),
    nodes: [
        Function {
            name: "MyFunc",
            args: [],
            modifiers: [],
            doc: Some(
                "Does something cool.",
            ),
        },
    ]
}

See tests in src/lib.rs for more usage examples.

Commit count: 0

cargo fmt