How can I create a local configs for Neovim extending the global init.vim? - neovim

Suppose that I have a map on my init.vim that I want to change the behaviour depending on the folder that I am. How could you do that?
A more concrete example: I have a map on my F12 that runs the project that I am. So if I am on a python project, this F12 will run an ipython on a floaternew window, with the current file already imported. Though, if I am on a cpp project, the same F12 will build using Make and running the binary on a floaternew window as well.
Nowadays, I have these two behaviours mapped on different key bindings. But It is going to very nice if I have only one binding to "run the project". Even if I need to open neovim with some parameter in each project, like neovim --local-config mylocalconfig.vim (extending init.vim with some behaviour)
I am kind inspired by a behaviour like direnv but with .vim files.
Any ideas?

There is an option in vim set exrc which enables reading vim config files from current directory, it also works in neovim.
From docs (:h exrc)
Enables the reading of .vimrc, .exrc and .gvimrc in the current
directory. If you switch this option on you should also consider
setting the 'secure' option (see |initialization|). Using a local
.exrc, .vimrc or .gvimrc is a potential security leak, use with care!
also see |.vimrc| and |gui-init|.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.

Related

Astyle formatting for vscode: extension doesn't have a config file

I am trying to get https://marketplace.visualstudio.com/items?itemName=chiehyu.vscode-astyle to work (if anyone has a different extension or settings I can use, I am all ears).
I cannot find a config file for it, even though the page implies that there are config parameters. I cannot find anywhere where I can, for example, specify the path of the astylerc file. Typing 'astyle' into the command tool bar says that there are no commands matching, even though I have installed the extension and restarted my computer.
Of course, I figured it out immediately after asking the question.
Settings (the gear in the bottom right) -> astyle configuration.

Why eclipse preference general->workspace->refresh using native hooks or polling not working?

I'm using vim in cygwin writing javascript code, using eclipse tomcat as web server. I checked the preference refresh using native hooks or polling. But after I write the buffer in vim, the project won't get refreshed, so the hosted application won't get republished neither. Only after I press F5 on the project manually, then everything works fine. Can someone help here? What am I doing wrong?
By default, Vim writes the file contents to a temporary file and then moves that over the original, see :help backup. Since this is now a different file (handle), the hooks set up by Eclipse may stop working.
You can make Vim override the original file by setting
:set backupcopy=yes

How to invoke F# auto-completion in Emacs

I installed FSharp 3.1, Emacs 24 and fsharp-mode of emacs. Howerver the auto-completion feature (complete-at-point) didn't work. I followed all the instructions here https://github.com/fsharp/fsharpbinding/blob/master/emacs/README.md and added fsautocomplete.exe to my $PATH .
But it still didn't work.
PS:
I failed in Debian sid, Ubuntu Trusty and Mac 10.9.
I am the author. In order to have autocomplete in fsharp-mode, you must either be editing a script (.fsx) file, or a normal (.fs) file that is associated with a project (.fsproj) file.
If a .fs file is opened and no other project has already been loaded, then fsharp-mode will look for and load a .fsproj in the current and enclosing directories. This can be done manually using C-c C-p. At this point autocompletion will be available in all .fs files mentioned in the project.
If a project has not been loaded, then no autocompletion will be available in .fs files.
I tried to make this clear in the README.md. I'll have a look updating it, and trying to give feedback in the interface as to why autocompletion is not available.
The author gave me the solution that the .fs file must be in the same directory with the .fsproject relating to it.

(g)Vim with version control like Eclipse

I was an Eclipse user, now I have to use Vim in my machine.
I used to "compare" a file I edited with a CVS repository to do merges an commit the files, using a context menu and my mouse.
Is this possible in Vim? Opening a vimdiff for a file before commiting, and commit it from vim itself?
And how is that supposed to work?
I'm supposing I would be editing a file. Then, I want to see the modifications. I run vimdiff in gvim, and a new window (or buffer) is opened. I run the modifications, save what is applicable (using vimdiff commands), and commit running another command.
Is this all transparent in vim? Do I have to keep getting out of vim to my terminal, or can all be done inside it?
Do I need to use some plugins, or just really simple functions inside my vimrc?
There is a couple plugins to integrate VCS to vim.
I personnally use vcscommand. It does at least the 2 things you're asking for: comparing from repository using vimdiff and commiting from within vim.
I personally just switch between vim and the terminal.
Usually I'd have several console tabs open at the same time (if you're on windows, Console can do that).
It depends on the VCS used, but you can linked that VCS with vimdiff (see git, for instance)
You could also try and integrate directly Vim into your Eclipse session with eclim.
(should you still be using eclipse. If not, I leave the following for others)
It does support the Eclipse local History.

Eclipse IDE; Open in current window / instance?

I've been using Eclipse for about a week now and I'm loving it.. great software for the 'price'. :P However, I'm having a few issues getting started.
The most annoying, so far, has been opening files from outside of Eclipse, and having them set to open w/ Eclipse. When I open a file from the file-explorer or an external application (WinSCP for instance), Eclipse seemingly attempts to open an entirely new instance itself rather than opening the file within a currently running instance. Of course, because this is the case, Eclipse errors out w/ 'The workspace is currently in use. Please select another' (or whatever it says).
Is there a configuration option, or an argument that I can use when opening a file externally that will simply use the currently open instance of Eclipse?
Thx in advance! :)
The easiest way to open external file in the current Eclipse is to drag-n-drop it to the tabbed area where your files are displayed. You should consider that Eclipse is seriously geared towards using files as part of a project and opening random file with Eclipse is certainly possible but not encouraged.
To your question - since Eclipse runs in Java if you attempt to use eclipse.exe to open a file then script will always try to open a new instance, I don't know if what you want is actually doable
To add to DroidIn.net's answer, here are a few eclipse bugs related to the question:
bug 4922 (from 2001!): "Need ability to open a file in eclipse from the command line", with sockent-monitoring kind of solutions, like the IBM proposition of opening an RCP from an URL, which leads to plugins like EclipseCalls.
EclipseCall is a plugin that accepts file-open requests on a defined socket port. A specialized client can be used to open a file in Eclipse by command from outside Eclipse, e.g. by double clicking a source file in Windows Explorer.
bug 178927 (2007): "way to pass arguments from launcher to a running application instance", based on a modifier launcher (more Windows-oriented, although bug 201154 is mac-oriented). An OSGi-based solution is also investigated.
(On Linux, see also steb)
In a Mac terminal, you can use open, though I needed to point to the executable explicitly, since I have more than one Eclipse installed:
open -a ~/eclipse/java-oxygen/Eclipse.app --args --launcher.openFile filename
You may or may not need --launcher.openFile, depending if you have --launcher.defaultAction set to openFile in your eclipse.ini file. (This config-file edit is also what you need for double-clicking or "open-with" to use the running Eclipse.)
For instance, I could do this (with gnu parallel) to open all of my failing tests after I'd copied to the clipboard (pbpaste is mac-specific):
pbpaste | parallel find . -name {}\\\* -print \
| parallel open -a ~/eclipse/java-oxygen/Eclipse.app
The Eclipse file-opening documentation for all OSes is here.