3 releases (unstable)

1.0.0-rc.0 Sep 10, 2024
0.2.1 Sep 2, 2024
0.1.0 Aug 30, 2024

#2115 in Parser implementations

Download history 389/week @ 2024-08-30 107/week @ 2024-09-06 54/week @ 2024-09-13 28/week @ 2024-09-20 45/week @ 2024-09-27 9/week @ 2024-10-04

163 downloads per month

MIT license

53KB
1.5K SLoC

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.

Dependencies

~9–17MB
~293K SLoC