Gvim - YCM - show errors in balloons - vim

I was wondering if there is a way to show code errors in balloons like Syntastic when mouse hover on it.

Yes, there is a way, the one Syntastic is using already: "Balloon Evaluation" (read :h balloon-eval). You can basically set a balloonexpr which defines the text to show in the balloon. If you want to show the balloons by only hovering the mouse regardless of where the cursor is, that is not supported by VIM at the moment. To be honest, that sounds like a very useful idea for a popup menu on right-click (see :h mousemodel).

Related

How do I set vim's autocomplete popup menu location?

In vim, when using an autocomplete plugin (or just vim's built-in omnifunc), a window will pop up next to the cursor with completion suggestions:
Vim tries to be smart about where to put this menu, putting it below the cursor most of the time, but above the cursor if you're near the bottom of the window and don't have space to see the window.
I recently updated to a new version of vim (and YouCompleteMe, the autocomplete plugin that I use), and it seems that vim (or YCM, not sure which is responsible) is now overly aggressive in putting things above the cursor instead of below, where basically if you're in the top half of the window, the popup menu is below the cursor, while if you're in the bottom half, the popup menu is always above the cursor.
My question is, how do I control this behavior? It seems like it's probably a vim setting, but in all of my searching I couldn't find anything that would hint at how vim decides whether to put the popup menu above or below the cursor.
The only completion-related options are 'complete' and 'completeopt'. The placement of the complete popup menu is hard-coded in Vim's source code.
If you think this has changed for the worse in a recent Vim version, please open an issue at the bug tracker, or directly discuss this on the vim_dev mailing list.

Vim binding in browsers

I have been googling for a way to use vim bindings inside normal text fields in chrome. I've tried vmium and cVim but I can't figure out whether they have the functionality I'm looking for.
An example is this exact text area in which I'm typing my question. I'd like to be able to press Esc and go to vim command mode in here, and start deleting a line pressing dd.
Would that be possible? Or those plugins are just for navigation shortcuts?
Here's the answer!
Those plugins are for navigation only. If you want a Vi-like
experience in Chrome's textareas, try Wasavi. – #romainl
The cVim plugin allows for keyboard shortcuts to manipulate text inside text boxes. However, the shortcuts are not the same as vim and there are not as many. After installing the extension type ":help" to see the list of shortcuts.

Mac OSX Terminal Vim displays javascript code with weird and horrid shade

I develop javascript and just recently I found that I still love to use Terminal Vim instead of MacVim. Then I was totally annoyed when I opened my usual javascript file in the Terminal Vim: the statements of the code are irregularly highlighted with a mysterious color.
Just to clarify that other file types I have opened (e.g. c, html etc.) do not have the problem. I have scoured website but I could not find an answer. This is just so unacceptable, could someone help me out. A million thanks!
My .vimrc screen shot:
You appear to be using Syntastic.
The first line with the red background seems to be marked as an error.
The Error highlight group is very often set to use a red background.
My conclusion is that what you see is exactly what you should see. It is ugly on purpose and designed to look like that: you don't want to miss errors, do you?
However, Syntastic can be set to not use the Error highlighting to mark errors but the "signs" feature instead which is a lot less ugly.
You should have read the Syntastic documentation as it is all explained in plain english:
:help syntastic-error-signs
Also, set background=dark is not very useful (it doesn't change the background color, if that's what you want) and can be removed safely from your ~/.vimrc.
I found out that it was this plugin jslint.vim that caused the text to be highlighted. The problem is that this plugin could not be disabled properly which I thought I did. Thanks to the hint of #romaini, syntactic is a better plugin to check code errors and make proper configuration.
As a side note, for those who would like to use vim solarized color scheme, please use the solarized terminal color scheme first. Otherwise the color scheme won't be displayed properly.
Thank you for all of your comments and answers! Really appreciated.
Try changing your colorscheme. Open the file in Vim, then do
:colorscheme blink
To cycle through all possible colourschemes, type :colorscheme, then a space, then press Tab. When you reach a colorscheme that sounds promising, press Enter, and see if the text looks OK. Keep doing this until you find a colorscheme that you like.
Once you have found a colorscheme that you like, copy its name, and put the following in your .vimrc:
colorscheme name
(name is the name of the colorscheme you like.)
My favourite colorscheme is blink, but there are many good ones. You can even go online and download new ones if the defaults are not good enough.
Seems the syntax are not recognized correctly. Could you try:
:set filetype=javascript
One other thing to look at to make things look better (will change colors not highlighting). Make sure that your terminal reports itself as xterm-256colors. You can check this by typing echo $TERM.
If it doesn't return xterm-256colors go to Preferences -> Settings -> Advanced (tab) on the profile you are using.
Change the drop down at the top to xterm-256colors.

Can I get vim to show the current function/namespace/etc. in the bottom bar?

I love the sorts of features that applications like textedit and sublime edit have, where you can see the current namespace in a little bar in the UI. Is there any way to make vim do that?
The Powerline plugin shows the current function.
Would TagBar or TagList help? Both provide a small function to add to your statusline to that effect. Or maybe this other plugin?
I'm not fan of that kind of feature. I prefer to use <C-w>} when I need.
here's a one-liner you can put in your .vimrc (need to have taglist.vim installed though):
set statusline=%<%f\ [%{Tlist_Get_Tagname_By_Line()}]\ %h%m%r%=%-14.(%l,%c%V%)\ %P
...that'll show the current function your cursor is in as you move around.
I forget the specifics but sometimes you'll want to manually refresh it, in which case this mapping is useful:
map <F4> :TlistUpdate<CR>:TlistHighlightTag<CR>
^ that'll refresh the function name in your statusline when you press F4

In Vim, can you show a tooltip where the cursor is?

Is there a way to display a tooltip (like a popdown menu, but just with text), where the cursor is, using VimScript?
If you mean a tooltip where the mouse cursor is, then you can do this by turning the ballooneval option on and setting the bexpr option to point to a function that returns your required tooltip. This is only available if you're using a vim compiled with +balloon_eval (see :version). Have a look at my (rather basic) tag balloons script for an example.
If you mean a tooltip where the normal vim cursor is, I don't think there's a very clean way to do this. You could create a custom menu with the text that you want (using amenu) and map the command to :nop<CR> and use :popup to display it:
amenu ]MyMenuName.The\ Text\ You\ Want :nop<CR>
popup ]MyMenuName
However, this will only work in the Win32 and GTK GUIs.
I don't know of a way to use the insert mode popup menu (the one used for Ctrl-P and omnicompletion etc) to just display some text. You could abuse the completion method to give your own text as the completion alternative and set menuone in completeopt to allow a single line to be shown, but it would probably overwrite the current text with the contents of the popup menu. It would probably also break omnicompletion!

Resources