Can I write Vimscript in my IdeaVim .ideavimrc file? - vim

I am experimenting with Vim mode in the various JetBrains editors, using their IdeaVim plugin.
I'm trying to port over some of the existing functionality from my native .vimrc file. However, I don't seem to be able to get even the simplest vimscript function to work in my ~/.ideavimrc file.
After some searching I can't determine if this is something that IdeaVim even supports. Can I execute functions in the JetBrains editors with the IdeaVim plugin enabled?

You can use only a very limited set of Vim commands like some "set" options, various "map" commands, etc. See the IdeaVim repository on GitHub for more info.

Related

How can I get realtime auto-completion on Python instead of having to press <ctrl-x> <ctrl-o> in Vim?

Currently, I have these plugins in Vim running on zsh shell:
Valloric/YouCompleteMe
davidhalter/jedi-vim
The vim also has support for Python 2 and Python 3.
I would like Vim to do autocompletion for every keystroke in realtime instead of having to press <ctrl-x>,<ctrl-o>, which is cumbersome. How can I achieve it? Thanks.
The acp.vim plugin (formerly named AutoComplPop) automatically opens the completion popup as you type. With the .,w,b,k configuration, you can make it use different completion sources, like omni or dictionary completion. neocomplete apparently also has this feature. Maybe this is already included in YouCompleteMe, too. Might be worth reading its documentation.

Ideavim plugin for Intellij keymaps

I'm trying to get the Ideavim plugin to work correctly in Intellij IDEA and PyCharm, but the documentation is rather poor and I can't configure it properly.
For starters, the documentation tells me to choose the VIM keymap under Preferences/Keymap but there is no VIM keymap there before or after installing Ideavim.
Also, according to the documentation some plugins are suposed to be supported (altough the documentation doesn't say wich and only talks about vim-surreound), but even after putting the line in ~/.ideavimrc:
set vim-surround
The vim-surround commands simply don't work.
Also, where are the actions/commands list that can be used in ~/.ideavimrc to map some keybinding.
For instance, imagine I want to remap <leader> f s to save my file. Where do I find out the commands available so that I can put something like in ~/.ideavimrc:
let mapleader = " "
nmap <LEADER>fs :SaveFile<CR>
Vim-surround emulation is not released yet. You can download CI builds that include vim-surround support using a link at https://github.com/JetBrains/ideavim.
In order to enable vim-surround, use:
set surround
You can list all the IDE commands available for mapping using :actionlist. See the documentation at the GitHub page.
Update: IdeaVim 0.46 supports vim-surround commands.

How can I use vim plugins with Ideavim?

I would like to use Tim Pope's vim surround plugin in my Pycharm IDE. I've been using the IdeaVim plugin for Pycharm to use vim motions and commands.
I know I can use ~/.ideavimrc like my normal .vimrc but I cannot find
information about how to use plugins with ideavim.
Can I specify the plugins directory inside my ~/.ideavimrc or do I have to go another way? Can I use a plugin manager like pathogen?
The latest version of IdeaVim includes the vim-surround plugin. Enable it by adding
set surround
to your .ideavimrc file
https://github.com/JetBrains/ideavim#emulated-vim-plugins
Most applications only emulate Vim's / vi key bindings (and often only the basic navigation and editing commands). That goes a long way to helping vi users edit comfortably, but it isn't the real thing.
Unfortunately, to be able to use Vim plugins, you'll need the full Vimscript interpreter and infrastructure around 'runtimepath'. I'm not aware of any application that provides this, and because of the complexities and idiosyncrasies of Vim, this would be very hard indeed.
To get more of Vim's special capabilities into your IDE, use both concurrently; it is very easy to set up a external tool in your IDE that launches Vim with the current file (and position). Automatic reloading of changes allows you to edit source code in both concurrently.
If it's any comfort to you, the same applies to Emacs / Elisp as well.
The ideaVim plugin added "Support for vim-surround commands ys, cs, ds, S, enable it with set surround in your ~/.ideavimrc" since version 0.46.
No. Vote for VIM-506 for Vim scripts support (unlikely to be implemented) and for VIM-769 for vim-surround emulation (likely to appear in future versions).
This was mentioned in a changelog relatively recently.
https://github.com/JetBrains/ideavim/blob/master/CHANGES.md#features-5
I didn't mange this work. Looks like I need vim-plug installed and I use another package manager in my NeoVim and also I don't want to mix up two configs. It should work in general.

share eclim -friendly .vimrc

I am trying to to use eclim for my daily development requirements. My .vimrc has some issues preventing few functionalities like code completion etc.
It would be great if anyone using eclim regularly share your .vimrc.
You can find my vim setup on github. I use eclim to do Android development.
See visualstudioinvoke.vim for how I launch Vim from eclim. This isn't necessary, but it's useful to start at the current line in the current file. It also sets up my eclim menu, bindings, and settings.
It's best to start the eclim server (by opening the "Eclim" eclipse tab) before you start gvim.
I have eclim's code completion mapped to Ctrl-Space.
You won't get any code completion for classes that aren't in the scope of the current file. To import, I have a menu option under Eclim > ImportMissing.
However, my vimrc might be pretty alien to you, so you might be better served whittling down your vimrc until you figure out what's breaking things. The default map for completions is Ctrl-x Ctrl-u. You can use :verb map <C-x> to search for maps that start the same way and it will show you where they're defined.
If you use SuperTab, try disabling it. SuperTab and eclim are both maintained by
Eric Van Dewoestine so they should be compatible, but you may have a SuperTab configuration problem.
You could also try updating all of your plugins.

Autocompletion in Vim

I'm having trouble with autocompletion. How can I get a code suggestion while I'm typing?
I usually develop in PHP, Ruby, HTML, C and CSS.
Use Ctrl-N to get a list of word suggestions while in insert mode. Type :help i_CTRL-N to see Vim's documentation on this functionality.
Here is an example of importing the Python dictionary into Vim.
You can use a plugin like AutoComplPop to get automatic code completion as you type.
2015 Edit: I personally use YouCompleteMe now.
If you are using VIM version 8+, just type Ctrl + n or Ctrl + p.
You can start from built-in omnifunc setting.
Just put:
filetype plugin on
au FileType php setl ofu=phpcomplete#CompletePHP
au FileType ruby,eruby setl ofu=rubycomplete#Complete
au FileType html,xhtml setl ofu=htmlcomplete#CompleteTags
au FileType c setl ofu=ccomplete#CompleteCpp
au FileType css setl ofu=csscomplete#CompleteCSS
on the bottom of your .vimrc, then type <Ctrl-X><Ctrl-O> in insert mode.
I always rely on this CSS completion.
There is also https://github.com/Valloric/YouCompleteMe and it includes things like Jedi and also has fuzzy match. So far I found YCM to be the fastest among what I have tried.
Edit: There also exists some new ones like https://github.com/maralla/completor.vim
Another option is coc.nvim.
It's really fast and the completion is great as it uses intellisense the same autocompletion as VScode has.
It also has linting capabilities. So it shows you were you might have a bug.
It supports a multitude of languages.
It might take a bit to set up and configure but I think it is the best autocompletion engine for vim out there.
I've used neocomplcache for about half a year. It is a plugin that collects a cache of words in all your buffers and then provides them for you to auto-complete with.
There is an array of screenshots on the project page in the previous link. Neocomplcache also has a ton of configuration options, of which there are basic examples on the project page as well.
If you need more depth, you can look at the relevant section in my vimrc - just search for the word neocomplcache.
Here is link! for PHP.
press the Ctrl + x followed by Ctrl + o keys while writing some PHP functions.
Thanks to Oseems Solutions for the tutorial
If you only wanna auto-completion from cache of your current buffers, supertab is easier to install than neocomplete, can work on Mac pre-installed vim out of box without the need of MacVim.
You can check other alternatives at vim awesome.
For PHP, Padawan with Deoplete are great solutions for having a robust PHP autocompletion in Neovim. I tried a lot of things and Padawan work like a charm!
For Vim you can use Neocomplete instead of Deoplete.
I wrote an article how to make a Vim PHP IDE if somebody is interested. Of course Padawan is part of it.
I recently discovered a project called OniVim, which is an electron-based front-end for NeoVim that comes with very nice autocomplete for several languages out of the box, and since it's basically just a wrapper around NeoVim, you have the full power of vim at your disposal if the GUI doesn't meet your needs. It's still in early development, but it is rapidly improving and there is a really active community around it. I have been using vim for over 10 years and started giving Oni a test drive a few weeks ago, and while it does have some bugs here and there it hasn't gotten in my way. I would strongly recommend it to new vim users who are still getting their vim-fingers!
OniVim: https://www.onivim.io/

Resources