Incompatibility with EnhancedJumps and vimfiler? - vim

Here's the plugin I'm talking about: https://github.com/vim-scripts/EnhancedJumps
The plugin sometimes croaks when navigating backwards:
Error detected while processing function EnhancedJumps#Jump:
line 52:
E121: Undefined variable: mappings
next: vimfiler:default
Could it be caused by my vimfiler plugin?

Your hunch is right. Because the :redir command cannot be nested, there can be conflicts in EnhancedJumps (which I'm the author of) if another plugin has redirection active, too. To work around that, I've added a configuration in version 3.02 to turn that off. Put the following into your ~/.vimrc:
let g:EnhancedJumps_CaptureJumpMessages = 0
You'll lose a tiny bit of functionality (messages reported during jumping may be out of order), but can continue to use both plugins without script errors.

Related

Strange behaviour on full stop (.) whilst in insert mode vim

I am using vim with Pymode to write python source code. I have the come across some strange behaviour which is intermittent but very annoying.
If I am in insert mode and type a full stop (e.g. self.method()), whilst typing self vim prints at the bottom
-- Keyword completion (^N^P) The only match
As soon as I type the full stop vim seems to freeze momentarily, then
-- INSERT -- appears at the bottom, but my cursor is now on the full stop, so that when I write method() it actually appears behind the full stop. I keep having to go back and move the full stop.
I can't figure out when it happens and when it doesn't, when I open a new file it doesn't happen straight away.
Any ideas on what may be causing this? I have only noticed it recently.
This is a problem caused by some combination of pymode and rope. Either way putting
let g:pymode_rope_lookup_project = 0
in your vimrc solves it apparently. See here for the pymode issue.

Syntastic avoid irrelevant errors

I've recently installed the syntastic plugin in my vim installation. However I'm getting annoyed by irrelevant errors reported by syntastic.
I installed in order to make it work code sniffer and phpmd.
How can I tell syntastic to stop giving me such irrelevant errors like:
Missing file doc comment
or
Line indented incorrectly; expected at least 8 spaces, found 4
I'd like to get only real errors like missing a semicolon;
As per the discussion in the comments, you can define which syntax checkers to use with the g:syntastic_<filetype>_checkers = [] variable.
In this case, you might want something like this to disable code sniffer (phpcs):
let g:syntastic_php_checkers = ["php", "phpmd"]
For more information see :h syntastic-filetype-checkers.

vim syntax performance with very long lines

I'm using vim to edit markdown files that contain some very long lines (100000
characters). Vim is very slow with this kind of input. If I turn off syntax
highlighting (:syntax off), Vim is not slow anymore.
The reason for the length is that some of the code blocks contain json that
contain images encoded in base64. (Actually, I'm trying to edit a markdown
version of an ipython notebook).
Here is what the offending text looks like:
```{.json .output n=41}
[
{
"metadata": {},
"output_type": "display_data",
"png": "iVBORw0KGgoAAAANSUhEUgAAAtAAAAFxCAYAAAB....long...long....line...."
}
]
```
What I'd like is for Vim to not be slow.
Possible solutions that I've thought of:
set synmaxcol=250 - no, breaks syntax highlighting after a long line
Disable syntax highlighting selectively for long lines (not sure how to do
this)
Disable syntax highlighting for code blocks that begin with {.json (don't
know how)
I'm using the vim-pandoc
syntax highlighter. This gives code blocks the syntax group
pandocDelimitedCodeBlock or e.g. pandocDelimitedCodeBlock_json if you turn
on language detection.
This also means that I'm folding on syntax groups (foldmethod=syntax) which
is a possible source of slowness (see stackoverflow, github and superuser).
However, :set foldmethod=manual does not solve the problem.
vim-pandoc makes extensive use of syntax folding and I'm pretty sure that is the issue. Disabling vim-pandoc-syntax and turning off folding (let g:pandoc#modules#disables = ['folding']) makes vim fast again.
For syntax highlightin I've used my fork of tpope's vim-markdown. I've forked it because the original does not syntax highlight code blocks with pandoc style attributes (pull request here).
For folding on headers and fenced code blocks using a foldexpr I've used my fork of vim-markdown-folding. Forked because the original does not fold on code blocks (pull request here).
Whilst this doesn't really answer my question (which I agree isn't well defined), it does fix my problem.

Indenting Fortran code in Vim

I have a fortran code which looks like this:
open(2,file=filenm(i),status='unknown')
do j=1,num_lines
do k=1,dime
read(2,*) z(k)
enddo
if( j .ge. 1000 ) then
do k=1,dime
sumz(k)=sumz(k)+z(k)
enddo
nsteps=nsteps+1.0
endif
enddo
close(2)
as you can see the indentation is not even, I would like to have something
like this:
open(2,file=filenm(i),status='unknown')
do j=1,num_lines
do k=1,dime
read(2,*) z(k)
enddo
if( j .ge. 1000 ) then
do k=1,dime
sumz(k)=sumz(k)+z(k)
enddo
nsteps=nsteps+1.0
endif
enddo
close(2)
I can go line by line fixing the indentation but the code is kind of big.
I appreciate any comment.
I've gone through a very similar process of trying to get Fortran indenting to work in vim. I still don't have it great, but I've made some progress. The script that arutaku posted (http://www.vim.org/scripts/script.php?script_id=2299) is where I started, but you need to make sure that filetype plugin indent on is in your vimrc.
I also needed a script for determining if I was using fixed-form or free-form syntax, since in my environment I use both. This is recommended in the documentation (http://vimdoc.sourceforge.net/htmldoc/syntax.html#ft-fortran-syntax). As it specifies, I put this script in ~/.vim/ftplugin/fortran.vim:
let s:extfname = expand("%:e")
if s:extfname ==? "f90"
let fortran_free_source=1
unlet! fortran_fixed_source
else
let fortran_fixed_source=1
unlet! fortran_free_source
endif
I also use a script so that I can press F7 to automatically complete certain constructs: http://www.vim.org/scripts/script.php?script_id=2487. I also put that in ~/.vim/ftplugin/.
I also have these in my vimrc to try to improve things further:
let fortran_do_enddo=1
let fortran_more_precise=1
let fortran_have_tabs=1
I believe those are supposed to interact with the first script to control its behavior, but I'm not convinced that they all work for me. I know the first is supposed to properly indent do/enddo blocks. The issue there is that since old-style Fortran allows a do without a matching enddo, the script can't indent them properly unless you can guarantee that you won't use unmatched 'do' statements. The let fortran_do_enddo=1 is supposed to be that guarantee, but it doesn't seem to work for me. The last one is supposed to allow usage of the tab character, which old Fortran considered bad, so it prevents them from being marked as errors. That one appears to work for me. And to be honest, I don't remember what the middle one is supposed to do nor if it works for me.
Edit:
I discovered that there was an older version of the the first script in my vim installation directory (/usr/share/vim/vim70/indent/ in my case) to which I do not have access rights. You might have those rights, and if it's causing you problems, overwrite or delete it. If, like me, you can't edit it, you can get the version in your $HOME to overwrite the functions from the first. I did this by doing two things. First I had to remove the checks to see if the functions already exist (the statements like if exists("*FortranGetFixedIndent")) and then I had to change all the function declarations to force overwriting by using the ! character, i.e. function! SebuFortranGetFreeIndent(). As far as I can tell, everything now works roughly as I would expect!
Does gg=G work?
gg: go to top
=: indent...
G: ... until the end
Try: https://sourceforge.net/projects/findent/files/
From the README:
findent: indents/beautifies/converts Fortran sources
findent supports Fortran-2008
findent can convert from fixed form to free form
binaries for Unix and Windows (findent and findent.exe respectively)
wrapper for processing one or more files in one call available for Unix and Windows (wfindent and wfindent.bat respectively)
(g)vim users: findent can act as a plug-in to format your edit file with the '=' command
gui frontent available in a separate package: jfindent
You can use auto-indentation writing <x>== (in command mode) where x is the number of lines to be indented.
If vim does not have fortran indentation you can load the following plugin and try the == combination: http://www.vim.org/scripts/script.php?script_id=2299

Preventing :make in VIM from going to a warning

I have a warning I can not easily remove from my build, every time i run ":make" from inside vim the quickfix takes me to some header file I don't care about. How can I prevent VIM from doing this and only showing me warnings and errors I do care about?
As Luc Hermite said, it is possible to ignore warnings using 'errorformat'option.
Adjusting this option is a little bit complicated; it may be helpful to check $VIMRUNTIME/compiler for some examples.
When working with avr-gcc and C++ some annoying warnings like this
tests.cpp:492: warning: only initialized variables can be placed into program memory area
shows up, and it is likely to be result of a compiler fault.
To avoid that this warnings being displayed on quickfix window I've add this to ~/.vimrc:
compiler gcc
set errorformat^=%-G%f:%l:\ %tarning:\ only\ initialized\ varia
\bles\ can\ be\ placed\ into\ program\ memory\ area
The %-G can be used to specify patterns to be ignored.
The ^= in set errorformat^=... is used to prepend the ignored warning pattern to 'errorformat' -- using += (set errorformat+=...) would append to the option and wouldn't work, as 'errorformat' is a list of formats and the first one that matches is used, thus the "normal" warning pattern would apply instead.
Maybe you could adapt these settings for your environment.
Check :h 'errorformat' (aka &efm), there are options to ignore warnings as long as you can recognize them with a pattern.
A quick and dirty way would be to write a simple shell script that runs your make and greps out the warnings you don't want to see. Then have vim use this script instead of make (Add "set makeprg=yourscript.sh" to your .vimrc).
To build on what mMontu suggested, adding this to my .vimrc did the trick for me (ignore all warnings from my gcc compiler)
set errorformat^=%-G%f:%l:\ warning:%m
Learn from Bram himself.
I can vaguely remember he talks about this somewhere in this video.
He adds a filter to ignore some gnome warnings when he's compiling gvim.
The video's well worth watching anyway.
It's around the 30 minute mark.

Resources