Git Product home page Git Product logo

mattn / vim-sonictemplate Goto Github PK

View Code? Open in Web Editor NEW
331.0 13.0 42.0 731 KB

Easy and high speed coding method

Home Page: http://mattn.github.com/vim-sonictemplate

Makefile 5.52% C 9.98% Clojure 1.80% C++ 3.13% C# 0.45% D 0.18% Go 35.81% HTML 1.66% Java 10.36% JavaScript 6.99% Perl 9.91% Python 2.45% Ruby 2.52% Rust 0.10% Dockerfile 0.37% TeX 0.52% Scala 0.35% TypeScript 7.41% Kotlin 0.17% Elixir 0.34%

vim-sonictemplate's Introduction

sonictemplate

Easy and high speed coding method.

Template Completion

Postfix Completion

Basic Usage

Open new file

vim foo.pl
:Template <tab>

Then you can select package or script for perl filetype.

:Template package
:Template script

Type <enter> in script, you can see following.

use strict;
use warnings
use utf8;

_

And cursor is in _. If you open lib/Foo.pm, and type <enter> in package. You get following.

package Foo;
use strict;
use warnings
use utf8;

_

1

If you open C++ file, you can select main for C.

License

MIT

Author

Yasuhiro Matsumoto <[email protected]>

vim-sonictemplate's People

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  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  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  avatar  avatar  avatar  avatar

Watchers

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

vim-sonictemplate's Issues

How do you show all templates on status line?

Under

Template Completion

You have an animation with all the possible template files showing up on the status line at the bottom.
How should I set up vim to get this feature?

日本語でも結構です。

duplicate template names

Say one of the default templates is base-class.py

Then I want to modify that template based on my own liking, i put it in my custom template dir with the same name base-class.py.

Now if I do :Template <tab> , there will be 2 templates "class" and "class"

Do you think the plugin should let the custom template override the default, so there will be only one template "class"?
or maybe tell the users to call their templates with different names in the doc?

PHPでpostfix completionができない

概要

golangで動作したPostfix Completionの設定をPHPに移植したところ、
入力した文字が消去されるのみで、置換されない。

環境

nvim 0.5.0
debian8

最小環境

" minimum setting {{{
if empty(glob('~/.config/nvim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
messages   autocmd VimEnter * PlugInstall | source $MYVIMRC
endif

call plug#begin('~/.config/nvim/plugged')
Plug 'mattn/vim-sonictemplate'
let g:sonictemplate_vim_template_dir = expand('~/.config/nvim/sonictemplate')
call plug#end()
" }}}1

■PHPのpattern.stpl
\(\S\+\)\.var$
    var {{$1}} = {{_cursor_}}

再現手順

  1. pattern.stplを~/.config/nvim/sonictemplate/phpにコピー
  2. PHPファイルを開き、 xxxx.var と入力してから、を入力

発生する現象

入力した文字が消去されるのみで、置換されない。

期待する動作

var xxxx = {{cursor}};に置換される

備考

autoload/sonictemplate.vim の364行目
let c = join(s:pat[s:get_raw_filetype()][k], "\n") の中を出力したところ、
golangでは['var {{$1}} = {{cursor}}']
PHPでは[ ]と空になっておりました。

また、coc.nvimを使用した場合、golangも同様の現象が発生し、
Postfix Completionができませんでした。

error - Template is not exists

I have created a custom template base-kickstart.java in ~/.config/nvim/templates:

import java.util.Scanner;

public class {{_name_}}{
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int T = Integer.parseInt(input.nextLine());
		for (int ks = 1; ks <= T; ks++) {
			{{_cursor_}}
		}
    input.close();
  }
}

and added

let g:sonictemplate_vim_template_dir='~/.config/nvim/templates'

to init.vim. When I create a new file (:e test.java) and then :Template and press tab, I get kickstart in the tab completion.

However when I select it, I get Template kickstart is not exists.

The struct postfix of go have problem

The pattern.stpl of struct is

\(\S\+\)\.struct$
	type {{$1}} struct {
		{{_cursor_}}
	}

But when i type person.struct, I got this. | mean cursor.

type person struct{
      struct|
}

custom template dir

I put this in my .vimrc

let g:template_vim_template_dir = '$HOME/.vim/template'

and my template dir looks like this:

template
  |
  python
      |
     snip-doc.py

But it doesn't seem to load.

テンプレートを挿入した際に^Mが余分に付く

sonictemplate を git で core.autocrlf=true でclone した場合、任意のファイルを開いて :Template でテンプレートを挿入した場合に、&fileformetに関わらず挿入したコード/スニペットの各行末に^Mが付与されます。

git で core.autocrlf=true にしていると、テンプレートのファイルを含め、改行コードがCRLFの状態で clone されてしまいます。
その状態でautoload/sonictemplate.vim#L74 にて、それらのテンプレートを 'b' つきの readfile() で読み込んでしまうためだと考えられます。

comment line for stpl files

You cannot add line comments in .stpl files.
Adding __END__ seems to be a way of adding lines (not sure I'm right) which doesn't affect the behavior
of the plugin, which only provides very limited capabilities.
I believe comment lines can be implemented in autoload/sonictemplate#load_postfix(),
by simply skipping lines starting with # or such.

indentation

is there a way to indent the snips automatically? Here's what I got for Java, first :Template class then :Template getter-setter:

/**
 * test-tmpl
 */
public class test-tmpl {
    /**
     * Constructor
     */
    public test-tmpl() {
        final int a = 10;   
    }

/**
 * get a
 * @return a
 */
public int getA() {
    return a;
}

/**
 * set a
 * @param a
 */
public void setA(int a) {
    this.a = a;
}
}

How can I set a default value for `{{_input_}}`?

English

How can I set a default value for {{_input_}}?
In other words, when asked to type {{_input_}}, is there any way to input the default value by just typing enter key?

For example, I made the following snippet for python loop.

for {{_input_:i}} in range(N):

In most cases, I use i as a cursor. However, in some cases, e.g., making a double loop, I want to use another cursor such as j.
Thus, I want {{_input_:i}} to fill i by default and want to fill it if I needed.
Is there any way to do this?
Thank you in advance.

日本語

{{_input_}} オプションを使うにあたってデフォルト値の設定は可能ですか?
例えば、ほとんどのケースではデフォルト値でよいが、特定のケースではカスタマイズした値を入れたいと言った場合に、デフォルト値をエンターキーを押すだけといった簡単な動作で達成できるとうれしいです。

Error occurs when insert {{_inline_}} template with asyncomplete.vim

I found an error when using sonictemplate-vim with asyncomplete.vim.

How to reproduce:

  1. Trigger the SonicTemplate with mapping such as <C-y>t (:Template command works correctly)
  2. Select a snippet using the {{_inline_}} keyword.

2020-01-09 09_17_23-Window

My template is like below:

has('gui_running') {{_inline_}}

Postfix completion also occurs same error.

2020-01-09 09_53_54-Window

The error occurred at autoload/asyncomplete/utils/_on_change/textchangedp.vim in asyncomplete.vim.

I assume that TextChangedP or TextChangedI event were triggered but InsertEnter was not triggered when expanding {{_inline_}} templates (at #L298 #L376).

I think this is fixed when adding noautocmd to normal! command but I have no idea that either this
change affects to other part of sonictemplate functionalities or not.

noautocmd silent! exe "normal! a\<c-r>=c\<cr>"

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.