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

[Question] How to get snippet to expand with a non-standard cursor position #1230

Open
ccatrett opened this issue Sep 2, 2024 · 3 comments

Comments

@ccatrett
Copy link

ccatrett commented Sep 2, 2024

I am using luasnip with nvim-autopairs and I would like to be able to expand (*) to \left ( * \right ) where the * represents where my cursor position is when I want to expand the snippet.

Is this possible in luasnip? I thought about using the snip_expand command but wasn't quite sure how it was meant to be used.

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Sep 3, 2024

Yeah, should be possible: check out condition and show_condition, you'd have to manually get the line the cursor is on (:h nvim_win_get_cursor, :h nvim_buf_get_lines), but should be pretty straightforward :)

@ccatrett
Copy link
Author

ccatrett commented Sep 3, 2024

@L3MON4D3 hmm. I am not quite sure what you have in mind. From the docs, i can't seem to piece together a solution; I am not sure how to use the conditions as there only appears to be begin and end line conditions and selected text conditions.

@L3MON4D3
Copy link
Owner

L3MON4D3 commented Sep 3, 2024

Oh, you can get the full line by querying the current position of the cursor and then getting the line, for which you can use the two api functions I linked above

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