ultisnips
ultisnips copied to clipboard
Add a denite source
unite is officially declared as deprecated by the author and denite is the successor. If there is a unite source for ultisnips, there should also be on for denite then.
https://github.com/neoclide/ultisnips already has an implementation for that. Would be nice if that could get merged.
@chemzqm It seems you are the author of a few patches to UltiSnips, including a denite source. Would you mind contributing them back?
@SirVer the problem is it requires snippet location for edit action to work, in pythonx/UltiSnips/snippet_manager.py
there is:
_vim.command(as_unicode(
"let g:current_ulti_dict['{key}'] = '{val}'").format(
key=key.replace("'", "''"),
val=description.replace("'", "''")))
there is no way to add extra location information without change the API, so I did that in my fork, I've changed to use list for the return value of snippets_in_current_scope
@chemzqm Can you not always call let snippet_list = UltiSnips#SnippetsInCurrentScope(1)
? That always passes you the location back.
@SirVer There is argument check for UltiSnips#SnippetsInCurrentScope(1)
https://github.com/neoclide/ultisnips/blob/2cd5230abaf1066d403fe8f1329d1e02d30cc5b0/rplugin/python3/denite/source/ultisnips.py#L48
I need to get the location of all snippets so I can provide edit action, I have changed the source code of snippets_in_current_scope
function to always give more infomation at https://github.com/neoclide/ultisnips/blob/2cd5230abaf1066d403fe8f1329d1e02d30cc5b0/pythonx/UltiSnips/snippet_manager.py#L172
I didn't contribute that since I noticed this is a break change.
Just find #981 is related
Any progress on this? Would be really helpful to have such a source for remembering the snippets that are available.
I just tried to hack something. What about this:
from .base import Base
class Source(Base):
def __init__(self, vim):
super().__init__(vim)
self.name = 'ultisnips'
self.kind = 'command'
def gather_candidates(self, context):
candidates = []
snippets = self.vim.eval(
'UltiSnips#SnippetsInCurrentScope()')
for trigger in snippets:
candidates.append({
'word': '{} -- {}'.format(trigger, snippets.get(trigger, '')),
'action__command': 'exe "normal a{} " | '
'call UltiSnips#ExpandSnippet()'.format(
trigger),
})
return candidates
I am interested in this working. Is this something that is on the horizon?
@pdoak Help would be appreciated! I think the right way to go about this is to add a new function that returns the information required and mark the already existing one as deprecated. This is essentially retracing what @chemzqm did in his fork, but retaining backwards compatibility + adding tests.
Depends on #981.