How could I let vim ale plugin use pylint configuration file - vim

in my vimrc file, I add this line:
let g:ale_python_pylint_options = '--rcfile ~/.pylintrc'
And in my ~/.pylintrc file, I have this line:
msg-template={msg_id}: {msg}
However, with my vim ale plugin, the error message showed does not include the mssage id.
The message is like this:
[Pylint] Unused variable 'j' [W]
But I hope I could get this:
[Pylint] [W0612] Unused variable 'j' [W]
How could I make it work?

You could do that using the g:ale_echo_msg_format option. For example, setting this option in the vimrc as shown below, would give you the desired result:
let g:ale_echo_msg_format='[%linter%] [%severity%] %code% %s'
Where code is the error code. However, this code outputted is a human-readable code instead of the actual code. For the above an example output is as follows:
[pylint] [Warning] missing-docstring Missing module docstring
Note missing-docstring instead of the code F0001. On reading through the issues, the author of ale is deliberately doing this, So, if you need the actual error code, you're out of luck. Open an issue in the project and hope the author changes this behavior.

Related

Print lint rule out with ALE in Vim

At the moment I have the following in my vimrc to show the linter error message at the bottom of my screen:
let g:ale_echo_msg_format = '%linter% says: %s'
How do I customise this so that I get the name of the lint rule (rather than just the description).
What you're looking for is %code%. See :help g:ale_echo_msg_format. You can put just about any characters you want before or after code, and that part of the message will be removed if there's no error code. The default value for the option is '%code: %%s'.

Vimtex variables are said to be undefined (so I can't change them)

I'm using the vimtex plugin with vim-plug plugin manager to edit LaTex files. I'm trying to disable the Callback feature in my vimrc (so I stop getting warnings about it whenever I open a .tex file), so I let g:vimtex_compiler_latexmk.callback = 0, but I get an error saying g:vimtex_compiler_latexmk is an undefined variable.
Attempting :echo g:vimtex_compiler_latexmk gives the same error message.
The only variable I can seem to change or even view is g:vimtex_enabled, so if I want to let g:vimtex_enabled = 0, I can do that and disable vimtex altogether.
Any ideas why and what I can do to fix this? Vimtex otherwise works flawlessly despite this.
I'm running VIM 7.4 on Linux Mint 18.
Vim doesn't let you initialize a dictionary variable like that. There's no default value for g:vimtex_compiler_latexmk, so you first have to initialize it as a dictionary:
let g:vimtex_compiler_latexmk = {}
let g:vimtex_compiler_latexmk.callback = 0
Or just initialize and assign at once:
let g:vimtex_compiler_latexmk = {'callback': 0}
Either way, once it's initialized, you can use the . accessor shortcut.
The reason you're only seeing g:vimtex_enabled is because vimtex autoloads when you access a .tex file. Load one up, and you'll see a lot more variables. You still won't see g:vimtex_compiler_latexmk, though, because it has no value unless you set one.
I suspect you are assigning g:vimtex_enabled in your vimrc, and that's why you see that one even without loading a LaTeX file.

What is causing this SnipMate message?

I have just started using the Vim plugin SnipMate. When I create an HTML file (with filetype .html), go into insert mode, and type "html" and a tab, I see this message at the bottom of my screen:
1* 1. Users/me/.vim/bundle/vim-snippets javascript-jquery default
2: 2. Users/me/.vim/bundle/vim-snippets html default
__InputList__
select snippet by name (filter: ; press <F1> for help) [glob]
I'm not sure why this is happening. How can I configure SnipMate so that it knows that when I type "html" I always want the second option?
Thanks.
This message was caused by an "html" snippet in the file vim-snippets/snippets/javascript/javascript-jquery.snippets. Once I commented that snippet out, the message stopped occurring.
Yep.
I had a similar error on the bottom of my vim screen:
1 1* 1. html bundle/vim-snippets html.snippets
2 2: 2. javascript bundle/vim-snippets javascript-jquery.snippets
There is already a snippet called html in the
~/.vim/bundle/vim-snippets/snippets/javascript-jquery.snippets file.
You should comment out these two lines with the # sign, like this:
'# snippet html
̈́'# ${1:obj}.html('${2:Some text and bold!}')
Someone should fix this problem.
Installing Vim plugins should be easy, not complicated! :-(

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: spell checking in partial LaTeX files

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.)

Resources