项目作者: rokf

项目描述 :
Snippet plugin for the Vis editor
高级语言: Lua
项目地址: git://github.com/rokf/vis-snippets.git
创建时间: 2020-01-28T20:32:55Z
项目社区:https://github.com/rokf/vis-snippets

开源协议:MIT License

下载


vis-snippets

This is a plugin for vis that adds an ability to replace ranges with pre-defined text (aka. snippets).

Installation

On your typical Linux distribution you can do the following:

  1. cd ~/.config/vis
  2. git clone https://github.com/rokf/vis-snippets

Then require the plugin and configure snippets using its register method:

  1. local snippets = require('vis-snippets/snippets')
  2. assert(snippets:register("lua", {
  3. ["fun"] = "function () end"
  4. }))

Snippet registration

Snippets are registered per syntax (language). Multiple separate registrations can happen per syntax. The register method is going to combine them.

The register method should be invoked as a method (:). Its first (second to self) para,eter is the syntax name (string). The second parameter is a table of key value pairs.

Keys should be strings that are to be replaced with their values (also strings).

Usage

Select a range of text in the VISUAL mode. Run the :snip command. The text in the range should be replaced by the matching snippet, otherwise an error message will be written out into the info line.

The :snip command should correctly cooperate with other features of vis, that accept commands. For example x/hello/ snip should replace all hello instances with a snippet through the snip command - if a matching snippet exists.

Weird behavior should be reported through issues on GitHub.

Possible improvements

  • Improved multiline snippet insertions, where indentation is respected.
  • Unit tests for non-vis functions/methods.

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.