Giter Club home page Giter Club logo

sniper's Introduction

sniper

the hopefully cross-platform, potentially editor agnostic, probably over-ambitions and definitely over-engineered snippet management server

WARNING: this is very early, and implementation details will definitely change as I work to implement this in vscode.

Description

Sniper is an editor agnostic stateful snippet manager. The snippet syntax is currently superset of that defined by the LSP's snippet syntax specification. While right now the snippet directory is static (located at ~/.config/sniper), this means existing vscode snippets are compatible.

(When its done) Why Use Sniper?

TL; DR

  • you can write snippets that will be usable in every editor with a client
  • it's one less thing you have to set up when trying out a new editor, or writing your own
  • snippets are
    • modular: you can load and unload sets as you need them
    • composable: you can make snippets out of other snippets,
    • programmatic, still working out the details, but I plan on using grpc streaming along with scripting support(wasm? python? lua? good ol' sh? your guess is as good as mine.)
    • and (eventually) package-based and hands-off: just install the server and don't worry about the rest, unless you want to

my goal since the beginning of this project has been to make a system that goes beyond providing basic autocompletion and support context aware dynamic code generation.

Rationale

IMO, part of the reason snippets aren't more widely used is because of the individual effort involved. You could install the base snippets you have for your editor, but they aren't really flexible enough to justify putting a lot of time into creating custom ones. With snippet managers like ultisnips or hsnips(which I feel are powerful enough to justify use) if you make snippets for those tools, their utility is limited to a small subset of developers using the same editor and plugin. In both cases suggestions and the list of options isn't changed by file/project specific context, such as whether a certain library is imported. if you snippets for numpy, other than swapping out the snippets being loaded, they will always remain suggested. This project is set up to load a base set of snippets, with the ability to load/unload snippet libraries as needed (hopefully automatically depending on what I can get from the in play language server).

Currently I'm working towards supporting a superset of the LSP snippet syntax, which by itself isn't much, but will make it rather easy to implement snippets in new editors (rather than building the functionality inside the editor or a plugin for the editor), and also makes it easy to use your current vscode snippets across editors(once they are implemented).

Eventually I want to support some system of snippet sharing/distribution whether through simple github gist or something like cargo crates. my goal is to make it to where you could run something like sniper --install-recommended and download snippets for the languages and the libraries which you have on your system.

As an example: it's fairlyeasy to build an rpc service with libraries like tonic or tarpc, but I want to make it to where you can do so with minimum keystrokes, in a way that supports the contextual nuance required to build one for your specific project.

Installation

first build the server and place it somewhere on your path

git clone https://github.com/skewballfox/sniper && \
cd sniper && \
cargo build --release -p sniper-server && \
cp ./target/release/sniper $HOME/.local/bin/ 

ps: if you don't want to actually put it along your path and just want to test the server, then copy the first 3 lines (excluding the last &) and then run cargo run -p sniper-server

otherwise you can then launch the server

sniper

then it's ready to use, for example with the test client:

cargo run -p sniper-client

sniper's People

Contributors

dependabot[bot] avatar skewballfox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sniper's Issues

fix essential parsing.

In order to have snippets composed of snippets, without adding anything else, it is necessary to parse tabstops and subsnippets, and store their correct locations.

Since this is a rather vague problem, composed of a lot of smaller but related specific problems, it's probably best to just make this into a list of issues.

here are the problems right now:

  • need to append \n to the end of end text sections, OR need to change how snippets are stored so that they are a single string rather than a vector of strings
  • need to handle component creation directly from the parser
  • need to actually handle variables/Functors
  • need to handle the transforms of variables

this list will be updated as I make progress or discover new issues.

consider moving from `mpsc::chanel` to `ringbuf` w/ `notify`

not at all necessary and pretty low on the list of priorities, but I kind of want to experiment with the combination of these two given that the logic for returning a snippet is synchronous, with only asynchronous part being returning components as they become available.

I first came across this suggestion in this comment on a relevant rust user forum post

definitely want to benchmark the two implementations against each other though, so this should probably wait until much later

cross platform support

there is mainly 2-3 things that need to be done to make this cross platform:

  1. switch from tokio's unix domain socket pair to something like interprocess,
  2. make sniper-config more flexible in the paths it handles/allows
  3. if daemonizing, write a script to set up on installation as a windows service

Once these are done, this should work on both windows and unix platforms(linux, mac, possibly bsd)

add variable support

In order to support the snippet syntax in editors without builtin snippet functionality, and also in order to support variables beyond those specified in the specification, variables (eventually) will have to be handled by sniper itself.

this also adds a much needed layer to the parsing logic. Right now the parsing is only handled on the first call of the snippet, modifying it so that future calls won't have to rebuild a snippet composed of snippets. But variable handling(along with static text transformations), will have to be handled per call.

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.