vim 8, UltiSnips and coc-ultisnips: `${VISUAL}` does nothing - vim

Using vim 8, Ultisnips, and coc-ultisnips.
Consider this snippet:
snippet cdeg "Add console.debug({})"
console.debug(${0:${VISUAL:value}})
endsnippet
I would expect it to expand cdeg to console.debug(value).
The problem is if I have that buffer:
hello
Then visual select hello, press C to replace it with cdeg and then expand. I would expect the buffer to look like that:
console.debug(hello)
But instead, I get
console.debug(value)
So it would seem ${VISUAL} has no effect with coc-ultisnips. Any idea what is going on, and how to have coc-ultisnips behave like UltiSnips regarding ${VISUAL}?

It could be that I was using it wrong. In UltiSnips, you have to visual select, then press , then your snippet, then again. Only then do you get your visual selection inserted.
I don't know if this works with coc-ultisnips, because I have switched back to YouCompleteMe + UltiSnips and Supertab: YCM provides better completion results for TypeScript and works fine with UltiSnips.
This is the ticket to using Tab for YCM and UltiSnips together: https://stackoverflow.com/a/22253548/10421344

Related

Toggling preview tab for pydoc

I am new to VIM and I had this happened on few occasions. I am using these plug-ins:
nerdcommenter-master
vim-autoclose-master
vim-multiple-cursors-master
nerdtree-master
vim-autocomplpop
Sometimes I am typing python commands and autocomplete comes up, and I accidentally hit something. This new tab pop-ups with help text, describing the autocompleted command, basically like using pydoc. I'd like to know what this is called and how can I invoke it (I find it very useful).
What you see is the omni completion from the Python filetype plugin that ships with Vim, in $VIMRUNTIME/autoload/pythoncomplete.vim. It is automatically triggered by the AutoComplPop plugin. You can also explicitly invoke it by pressing <C-x><C-o> in insert mode; :help i_CTRL-X_CTRL-O.
The preview comes courtesy of :set completeopt+=preview.

Vim format source code from Visual mode

watching a screencast (can't link it since you need to have a peepcode pro subscription) I've seen a developer indenting his source code (a ruby file) graphically using the visual mode inside vim. He did the following steps: press "v" selecting lines and then pressing something else I didn't get (because there is no representation of what's being pressed on the keyboard), then he got the whole source perfectly indented, without the need to write something on the command line.
Is there a plugin you know to do it that way from visual mode?
You can press = in visual mode to automatically indent your code.
Or you can use > and < in visual mode to change the indentation level
of the selected code.
This plugin does exactly what you want: https://github.com/Chiel92/vim-autoformat.
That would be V(motion)=.
See :help = for details.

Not able to hide <# and #> with parameters for clang_snippets=1 with clang_complete

I've set this on my .vimrc:
let g:clang_snippets=1
let g:clang_snippets_engine='clang_complete'
let g:clang_conceal_snippets=1
set conceallevel=2 concealcursor=inv
I don't know how conceal is expected to work, maybe the clang_complete's docs should have a tip for a specific setting to hide the snippets adorns.
How do I hide it? I'm using MacVim built with +conceal, but it's not working. This is my messy .vimrc by now.
NOTE:
I'm sticking with g:clang_snippets_engine='clang_complete' because it seems to be more smart than the snipMate parameter completion, switching to NORMAL mode is a wiser choice to navigate between parameters since I can use SuperTab completion for params in INSERT mode while being able to navigate through them with the same tab at NORMAL mode. snipMate engine was acting weird to me sometimes too, sometimes it switched to a parameter after a completion, sometimes not.
Also, I'm missing a final tab to go after the last parameter, right after the function call (snipMate does that), so I can just insert ; and hit Enter.
Disclaimer: This question is related with the issue at https://github.com/Rip-Rip/clang_complete/issues/176.
EDIT:
My problem was with this line at my .vimrc:
au BufNewFile,BufRead *.cpp set syntax=cpp11
I'm using C++11 Syntax Support and #xaizek has discovered and pointed it out as the problem in the comments bellow in the accepted response, it seems the root cause is the use of the syntax clear command in it.
According to :help 'concealcursor':
Sets the modes in which text in the cursor line can also be concealed.
When the current mode is listed then concealing happens just like in
other lines.
n Normal mode
v Visual mode
i Insert mode
c Command line editing, for 'incsearch'
So with concealcursor=iv you asked Vim to hide concealed text in insert and visual modes, but show it in normal mode. So just do:
:set concealcursor=inv

Vim function hints for C

I'm trying to achieve something simple, usually called "function hints". For example, scintilla-based editors have it:
You type a name, and just get the prototype. There are a few problems with that in vim:
You have to rebuild the ctags to keep it up to date
You can't type C-X C-O after the (, you'll just get "Pattern not found"
You can't type C-X C-O in normal mode, the cursor will just jump around
You get the annoying preview window at the top
I've tried a few plugins; most of them mess things up even more [^1].Can anyone recommend a simple way to get just that ? A simple rectangle containing the function prototype and nothing more.
[^1] It's really mind-numbing how idiotic some of these plugins are. One plugin (I won't mention it) actually contained in the .vim file a list of functions from libc.
ctags for autocompletion is a mess. I suggest you try a compiler based plugin such as clang-complete or gcc-sense (haven't tried this one). Advantages are:
more accuracy as what they do is pretty much compiling
compile errors are marked on the fly over the source code
You have to rebuild the ctags to keep it up to date
you don't need to deal with ctags (they are still useful to jump around though)
You can't type C-X C-O after the (, you'll just get "Pattern not found"
what would you expect?
You can't type C-X C-O in normal mode, the cursor will just jump around
you can always remap that sequence if you think it's a frequent mistake (something like nnoremap <C-x><C-o> a<C-x><C-o>)
You get the annoying preview window at the top
You can disable this by removing preview fromcompleteopt option. see :help completeopt
I'm using the following setup:
clang-complete for completion
supertab to complete with tab key
ultisnips for function signature placeholders. (also works with snipmate)
and some vimrc settings:
set pumheight=10 " so the complete menu doesn't get too big
set completeopt=menu,longest " menu, menuone, longest and preview
let g:SuperTabDefaultCompletionType='context'
let g:clang_complete_auto=0 " I can start the autocompletion myself, thanks..
let g:clang_snippets=1 " use a snippet engine for placeholders
let g:clang_snippets_engine='ultisnips'
let g:clang_auto_select=2 " automatically select and insert the first match
Enjoy!
Try to use eclim (plugin for integration with Eclipse).
This solution is overheaded a lot but it works in all cases.

How can I import more code completion in vim?

I program using java and vim and I want to figure out how to do code completion in vim. I downloaded the vim plugin javacompletion and it works, but it only for j2se but not for android source code.
Is there any code completion in vim for andriod source code? I would like that when I, for example, enter "TextView." (the class in android.jar) and press ctrl+x ctrl+o, it should show the functions in TextView.
Have look at Vjde vim plugin.
I remember using it before and you just have to tell it to also look inside android.jar for the stuff to autocomplete.

Resources