Print lint rule out with ALE in Vim - 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'.

Related

Vim cannot be commented correctly with multiple quotation marks

I found a bug in the vim language syntax of <vim.vim> file. If there are multiple quotation marks in a comment, it will not be treated as normal comment. For example:
the line 1 and line 3 will not be commented as I expected.
How can I fix the bug ? I try to understand the syntax setting in the of vimComment setting and do some modification, but failed.
Add more details about my question:
I wrote a vim script as below:
let a = b " b range:0~255
Note: there are some spaces at the beginning of the statement.
I want to comment this statement, so add quotation at the beginning of the statement.
" let a = b " b range:0~255
I find the statement will NOT be recognized as vimComment as I expected, it will be treated as vimString (when cursor under let) and vimIsCommand (when cursor under range).
Here, I used the following method to check syntax name and definition under cursor.
nnoremap <f8> :echo synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>
I think this is a bug in the vim.vim file which version is '8.0-28'.
For received feedbacks that there were no the same issue found in the others' VIM enviroment, I had to check my settings and did some trials. In the end I found this issue was caused by the Plugin 'thaerkh/vim-indentguides'. If I did not use this plugin, the comment state was correct as I expected. I guess the plugin has some errors in using of VIM conceal feature. So I changed to use the Plugin 'Yggdroot/indentLine' instead and solved the issue. Thank #all.

Color highlight function calls in VIM

Does anyone know a way to color highlight function calls in Vim?
I know that some plugins could do something like that by keeping record of tags, but with what I've found online, I could not figure out how to make it work.
I've tried using easy tags (which, by the way, doesn't seem to be maintained anymore) and gutentags, but to be quite honest, I haven't come much close to make any of them to work.
On the other hand, I imagine that it would be quite simple to implement a script to highlight anything that lies between a dot and a left parentheses or a blank space and a left parentheses (as in .anyCodeAtAll(), anotherCode()), but I have no idea how to do it. It would be a incomplete solution of course, but it would be good enough for my purposes at the moment.
Does anyone know how to make that work?
I have something like that in my configuration, but it's quite language specific. For example for Golang, I have a ~/.vim/after/go.vim which contains:
syntax match goCustomParen "(" contains=cParen
syntax match goCustomFuncDef "func\s\+\w\+\s*(" contains=goDeclaration,goCustomParen
" Exclude import as function name, for multi-line imports
syntax match goCustomFunc "import\s\+(\|\(\w\+\s*\)(" contains=goCustomParen,goImport
syntax match goCustomScope "\."
syntax match goCustomAttribute "\.\w\+" contains=goCustomScope
syntax match goCustomMethod "\.\w\+\s*(" contains=goCustomScope,goCustomParen
highlight def link goCustomMethod Function
highlight def link goCustomAttribute Identifier
highlight goCustomFuncDef ctermfg=13
highlight goCustomFunc ctermfg=43
highlight goCustomAttribute ctermfg=247
highlight goCustomMethod ctermfg=33
And for Python, I have a ~/.vim/after/python.vim:
syntax match pyCustomParen "(" contains=cParen
syntax match pyCustomFunc "\w\+\s*(" contains=pyCustomParen
syntax match pyCustomScope "\."
syntax match pyCustomAttribute "\.\w\+" contains=pyCustomScope
syntax match pyCustomMethod "\.\w\+\s*(" contains=pyCustomScope,pyCustomParen
highlight def link pyCustomFunc Function
highlight def link pyCustomMethod Function
highlight def link pyCustomAttribute Identifier
highlight pyCustomFunc ctermfg=43
highlight pyCustomAttribute ctermfg=247
highlight pyCustomMethod ctermfg=33
In each case, the first block defines what is a function, a method, an attribute, and so on, the second block link these custom definition to the generic classes "Function, Identifier..." and the 3rd block defines the colors.
The files need to be in the after directory to be executed after the colorscheme and highlights definitions.
Here's a side by side comparison of with and without these settings (look on the last 3 lines):
Unless someone has a better solution, you could adapt the above for the language you need it.
It might be that you have not installed your plug-in correctly.
Try following these steps (or retrace your steps) and see if it works / missed any steps out:
cd ~ Go to home directory.
vim .vimrc open .vimrc
Insert:
call plug#begin()
Plug 'xolox/vim-easytags'
call plug#end()
easytags#Options states easytags should work out of the box, but you could add option here in the
.vimrc file now or later,
e.g. put:
let g:easytags_syntax_keyword = 'always'
afer the call plug block.
Anyway.
:wq write quit the .vimrc
source ~/.vimrc unsure if required as will do later
vim test.js open vim with test.whatever language you know.
:PlugInstall in vim
Here might take a bit of time.
Then :q out of that window.
:source ~/.vimrc this is needed
Then test out to see if you have syntax highlighting.
I'm pretty sure this is along the right lines. Might be misspelled plugin name.

How could I let vim ale plugin use pylint configuration file

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.

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! :-(

How can I get vim's closetag plugin to work for all html tags?

I am using the closetag.vim plugin, but it doesn't seem to work for all tags. In the plugin code there is the ignored tags var that contains some one that I noticed were not closing ex dd dl, but there are many others that aren't in the list that are not working (p, ul, li).
Nothing seemed to happen after updating the list of ignored tags.
To get this plugin to work you just enter the tag text and click tab, right? ie div
Am I missing something?
How did you install the plugin?
I had troubles with closetag.vim when I installed it in ~/.vim/plugins. Then I moved it into ~/.vim/scripts instead, and added the following to my .vimrc:
:let g:closetag_html_style=1
:source ~/.vim/scripts/closetag.vim
and now it works fine for me. I find that it closes all tags (including those included in the 'ignore' list), but not those that are self-closing (e.g. <img/>).
In the version of the script that I am using (0.9.1), it defines <C-_> as the trigger for completing tags. If you have mapped the command to <tab>, then that should work too.
I also cannot get this plugin to work, however in my case what it does it throw out a number of error messages before finally working. For instance if I try to close an H1 tag I will get the error Error Detected while processing function GetCloseTag and the error is an undefined variable b:UnaryTagsStack.
Seems like it would be a useful plugin but it just won't cooperate.
I had the same issue and nelstrom's answer above didn't solve it for me. What worked for me was adding the following lines to my .vimrc:
if !exists("b:unaryTagsStack") || exists("b:closetag_html_style")
if &filetype == "html" || exists("b:closetag_html_style")
let b:unaryTagsStacktack="area base br dd dt hr img input link meta param"
else " for xml and xsl
let b:unaryTagsStack=""
endif
endif
if !exists("b:unaryTagsStack")
let b:unaryTagsStack=""
endif
I don't know why adding just let b:unaryTagsStack="" didn't do the trick, but the combination above seems to fix it in all file types for me.

Resources