Open kbenzie opened 10 years ago
Hi, thank you for your report.
clang-format
command's failure raises the error. Could you confirm that clang-format
command can format the C++ code properly in your command line? And please tell me the version of clang-format.
Unfortunately, I don't have Windows environment. I can't do debug by my hands.
Hi,
I can confirm that calling clang-format
from the command line works as expected.
The version is a snapshot from llvm.org
clang-format version 3.6.0 (218712)
I have the following setting in my .vimrc
let g:clang_format#code_style='google'
My intuition is that vim-clang-format
was unable to find clang-format
on the path for some reason. Is there some way to provide this path as a vim setting?
Hi. Thank you for your information.
Is there some way to provide this path as a vim setting?
g:clang_format#command
is available. Please try it.
let g:clang_format#command = "path/to/your-clang-format"
I'll close this issue because of no response. If anyone encounters this issue, please reopen this issue.
Hi rhysd, I'm afraid I have the same problem. Windows7, Vim7.4, plugin freshly cloned from github and installed by manually copying files to vimfiles dir.
The error I get is a little different, though:
Error detected while processing function clang_format#replace..<SNR>77_error_message:
line 1:
clang-format has failed to format
I have tried setting the clang_format#command variable as you suggested, and then I get a different error:
Error detected while processing function clang_format#replace..clang_format#format..<SNR>77_system:
line 8:
E484: Can't open file C:\Users\juanval\AppData\Local\Temp\VIo8430.tmp
Any ideas? Thanks!
@jonvaldes
Thank you for your report.
The error seems to occur here where vim-clang-format executes clang-format
command.
And :help E484
says that it is an error when Vim can't read a temporary file at calling system()
. In Windows, some additional special character must be escaped. So it seems to be the reason that vim-clang-format doesn't escape them in Windows. :help E848
also says using shellescape()
may resolve the issue. I'll make new branch and use shellescape()
in it.
@jonvaldes
I tried to fix this issue in fix/issues/14 branch. Could you try it? I can't test it on my side because I don't have Windows PC.
@rhysd Just tried it, but I get the same issue. However, if I move clang-format to c:\ or I make sure it's in the path, I still get the original error:
Error detected while processing function clang_format#replace..<SNR>78_error_message:
line 1:
clang-format has failed to format.
So I guess that wouldn't be because of weird characters...
@jonvaldes
Thank you for your try. It seems that command should also be escaped. I implemented it in b175afa.
Error detected while processing function clang_format#replace..
78_error_message: line 1: clang-format has failed to format.
This error message derives from the failure of executing clang-format
command. So, to determine it is an issue of vim-clang-format side or clang-format side, it is needed to execute the same command in cmd.exe manually and check the result.
@rhysd I've tried that commit, but I still get the same error :( I need to go back to work on my own stuff, so for the moment I've resorted to a crappy .bat file. That'll work for the moment.
If you try any more possible fixes for this issue, I'll gladly check them out and see if they work for me.
When I format my code using :12verbose ClangFormat
, I got these:
...
调用 shell 执行: "D:/tool/LLVM/bin/clang-format.exe -lines=1:48 -style='{BasedOnStyle: mozilla, IndentWidth: 4, UseTab: false}' -- <D:\temp\VIiDCBA.tmp >D:\temp\VIoDCBB.tmp 2>&1"
...
function clang_format#replace..clang_format#format 返回 'error: -offset, -length and -lines can only be used for single file.'
...
And my LLVM version is 3.6.1.
Has anyone ever successfully gotten vim-clang-format to work on Windows with gvim? I have the same temp file issue and none of the suggestions here fix it.
I encountered this problem just after an Vundle PluginUpdate, so I think the problem is in those plugins. There is a dependency call vimproc. After an update, the builded dll(Check for vimproc_win64.dll or vimproc_win32.dll in $VIM/bundle/vimproc.vim/autoload/) for Windows is lost. Thus after you updated the plugin or you just fresh installed vimproc you need to build the vimproc dll. You can build it by cd into vimproc.vim folder and exec "./tools/update-dll-mingw.bat". The building require mingw32 installed(Check vimproc building instructions). After building the required dll, the problem solved.
Hi, I think I've got the same issue trying to run vim-clang-format into gvim 8.0 with vimproc already installed:
Error detected while processing function clang_format#replace[2]..<SNR>89_verify_command:
line 3:
clang-format has failed to format
I actually don't run into this problem with projects that have a .clang-format
. So, I opened vim with vim -V9details.log thread.cpp
in a place without .clang-format
and tried :w
a bunch of times and got this info:
Calling shell to execute: "^"clang-format^" -lines=1:26 -style='{BasedOnStyle: google, IndentWidth: 4, UseTab: false, }' -assume-filename=^"thread.cpp^" -- <C:\Users\g\temp\VIiE2CC.tmp >C:\Users\g\temp\VIoE2CD.tmp 2>&1"
Error detected while processing function clang_format#replace[18]..<SNR>42_error_message:
line 1:
To me it looks like style='
should be using double quotes for windows. I ran the command outside:
C:\Users\g\temp>copy thread.cpp threadin.cpp
1 file(s) copied.
C:\Users\g\temp>^"clang-format^" -lines=1:26 -style='{BasedOnStyle: google, IndentWidth: 4, UseTab: false, }' -assume-filename=^"thread.cpp^" -- < threadin.cpp > threadout.cpp
error: -offset, -length and -lines can only be used for single file.
modifying to use double quotes:
C:\Users\g\temp>"clang-format" -lines=1:26 -style="{BasedOnStyle: google, IndentWidth: 4, UseTab: false, }" -assume-filename=^"thread.cpp^" -- < threadin.cpp > threadout.cpp
:: no error
I believe this is no longer an issue, and can be closed due to cc9b5d8f
Hello! I've got the same error in neovim (both nvim and nvim-qt). Win10, vimproc installed and compiled. I use ":ClangFormat" to run clang-format (10.0.0)
vimrc file doesn't customise the clang-format style settings. .clang-format craeted by --dump-config.
I've been using this plugin on linux happily for months, thanks. However I'm sometimes required to do development on Windows at work.
I have
clang-format
on my path but am getting the following error message in Windows gvim 7.4.I tried installing Shougo/vimproc.vim as advised in the documentation but got the same error.
Any idea what would be causing this issue?