emmet-vim icon indicating copy to clipboard operation
emmet-vim copied to clipboard

No way of adding custom snippets seems to function

Open OndraX opened this issue 7 years ago • 0 comments

So first off, many thanks for the great work in bringing this awesome plugin into Vim as well.

However: I've tried to set up my own abbreviations/snippets using it (as per the readme; on a sidenote, the help provided there is really sparse), doing:

{
	"javascript": {
		"filters": "js",
		"profile": "js",
		"abbreviations": {
			"br": "<brzzz/>",
			"foo": "fullName: Ember.computed('firstName', 'lastName', {\n\tget() {\n\t\treturn `${this.get('firstName')} ${this.get('lastName')}`;\n\t}\n})"
		}
	}
}

in my ~/.vim/snippets.json (yes this is exactly the code krzkrzkrz had in his file in https://github.com/mattn/emmet-vim/issues/293; that is because he later reported it to work and I couldn't find an "official" example that was guaranteed to work -- the pointer to emmet's official guide still leaves the issue of my own potential JSON errors open; I can submit my own attempt at the file upon request) and

let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.vim/snippets.json')), "\n"))

in my ~/.vimrc of course also having installed the webapi plugin (via pathogen) However, in my sample index.js file, typing foo resulted in a

Another side note: How do I then add my own, vimscript-dictionary-esque other configuration settings, or should everything be in snippets.json?

Also, trying the vimscript way (again, copying the example code) and instead "manually" setting the user_emmets_settings global to this:

 let g:user_emmet_settings = {
 \  'indentation' : '  ',
 \  'perl' : {
 \    'aliases' : {
 \      'req' : 'require '
 \    },
 \    'snippets' : {
 \      'use' : "use strict\nuse warnings\n\n",
 \      'warn' : "warn \"|\";",
 \    }
 \  }
 \}

and typing req_,, ; use_,, ; or warn_,, , I simply saw all of them expand to an HTML-esque tag instead of the desired sequence of characters.

I must be missing something (JSON grammar, for example). But none of this seams to work for me. Any help (or readme expansion) would be greatly appreciated.

OndraX avatar Jul 30 '18 10:07 OndraX