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.
Related
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.
I use a problem set class to type up my problem sets. I often have a main.tex file that looks something like the following.
\documentclass{problemset}
\begin{document}
\input{problem1}
\end{document}
I typically have a different file for each problem. For example, problem1.tex might be as follows.
\begin{problem}
there is a spelling errrrrrrror here
\end{problem}
I would like vim to detect the spelling error in problem1.tex, but unfortunately it does not. As noted in this post, the problem seems to be that vim is not able to identify any syntax region: when I run the command
:echo synIDattr(synID(line("."),col("."),1),"name")
I don't get any output. As another example, if I change problem1.tex to the following, then the spelling error is identified.
\section{dummy section}
\begin{problem}
there is a spelling errrrrror here
\end{problem}
I have tried to create a syntax region for my problem environment, but was unsuccessful. My attempt consisted of creating the following .vim/syntax/tex.vim file.
syntax region texProblem start="\\begin{problem}" end="\\end{problem}" contains=#Spell
Nothing seems to happen when I create this tex.vim file. I used scriptnames to check that that the syntax file is being loaded (the default syntax file is also loaded after mine). I can also get the spelling error to be flagged by setting the filetype to plaintex, as suggested here, but this seems like a terrible hack. It seems like there should be a better way to get spell checking in my problem1.tex file.
The comments above worked for me (syntax spell toplevel) and this setting works for me even when run later (so no need to copy anything from /usr). But I didn't want that setting to be active for all tex files - instead, I customize it for the given file in my .vimrc:
au BufNewFile,BufRead body.tex syntax spell toplevel
I used a hack for this problem. Add the following to the top of your file:
\iffalse{}\section{vim-hack}\fi{}
This way, vim's syntax and spell algorithms find some token to get them started, but due to the "if" the section will be ignored by latex itself.
(I did not test whether more specialized editors ignore this dummy section, so there may be more hackery required if you use both vim and an editor.)
I just configured my Vim to used Syntastic - which works great !
I use it for javascript validation.
I have two linters installed: jslint and jshint, and I intend to keep the two. But Syntastic does not seem to want to report errors from the two at the same time: I get first errors from jshint, and then only jslint when I fixed the previous ones.
Any way I could have the two at the same time?
You need to set g:syntastic_aggregate_errors option to 1 (it's default value is 0):
let g:syntastic_aggregate_errors = 1
This is from documentation:
When enabled, syntastic runs all checkers that apply to the current filetype,
then aggregates errors found by all checkers and displays them. When disabled,
syntastic runs each checker in turn, and stops to display the results the first
time a checker finds any errors.
Ruby:
file = File.new("some.txt", "r")
lines = file.readlines
Omni-completion tests
file.readl
---------
readline <- PASSED
readlines
---------
"hola".capital
---------
capitalize <- PASSED
capitalize!
---------
lines.
<-- FAILED (no suggestions)
lines[0].capital
<-- FAILED (no suggestions)
I tried Python as well, and it worked in similar way. So it looks like omni-completion can't be used for real development, as it fails on pretty simple cases?
Am I missing some thing? May be the intellisense can be improved some how for Ruby/Python?
The issue is that Vim does not know if line is a String, an Array or some other Class. There is no deep syntactical analysis in Vim. Vim has no idea of scope, if a variable or method has been defined, etc.
It is only suggesting similar words. So yes, Vim is more limited than an IDE in this aspect. This is also why Eclipse can suggest errors as you typed them, and Vim can't.
Vim is much more basic: in a way, everything is text, and not necessarily seen as "code".
So you are right this is one of Vim limitation.
There are some plugins to work around those limitations (omnicpp is using ctags to determine the scope of some methods) but they are often developed on a per-language basis and there is no silver bullet.
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.