Code Monkey home page Code Monkey logo

snip-cli's Introduction

A CLI (snip-cli) Tool for Managing Neovim and VSCode Snippets

Rust Build and Test

release

Note: This is an additional tools to be used with my Neovide Neovim rust setup.

VSCode Snippet Compatible

Installation

  1. You can Download and Install snip-cli on Releases Page Note: on MacOS you might need to go to System Preferences > Security & Privacy > General and click Open Anyway to install it

Note: on Windows you might need to Add the command to ENV PATH

  1. Install it using Cargo
cargo install snip-cli --bin snip

Managing Multiple Snippets File for Different Languages

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.

Location of Config Path

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.

Usage:

  1. Help
snip
# or
snip --help
Output
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
  1. Add new snippet
# help
snip add --help
# Add Snippet
snip add --key <key> --value <value> --description <description> -- "<snippet>"
  1. Remove snippet
# help
snip remove --help
# Remove Snippet
snip remove --key <key>
  1. List all snippets
# help
snip ls --help
# Usage
snip ls <LIST_OPTION | (key or prefix)>
# List all Keys
snip ls key
# List all Prefixes
snip ls prefix
Output
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
  1. Update Key
# help
snip update-key --help
# Update Key
snip update-key  --old-key <old-key> --new-key <new-key>
Output
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"
  1. Update Snippet
# help
snip edit --help
# Update snippet Value
snip edit --key <key> --prefix <prefix> --description <description> -- "<snippet>"
  1. Search Snippet
# help
snip search --help
# Search Snippet
snip search <ID | (key or prefix)> -- "<search_term>"
Output
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
  1. Show Snippet
# help
snip show --help
# Show Snippet
snip show <key_id>
Output
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}                           |
|             |     }                                                       |
|             | }                                                           |
+-------------+-------------------------------------------------------------+
  1. Config Snippet Note: This can be used to switch Configuration e.g. you wanna manage Python Snippet , you can do just pass in the PATH to that configuration file.
# help
snip config --help
# Config Snippet
snip config <path>

snip-cli's People

Contributors

codeitlikemiley avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

younghakim7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.