Vim plugin youcompleteme error message
Asked Answered
H

2

23

Every time I write a new python source code *.py, the following error message comes up:

Error detected while processing BufRead Auto commands for"*.py":
E518:Unknow option:set
E28:No such highlight group name: BadWhitespace

How can I fix it?

Before I typed this question , I modified my _vimrc file according to this post, but the error message remains. Even worse another error message occurs as well:

The ycmd server SHUT DOWN(restart with':YcmRestartSever').YCM core library not detected;you need to compile YCM before using it. Follow the instructions in the documentation.

I am a new Gvim user and I use gVim 8.0 in Windows 10. I set up my python development environment by searching the Internet and I installed the YouCompleteMe plugin via Vundle but It is too difficult for me to compile YCM myself now.

Hanser answered 12/10, 2016 at 15:40 Comment(7)
The other errors that don't mention YCM seem unrelated to this problem. There might be other problems with your _vimrc file.Juanjuana
Maybe the Error 28 "BadWhitespace" because of " Plugin 'vim-scripts/indentpython.vim' au BufRead,BufNewFile .py,.pyw,.c,.h match BadWhitespace /\s\+$/",I copy these from a article.@JuanjuanaHanser
I comment down the au BufRead sentence ,the Error,Error518,E28 disapear.But how can I modify the au command to right?Thank you .Hanser
The match command applies a "highlight group" (which is a set of background and/or foreground colours), in your case BadWhitespace to strings matching the supplied pattern. Your problem is that you don't have this this highlight group defined (you probably didn't paste the whole snippet from the article). To fix it, you have to define the highlight group with something like highlight BadWhitespace ctermbg=red guibg=red in your _vimrc. This will instruct vim that BadWhitespace means it should colour the background red. The colour can be either a noun or a hex code like, #6f4822.Juanjuana
@Juanjuana I copied the commands from this website.realpython.com/blog/python/…Hanser
I copy and paste the commands to _vimrc one by one,but those three error messages still occour.Hanser
That's weird. In the comments someone had the same problem as you and fixed it using the same solution I gave you. Perhaps you should post another question since this is a separate issue and paste your _vimrc (or rather a minimal, complete, verifiable snippet that reproduces the problem).Juanjuana
J
6

YCM depends on ycmd to do actual work. ycmd is a compiled service running in the background so you have to compile it to make it work.

The basic installation procedure consists of opening a shell / command line for your OS, cd-ing to YouCompleteMe's vim plugin directory and running ./install.py there to compile it. If you need it for languages other than Python, run ./install.py --help and look up any additional flags you need to add to turn on support for the languages you want to use.

The above assumes you have read YCM's installation guide and have installed the required dependencies. There are two guides relevant to your case and they are rather detailed and clearly written:

Juanjuana answered 12/10, 2016 at 15:48 Comment(5)
Please install CMake and retry. Traceback (most recent call last): File "C:\Users\admin\.vim\bundle\YouCompleteMe\install.py", line 44, in <module> Main() File "C:\Users\admin\.vim\bundle\YouCompleteMe\install.py", line 33, in Main subprocess.check_call( [ python_binary, build_file ] + sys.argv[1:] ) File "C:\Python27\lib\subprocess.py", line 541, in check_call raise CalledProcessError(retcode, cmd)subprocess.CalledProcessError: Command'['C:\\Python27\\python.exe', u'C:\\Users\\admin\\.vim\\bundle\\YouCompleteMe\\third_party\\ycmd\\build.py']' returned non-zero exit status 1Hanser
I try to run the install.py then return these message.Here I have a question :Do I have to "compile " it once I use the YCM plugin?If so,it is very inconveniency.Hanser
See my updated answer. Yes, to use YCM you have to compile the ycmd binary once (and again later in certain cases when you update the YCM plugin and the API changes incompatibly). It is slightly incovenient, but having a persistent service run in the background is the only way you can get fast and accurate completions (and other features YCM offers).Juanjuana
Thanks for your help and patience very much.After I install VS ,compile the YCM,the compiling message disapeared ,maybe the YCM problem has been solved.Hanser
Does Python completion work? Try opening a test.py file in vim and doing something like import math followed by math. then press control-space (the default completion shortcut). This should show you a list of completions. If it works, please upvote/accept my answer.Juanjuana
E
40

for error like

Error detected while processing BufRead Auto commands for"*.py":
E518:Unknow option:set
E28:No such highlight group name: BadWhitespace

add | to end of set xxx

au BufNewFile,BufRead *.js,*.html,*.css,*.vue
\ set tabstop=2 |
\ set softtabstop=2 |
\ set shiftwidth=2

set

"Flagging Unnecessary Whitespace
highlight BadWhitespace ctermbg=red guibg=darkred
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
Eamon answered 19/6, 2018 at 3:25 Comment(2)
This is a good answer that was explained in this comment on the main question. You can make it better if you edit it into here. Does the second stanza mean something?Capitalization
For the first issue, another fix is delete set except the first one. Better with less typing.Rosales
J
6

YCM depends on ycmd to do actual work. ycmd is a compiled service running in the background so you have to compile it to make it work.

The basic installation procedure consists of opening a shell / command line for your OS, cd-ing to YouCompleteMe's vim plugin directory and running ./install.py there to compile it. If you need it for languages other than Python, run ./install.py --help and look up any additional flags you need to add to turn on support for the languages you want to use.

The above assumes you have read YCM's installation guide and have installed the required dependencies. There are two guides relevant to your case and they are rather detailed and clearly written:

Juanjuana answered 12/10, 2016 at 15:48 Comment(5)
Please install CMake and retry. Traceback (most recent call last): File "C:\Users\admin\.vim\bundle\YouCompleteMe\install.py", line 44, in <module> Main() File "C:\Users\admin\.vim\bundle\YouCompleteMe\install.py", line 33, in Main subprocess.check_call( [ python_binary, build_file ] + sys.argv[1:] ) File "C:\Python27\lib\subprocess.py", line 541, in check_call raise CalledProcessError(retcode, cmd)subprocess.CalledProcessError: Command'['C:\\Python27\\python.exe', u'C:\\Users\\admin\\.vim\\bundle\\YouCompleteMe\\third_party\\ycmd\\build.py']' returned non-zero exit status 1Hanser
I try to run the install.py then return these message.Here I have a question :Do I have to "compile " it once I use the YCM plugin?If so,it is very inconveniency.Hanser
See my updated answer. Yes, to use YCM you have to compile the ycmd binary once (and again later in certain cases when you update the YCM plugin and the API changes incompatibly). It is slightly incovenient, but having a persistent service run in the background is the only way you can get fast and accurate completions (and other features YCM offers).Juanjuana
Thanks for your help and patience very much.After I install VS ,compile the YCM,the compiling message disapeared ,maybe the YCM problem has been solved.Hanser
Does Python completion work? Try opening a test.py file in vim and doing something like import math followed by math. then press control-space (the default completion shortcut). This should show you a list of completions. If it works, please upvote/accept my answer.Juanjuana

© 2022 - 2024 — McMap. All rights reserved.