{"id":25852553,"url":"https://github.com/aceofspades5757/vii","last_synced_at":"2025-03-01T14:20:06.115Z","repository":{"id":37938738,"uuid":"481453952","full_name":"AceofSpades5757/vii","owner":"AceofSpades5757","description":"Bindings to Vim objects, bindings to Vim channel commands, and a way to interact with Vim using Rust.","archived":false,"fork":false,"pushed_at":"2022-10-25T05:14:17.000Z","size":1252,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T10:45:02.119Z","etag":null,"topics":["rust","vim"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AceofSpades5757.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-14T03:32:36.000Z","updated_at":"2023-12-14T03:24:57.000Z","dependencies_parsed_at":"2022-08-31T11:22:39.630Z","dependency_job_id":null,"html_url":"https://github.com/AceofSpades5757/vii","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AceofSpades5757%2Fvii","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AceofSpades5757%2Fvii/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AceofSpades5757%2Fvii/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AceofSpades5757%2Fvii/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AceofSpades5757","download_url":"https://codeload.github.com/AceofSpades5757/vii/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241375170,"owners_count":19952665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","vim"],"created_at":"2025-03-01T14:20:05.234Z","updated_at":"2025-03-01T14:20:06.090Z","avatar_url":"https://github.com/AceofSpades5757.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![Coverage](https://github.com/AceofSpades5757/vii/actions/workflows/tests.yml/badge.svg)](https://github.com/AceofSpades5757/vii/actions/workflows/tests.yml)\n\n[![cargo.io](https://img.shields.io/crates/v/vii)](https://crates.io/crates/vii)\n![License](https://img.shields.io/crates/l/vii?color=purple)\n\n[![rust badge](https://img.shields.io/static/v1?label=Made%20with\u0026message=Rust\u0026style=for-the-badge\u0026logo=rust\u0026labelColor=e82833\u0026color=b11522)](https://www.rust-lang.org/)\n\nBindings to Vim objects and a wayt to interact with Vim using Rust, such as text properties, channels.\n\nUsing this library, you can wite standard plugins, all in Rust, which get run just like a Vim plugin would typically run.\n\n# Installation\n\nAdd this line to your dependencies section of your `Cargo.toml` file.\n\n`vii = \"0.0\"`\n\n_Current interface is highly unstable._\n\n## Features\n\nDefault comes with a lot of useful features, but there are a lot of features available, to increase the quality of your program.\n\n# Usage\n\n_If possible, use the examples directly from the documentation as they are more clear and tested._\n\n## Plugin\n\n- _Note: Server plugins, or persistent plugins are not yet implemented._\n- _Note: FiletypePlugin, for a Vim filetype plugin, is not yet implemented._\n\nCreating a Vim plugin using Rust. Can be installed and run using the Vim plugin `rust-plug`.\n\nActs _almost_ just like a Vim plugin would. It runs on startup, running it's code. Exceptions include adding `pythonx` code, the `autoload` directory, but it can still create functions, commands, global variables, and read from Vim itself.\n\n- Uses `PluginConfig` struct to add configuration support.\n- Uses `Plugin` trait to create a plugin.\n  - `get_config` - Get the configuration struct.\n  - `plugin` - The plugin, the important information.\n\nHere's an example, taken from [rust-plug proof of concept](https://github.com/AceofSpades5757/rust-plug-poc).\n\n```toml\n# Cargo.toml\n[package]\nname = \"rust-plug-poc\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[dependencies]\nvii = \"0.0\"\n```\n\n```rust\n// src/main.rs\nuse std::env;\nuse std::net::TcpStream;\n\nuse vii::plugin::Plugin;\nuse vii::plugin::PluginConfig;\n\nstruct MyPlugin{\n    ip: String,\n    port: String,\n}\n\n/// Make your struct, MyPlugin, into a Plugin ready for Vim.\nimpl Plugin for MyPlugin {\n    fn get_config(\u0026self) -\u003e PluginConfig {\n        PluginConfig::new(\"127.0.0.1\".to_string(), \"8765\".to_string())\n    }\n    fn plugin(\u0026mut self, _stream: \u0026mut TcpStream) -\u003e Result\u003c(), String\u003e {\n        Ok(())\n    }\n}\n\nfn main() {\n\n  // Environment Variable, to communicate with rust-plug\n  let port = env::var(\"VII_PLUGIN_PORT\").unwrap();\n  let mut plugin = MyPlugin {\n    ip: \"127.0.0.1\".to_string(),\n    port,\n  };\n\n  // Run your plugin.\n  //\n  // Here you can run your plugin as many times as you'd like, create multiple plugins, etc.\n  plugin.run();\n}\n```\n\n## Data Types\n\nWorking with Vim data types.\n\n_See documentation for supported data types._\n\n```rust\nuse vii::DataType;\n\n// Using a Vim data type\nlet vim_float = DataType::Float(3.14);\n// Serializing for transmission to Vim\nlet serialized_float = vim_float.to_string();  // \"3.14\"\n\nlet vim_string = DataType::String(\"Hello World!\".to_string());\nlet serialized_string = vim_string.to_string();  // \"\\\"Hello World!\\\"\"\n```\n\n## Text Properties\n\nWorking with Vim text properties (see `:help textprop.txt` in Vim).\n\n_Note: This is a low-level API._\n\n```rust\nuse vii::textprop::{\n    TextProperty,\n    PropertyType,\n};\nuse vii::textprop::PropertyTypeBuilder;\n\n// Create New Property\n\nlet prop = TextProperty { id: 0, r#type: \"number\".to_string() };\n\n// Create New Property Type\n\nlet prop_type = PropertyTypeBuilder::default().highlight(\"Constant\".to_string()).build();\n```\n\n## Channels\n\nWorking with Vim channels (see `:help channel.txt` in Vim).\n\n_Note: This is a low-level API. The eventual, high-level API should look like `let expr = Expr::from(\"line('$')\");`._\n\n```rust\nuse vii::channel::{\n    ChannelCommand,\n    Call,\n    Expression,\n};\n\n// Number of Lines in Current Buffer\n// [\"expr\",\"line('$')\"]\nlet expression = ChannelCommand::Expr(\n    Expression {\n        expression: \"line('$')\".to_string(),\n    },\n    None,\n);\n\n// Number of Lines in Current Buffer\n// [\"call\", \"line\", [\"$\"]]\nlet call = ChannelCommand::Call(\n    Call {\n        function: \"line\".to_string(),\n        args: vec![DataType::String(\"$\")],\n    },\n    None,\n);\n\n\nprintln!(\"{}\", expression.to_string());\n// [\"expr\",\"line('$')\"]\nprintln!(\"{}\", call.to_string());\n// [\"call\", \"line\", [\"$\"]]\n```\n\n# Contributing\n\nIf there are any features you would like added, found any potential bugs, or have any questions, then feel free to create an issue.\n\n## Testing\n\n`cargo test`\n\nUnittests are in the same file, next to the units they are testing (bottom). Integration tests are in `/tests/`.\n\n# License\n\nLicensed under either of\n\n- Apache License, Version 2.0\n  ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license\n  ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceofspades5757%2Fvii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faceofspades5757%2Fvii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceofspades5757%2Fvii/lists"}