Vim disable make on insert mode exit - vim

I'm using yats (https://github.com/HerringtonDarkholme/yats.vim) for typescript, it sets the makeprg variable, which makes it so vim runs make everytime I make a change to a file. I would like to somehow disable this, as I prefer a linter manager (ALE), which can compile and also lint.
Is there something I can do about that localy or does yats need an option to disable the setting of makeprg?
EDIT:
The accepted answer doesn't provide actual solution to my specific problem, but the explanation of makeprg guided me in the right direction, which was other plugins. I traced the problem back to YouCompleteMe.

it sets the makeprg variable, which makes it so vim runs make everytime I make a change to a file.
No, makeprg only defines what external command to run when you or a plugin does :make.
Furthermore, I couldn't find anything in that plugin that would run :make on write or on any other event. The command below will hopefully help you find where that automatic make comes from:
:verbose autocmd BufWritePost
See :help :verbose, :help :autocmd, :help BufWritePost.

Related

vim snippet default snippet file issue

I installed Vundle, got the snippetMate running. But when vim launched, the snippet it loaded is _.snippets. With my Understanding, it is the default for snippet. However, i want to use other snippet such as sh.snippets and tex.snippets. I try to run the SnippetMateOpenFile in Vim to locate the snippets file It doesn't appear. I checked and see that all of the snippet file is there.
Yes, the _.snippets contains the global snippets. In order to use the other ones, the correct filetype has to be set. The snippet plugin reuses the same mechanism that Vim uses for syntax highlighting and settings (like indent) that are specific to a certain programming language. Usually, filetype detection works automatically; you can check with
:verbose setlocal filetype?
This needs to print sh for shell scripts, to use sh.snippets. If it doesn't, you have to fix / enable filetype detection (see :help filetype-detect), or, for a one-time fix, set it manually:
:setf sh
(I'm not sure about your particular snippet plugin; I guess it's snipMate, but there are multiple variants around.)
I found out what happened. the snippets won't recognize the snippet files rightaway. So i saved and exit the text and reopen vim again. It works, yet seems like there must be a certain tag in order for vim to recognize the format of the file.

Can you view the default Vim settings?

I’m starting to learn about creating my own .vimrc file and I keep noticing features that are missing with my custom version that were present in the default setup.
I was wondering if it is possible to view the default settings, so I can compare them to my own and look up all the standard inclusions I don't know to learn more about them.
I searched and couldn’t find an answer online, and if the reason why there isn’t one is that the answer to this question is glaringly obvious, I’m really sorry; I’m still a bit of a noob :p
No worries, it’s a perfectly valid question. Unfortunately, the answer is a bit complicated. First of all, Vim has certain defaults that are documented in the built-in help system.
Some of them are only used when Vi compatibility mode is disabled, and that’s the first customisation most people make:
:set nocompatible
On top of that, many distributions provide their own custom config, for example Debian/Ubuntu comes with /etc/vim/vimrc. To makes things even more confusing, Vim 8 comes with a sane configuration (called default.vim) that only gets applied when ~/.vimrc is not found. Not to mention that NeoVim comes with its own set of defaults.
In practice, I suggest to explicitly set any options you care about to make sure your config is portable between systems and versions of Vim. To see the current value of a given option, use a question mark:
:set showcmd?
To learn more about a given option (including the default value), use Vim’s comprehensive help system:
:help showcmd
Finally, you might want to check my annotated .vimrc for some inspiration, and there is also the vim-sensible plugin that provides some sane defaults most people would agree to.
The easiest way to see “vanilla” Vim options is to start it using:
$ vim -u NONE -N
It will start Vim without any of your customizations or plugins, but still in ‘nocompatible’ mode (i.e., basically, running full-fledged Vim, instead of its stripped down version emulating Vi).
Then, you can execute the following commands:
:set all
:map
:command
:let
:function
:autocmd
to see all options, mappings, commands, variables, functions, and auto-commands, respectively, that are currently in effect. (I cannot promise I haven’t forgotten a customization category.)
Vim also comes with a bunch of basic configurations that is skipped by the -u NONE option, that you can also include while still excluding your .vimrc, by using -u NORC, instead.
Based on #Amadan's answer, I came up with this file (ShowAllDefaults.vim) and command to run it and capture the output.
. In the mean time, learning that, if you have files under ~/.vim, they get executed if you use this:
vim -u ShowAllDefaults.vim -N +q
So the correct way to do it is:
vim -u NONE -N +"source ShowAllDefaults.vim" +q
Contents of ShowAllDefaults.vim:
set verbosefile=/tmp/ShowAllDefaults.log
set all
map
command
let
function
autocmd
I am trying after long time to get familiar with vim also, and I came across this because I had same question.
How I found answer from within vim was to pull up help on defaults and it explained to get defaults along with .vimrc for newer users and also gave the path to default script so you could open it right up in your editor and read & compare it.
I am not going to give my exact path because that might change in different versions, so best to get it from help documents inside vim.

How can I reload a VIM plugin after VIM was started?

I am modifying an installed VIM plugin and in another Terminal tab I am testing the results.
Each time I want to test the changes I have to restart VIM.
Is there any faster way to do this process? How can I reload a VIM plugin after VIM was started?
The plugin is installed via Vundle
I have tried to run :so % that is supposed to reload the .vimrc file but I still cannot see my changes.
If there weren't an inclusion guard (if ! exists('g:loaded_pluginname') ...), you could simply :runtime! plugin/pluginname.vim (or :source % if it's currently opened) and all plugin definitions would be re-read.
But as most plugins (correctly) use such a guard, you need to :unlet that variable first:
:unlet g:loaded_pluginname | runtime! plugin/pluginname.vim
My ReloadScript plugin can do this with one command if the guard name adheres to the canonical naming, and the scriptease plugin has such a command, too.
Edit: Some plugins use differently named guard variables, or other ways that prevent reloading. The plugins from mattn (like emmet.vim) are quite elaborate; maybe there's some special mechanism; I don't use that plugin. You could ask the author for advice, though.

Warning keep popping when running conque in VIM

When running conque in VIM, the warning message prompts out every time:
Warning:
Global CursorHoldI and CursorMovedI autocommands may cause ConqueTerm to run slowly
I found a method to remove the warning is to comment out the warning-function in the conque_term.vim, but I don't think it's a decent and safe way to solve the problem.
I'm new with VIM, so I found no way to identify the source of problem by myself. Could anyone help? Thanks a lot!
One integration point into Vim is through events, which can trigger automatic commands; the Conque plugin itself uses these to implement its functionality. Events like CursorMovedI are fired whenever you type something or move the cursor in insert mode; this can have an impact on performance, and that's what the warning is about.
You can list all such automatic commands via:
:verbose autocmd CursorHoldI,CursorMovedI
As long as Conque works well for you, it's fine to ignore (and suppress) the warning. But if you indeed run into problems, you'd need to check the other autocmd sources and maybe disable one or the other plugin (at least for the Conque buffer). (See :help autocmd-remove for how to do this.)
Off topic, but using Ctrl+Z to drop back to shell and fg to return to vim seems to work way better than Conque. That is if you're using vim from the terminal, which you should.
Some inspiration: http://statico.github.com/vim.html

vim run make through screen

Due to some complicated environmental variables required, I have chosen to run Make through GNU screen. Using the screen vim plugin, I have the following setup in my .vimrc:
map <Leader>mm :call ScreenShellSend("cd ".expand("%:p:h")." && make 2>&1 | tee /path/to/errorfile") <CR>
Roughly translated, this will run make in the current working directory through an existing screen session with all of the required environment variables preset. I can then see the output of that command in a separate terminal window.
My question is, assuming I output the results of make to a text file, how do I tell automate the vim make process to:
A.) set make to use a vimscript function, i.e. call SreenShellSend() instead of an external program.
B.) set errorfile to /path/to/errorfile
Unfortunately, you cannot set 'makeprg' to a Vim function or command, it has to be a shell program. (I wish for an enhancement that treats commands starting with a colon as Vim commands, similar to the :help exception in 'keywordprg', but haven't come around to implementing this.)
There are workarounds, though. One is to use vim --remote-send as 'makeprg' and use this other temporary Vim instance to call back into the original Vim. What I do though is overriding the :make command through the cmdalias.vim plugin for those buffers. That alias then simply :calls my function.
Once you're able to invoke a Vim function, setting the 'errorfile' is just a matter of putting a function wrapper around ScreenShellSend() and setting it in there.

Resources