Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get a list of the possible snippets programatically? #99

Open
khalidchawtany opened this issue Oct 1, 2022 · 1 comment
Open

Comments

@khalidchawtany
Copy link

khalidchawtany commented Oct 1, 2022

I want to integrate xptemplate into nvim-cmp. However, I cannot figure out how to get a list of possible snippets given an input.

For example: I have typed "i" without double quotes. How can I get all snippets that start with i?

I know about the <c->. However, I want to get the list calling a function.

Thanks

@drmingdrmer
Copy link
Owner

I'm unsure if the function call way meets your needs: the call will return some characters to emulate user input to trigger a popup menu.

These two functions have to be called in insert mode, and the return value has to be consumed as if they are keystrokes, with <C-r>=:

fun! ListSnippetsStartingWithPrefix() "{{{
    return XPTemplateStart(0, {"forcePum": 1})
endfunction "}}}

fun! ListAll() "{{{
    return XPTemplateStart(0, {"forcePum": 1, "popupOnly": 1})
endfunction "}}}

# i<C-r>=ListAll()<CR>

# i<C-r>=ListSnippetsStartingWithPrefix()<CR>

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants