Comments (13)
would you like to try ?
key map
let g:ulti_expand_or_jump_res = 0
function! SmartTab()
if pumvisible() == 1
return "\<C-n>"
else
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\<Tab>"
endif
endif
endfunction
inoremap <silent><expr><CR> pumvisible() ? "<C-R>=<SID>ExpandOrClosePopup()<CR>" : "\<Cr>"
snoremap <silent><Tab> <Esc>:call UltiSnips#JumpForwards()<CR>
inoremap <silent><S-Tab> <C-R>=SmartSTab()<CR>
Steps:
- please use above key map
- plugin ncm2/go-languageserver
- input if, then press Tab to trigger snippet, then cursor is at first placeholder
- input "tr", then ncm2 will popup menu. press Tab/C-n to choose completion true
- press Enter key, you will find cursor is at if block body(in {})
But above keymap lose function parameter expand. Then change Entry map to your suggestion:
inoremap <silent> <expr> <CR> ncm2_ultisnips#expand_or("\<CR>", 'n')
Re-execute above steps, you will find explicit Enter key is accepted, as result, newline is inserted, { is moved to newline
from ncm2-ultisnips.
i understand now, but it will cause vimrc ugly/complex. UltiSnips provide API UltiSnips#ExpandSnippetOrJump(). How about change ncm2_ultisnips#expand_or to ncm2_ultisnips#expand_or_jump_or ? appreciated for this wonderful plugin.
from ncm2-ultisnips.
I'm not sure what you what.
After the snippet is expanded, ultisnips will automatically jumps to the first snippet tabstop/placeholder.
If you're encountering wired behavior, better to post a gif to describe the issue.
from ncm2-ultisnips.
maybe i hope to jump next placeholder. currently, based on example, press Enter key, it will input new line, but i want to jump to next placeholder(if body). i will try to find a gif tool to record.
thank you!
from ncm2-ultisnips.
If you want a different order of placeholder, you should modify the snippet instead of modify the plugin
from ncm2-ultisnips.
diff --git a/autoload/ncm2_ultisnips.vim b/autoload/ncm2_ultisnips.vim
index ac80a21..e165896 100644
--- a/autoload/ncm2_ultisnips.vim
+++ b/autoload/ncm2_ultisnips.vim
@@ -33,6 +33,11 @@ func! ncm2_ultisnips#_do_expand_or()
call feedkeys("\<Plug>(ncm2_ultisnips_expand)", "im")
return ''
endif
+ let g:ulti_jump_forwards_res = 0
+ call UltiSnips#JumpForwards()
+ if g:ulti_jump_forwards_res == 1
+ return ''
+ endif
call call('feedkeys', s:or_key)
return ''
endfunc
That's what I want.
from ncm2-ultisnips.
You could wrap your own <Plug>forward_or_cr
key so that you could map a key like this:
inoremap <silent> <expr> <CR> ncm2_ultisnips#expand_or("\<Plug>forward_or_cr", 'm')
from ncm2-ultisnips.
I have exported two API, you should be able to program you own key mapping based on
ncm2_ultisnips#completed_is_snippet()
and
ncm2_ultisnips#inject_completed_snippet()
from ncm2-ultisnips.
thank you. Based on requirement, would you like to give an example ? Sorry, I don't know how to do because knowledge of vim script is very limited.
Anyway, thank you!
from ncm2-ultisnips.
ncm2_ultisnips#expand_or
is an example for the two APIs
from ncm2-ultisnips.
Sorry if I am overly confused. Using this extension for ncm2 with your recommended configs for both does not allow for auto-completion and rotation through options with and . How should we go about solving this?
from ncm2-ultisnips.
If you're having trouble, you need to post your minimal vimrc and elaborate the reproducing steps. Another issue should be open too.
from ncm2-ultisnips.
This isssue is a bit old, but yes this would be great to have.
Currently I can expand a snippet from ncm2 by pressing enter with the following mapping:
inoremap <silent> <expr> <cr> pumvisible()
\ ? ncm2_ultisnips#expand_or("\<c-y>", 'n')
\ : "\<cr>"
But I'd like to additionally be able to press enter again to jump to the next placeholder.
This is how <Plug>(neosnippet_expand_or_jump)
in neosnippet works.
Edit - it occurred to me that something like this might work but it doesn't:
let g:UltiSnipsJumpForwardTrigger="<c-b>"
inoremap <silent> <expr> <cr> pumvisible()
\ ? ncm2_ultisnips#expand_or("\<c-y>", 'n')
\ : ncm2_ultisnips#completed_is_snippet()
\ ? "\<c-b>"
\ : "\<cr>"
from ncm2-ultisnips.
Related Issues (18)
- gifs
- List normal snippets as well HOT 6
- [Bug] Completion text is inserted when ncm2-ultisnips is installed HOT 8
- Function parameter expansion not working? HOT 2
- UltiSnips LSP function snippets not working HOT 7
- Show all UltiSnips completion HOT 3
- conflict with Utils plugin HOT 1
- Compatible issues with auto-pairs HOT 2
- Typescript parameter expension supported? HOT 1
- vimrc example is wrong HOT 1
- vim-snippets rust only the "trait" snippet incorrectly expands HOT 3
- Python parameter expansion with LanguageClient HOT 1
- clangd snippet not working HOT 4
- Could not complete too long defined python function? HOT 1
- LSP function parameter expansion doesn't work HOT 2
- How does parameter expansion work? HOT 1
- Deletion of lspitem field prevents autoimport from working
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 ncm2-ultisnips.