Crates.io | snip-cli |
lib.rs | snip-cli |
version | |
source | src |
created_at | 2023-12-19 09:58:37.491624 |
updated_at | 2024-12-09 04:45:31.057156 |
description | A CLI tool (snip-cli) for managing Neovim and VSCode snippets |
homepage | |
repository | |
max_upload_size | |
id | 1074150 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Note: This is an additional tools to be used with my Neovide Neovim rust setup.
VSCode Snippet Compatible
Note: on Windows you might need to Add the command to ENV PATH
cargo install snip-cli --bin snip
You can use the command snip config <path>
to change the Snippets File on Runtime.
Note: This is quite useful when you want to manage different Snippets File for different languages.
The DEFAULT_CONFIG_PATH
is ~/.config/nvim/snippets/rust/rust.json
as set on src/constants.rs
and is used during the build process,
but you can change it by setting the SNIP_CONFIG_PATH
environment variable.
snip
# or
snip --help
snip
/Users/uriah/.config/nvim/snippets/rust/rust.json
A CLI tool for managing Neovim LuaSnip Rust snippets
Usage: snip <COMMAND>
Commands:
add Adds entry to Snippet Collection file
rm Removes entry from Snippet Collection file
edit Edits entry in Snippet Collection file
ls Lists all entries in Snippet Collection file
show Gets entry from Snippet Collection file
search Searches for entries in Snippet Collection file
config Configures the Snippet Collection file
update-key
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
# help
snip add --help
# Add Snippet
snip add --key <key> --value <value> --description <description> -- "<snippet>"
# help
snip remove --help
# Remove Snippet
snip remove --key <key>
# help
snip ls --help
# Usage
snip ls <LIST_OPTION | (key or prefix)>
# List all Keys
snip ls key
# List all Prefixes
snip ls prefix
snip ls key
/Users/uriah/.config/nvim/snippets/rust/rust.json
[src/main.rs:468] list_option = Key
impl_iterator
serialize_to_json_string
impl_add_trait
impl_vec_iterator
unwrap_or_else
impl_deref
impl_debug_single_field
deserialize_json_string
impl_display_single_field
import_serde_traits
impl_clone_single_field
# help
snip update-key --help
# Update Key
snip update-key --old-key <old-key> --new-key <new-key>
snip update-key --old-key "Fuzz match String" --new-key "fuzzy-match-string"
/Users/uriah/.config/nvim/snippets/rust/rust.json
[src/main.rs:499] &old_key = "Fuzz match String"
[src/main.rs:499] &new_key = "fuzzy-match-string"
# help
snip edit --help
# Update snippet Value
snip edit --key <key> --prefix <prefix> --description <description> -- "<snippet>"
# help
snip search --help
# Search Snippet
snip search <ID | (key or prefix)> -- "<search_term>"
snip search key -- impl
/Users/uriah/.config/nvim/snippets/rust/rust.json
[src/main.rs:490] id = Some(
Key,
)
[src/main.rs:490] &name = "impl"
impl_deref
impl_clone_single_field
impl_iter_range
impl_partialeq_single_field
# help
snip show --help
# Show Snippet
snip show <key_id>
snip show impl_deref
/Users/uriah/.config/nvim/snippets/rust/rust.json
[src/main.rs:484] &key = "impl_deref"
+-------------+-------------------------------------------------------------+
| Key | impl_deref |
+-------------+-------------------------------------------------------------+
| Prefix | impl_deref |
+-------------+-------------------------------------------------------------+
| Description | Impl Deref and DerefMut traits for a custom type |
+-------------+-------------------------------------------------------------+
| Body | use std::ops::{Deref, DerefMut}; |
| | |
| | impl<${1:T}> Deref for ${2:YourConcreteStruct}<${1:T}> { |
| | type Target = ${1:T}; |
| | fn deref(&self) -> &Self::Target { |
| | &self.${3:your_field} |
| | } |
| | } |
| | |
| | impl<${1:T}> DerefMut for ${2:YourConcreteStruct}<${1:T}> { |
| | fn deref_mut(&mut self) -> &mut Self::Target { |
| | &mut self.${3:your_field} |
| | } |
| | } |
+-------------+-------------------------------------------------------------+
# help
snip config --help
# Config Snippet
snip config <path>
snip open
# or we can pass in the editor command e.g. code
snip open --editor code
This will open the configuration file in the default editor, or the editor specified with the --editor
flag.