Comments (5)
@kflak There has been some discussion recently with the merge of the luasnip
snippet format. I would like to include options for snippet generation in this PR
I'm still not so sure how we would handle (autogenerated) mutli-line snippets transparently though, afaik this is not something I've seen before. The only option that I can think of at the moment is to have two version of each snippet and let the user select. This would double the amount of snippets generated though which is already quite extensive..
What I envision is to have different formatting options for snippet generation, maybe different styles e.g. compact
, and ignore mul/add
would be nice. Maybe multiline
could also be an option?
With that said, another possibility would be to write a small function which expands a single line statement into a multiline after the actual snippet has been inserted. Something like this (note not extensively tested, cursor needs to be placed before the opening (
for this to work)
--- Split a single line function call into one parameter per line
function split_single_call()
local lnum, col = unpack(vim.api.nvim_win_get_cursor(0))
vim.api.nvim_buf_set_mark(0, '<', lnum, col, {})
-- find the open paren
vim.cmd[[normal! f(]]
vim.cmd[[exe "normal! a\<cr>"]]
-- find the closing paren
vim.cmd[[normal! f)]]
vim.cmd[[exe "normal! i\<cr>\<esc>k"]]
-- perform the split
vim.cmd[[s/,/,\r/g]]
lnum, col = unpack(vim.api.nvim_win_get_cursor(0))
vim.api.nvim_buf_set_mark(0, '>', lnum, col, {})
-- reindent
vim.cmd[[normal! vgv=]]
end
from scnvim.
@kflak It would be simple to generate two versions of each snippet, one split on newlines as the example you posted. However, this will also make users have to choose between the two alternatives when expanding each snippet. Maybe this can be configured in the snippets engine somehow, there could be another keybinding for this perhaps.
Keeping the argument description would also be easy to implement. This could be a user setting as you mentioned. Another feature I've been thinking about is to have a setting to not include mul: 1, add: 0
in the snippet, since this can be accomplished easily outside of the method call.
from scnvim.
I'm just starting to wrap my head around UltiSnips, so I don't know too mch of how this would work, but I like the idea of setting up two different keybindings, one for each alternative. And dropping mul
and add
from the snippets would be very nice indeed :-)
from scnvim.
Hi,
Just wondering if there has been some movement on this? Otherwise I'd be happy to get some pointers on how to do this myself, so that I could possibly contribute a PR :-)
from scnvim.
This is great, I'll give that function a go at some point in the near future! Thanks for the tip.
from scnvim.
Related Issues (20)
- [FR]: optional use tmux instead of vim terminal HOT 3
- No setup function for lua config HOT 2
- [BUG] viewing help with pandoc throws ERROR: Message 'getHelpUri' not understood HOT 4
- [BUG] Keymaps don't work HOT 4
- [ SCNvimStart - cannot start sclang process || Unrecognized handler || ERROR: Class not defined ] - medley HOT 2
- [FR]: Return to Normal mode after evaluating a Visual mode block HOT 2
- [FR]: description for scnvim.map keymaps
- [BUG] Error If postwindow float in not enable HOT 2
- [FR]: More documentation on how to use it: describe how you can run code HOT 5
- [FR]: Implement Arrays in SCNvimJSON:stringify HOT 3
- [BUG] Error executing vim.schedule lua callback: […] Unrecognized handler HOT 2
- [BUG] Toggle post window leaves empty buffers HOT 6
- [BUG] scnvim foobar HOT 5
- [BUG] Syntax highlighting is not consistent with multiline strings HOT 2
- [BUG] s.meter only works after recompiling class library HOT 3
- [BUG] Editor commands do not work HOT 2
- [BUG] Error using pandoc on Linux HOT 1
- [BUG] Reloading a session with scnvim using Startify causes errors HOT 1
- [BUG] need help with tags file on wsl HOT 6
- [BUG] SCNvim crashes out of Neovim from too fast input. HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scnvim.