Automating store_selection_keys #584
Replies: 2 comments 3 replies
-
Ouh, feedkeys is a bit difficult, because it will not immediately execute, I'd recommend reading We don't have an api for storing visual, we did not want to manually implement deleting the selection (here's the implementation). |
Beta Was this translation helpful? Give feedback.
-
Hi L3MON4D3, Sorry to bug you about this again. I'm trying to utilize store_selection but random lines are being stored in the selection and not necessarily what is highlighted before being in the snippet: `if vim.api.nvim_get_mode().mode == "V" or vim.api.nvim_get_mode().mode == "v" then ls.snip_expand(snippet)` I was trying to copy over the function directly from the implementation but it was throwing a syntax error around the <.
|
Beta Was this translation helpful? Give feedback.
-
Hi friends! I have mappings for generating snippets via lua functions, I'm trying to automate the process of wrapping lines in snippets like if statements or for loops if I have the line highlighted with line V mode. My store_selection_keys is set to
<C-s>
and in my function I try to automate the storing of the selection before expanding the snippet by trying to send<C-s>
to the buffer like so:vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<C-s>", true, false, true), vim.fn.mode(), true)
However when the snippet expands it doesn't expand the snippet around the line that I wanted. Anyone know if there is any API instead to store the selection or a better way to send the keys? Manually pressing Ctrl+s works before expanding the snippet.
Beta Was this translation helpful? Give feedback.
All reactions