Open rlue opened 7 years ago
Update, this issue only occurs in MacVim, no problem in Terminal.
Update, this issue only occurs in MacVim, no problem in Terminal.
Hmm, it seems strange.
Vint has a feature that guess file encoding, and this feature got something wrong. What file encoding are you using?
Thank you.
What file encoding are you using for config files such as ~/.vintrc
?
There's a .vintrc
?? (Clearly, I'm new at this.)
I don't have a .vintrc
file (I checked with find . -name "*vintrc*"
). Should I create one and set some settings?
I did a little check on every single file in my ~/.vim/
directory – the only non-UTF-8 files are git indices and objects from my various vim plugins, and all my vimundo files.
(I don't actually understand the command I used below; I just lifted it from this blog.)
$ pwd
/Users/rlue/.vim
$ find . -type f | xargs -I {} bash -c "iconv -f utf-8 -t utf-16 {} &>/dev/null || echo {}" > utf8_fail
$ cat utf8_fail
(you don't want to see the output of cat
– it's 700 lines long.)
And no – thank you.
Hmm... could you print the result of the following command?:
$ file -I /usr/local/lib/python2.7/site-packages/vint/asset/default_config.yaml
/usr/local/lib/python2.7/site-packages/vint/asset/default_config.yaml: text/plain; charset=us-ascii
I suspect that the module "chardet" (Vint is using this module) returned an unexpected result.
Could you try the following script?
# test.py
import pprint
import chardet
import sys
file_path = sys.argv[1]
print("Checking: `{0}`".format(file_path))
with open(file_path, mode='rb') as f:
bytes_seq = f.read()
pprint.pprint(chardet.detect(bytes_seq))
$ python ./test.py /usr/local/lib/python2.7/site-packages/vint/asset/default_config.yaml
{'confidence': 0.99, 'encoding': 'utf-8'}
Checking: `/usr/local/lib/python2.7/site-packages/vint/asset/default_config.yaml`
{'confidence': 1.0, 'encoding': 'ascii'}
Hmmmmm...! it seems strange! 😰
Very strange indeed! FWIW, the file appears as UTF-8 in vim, and if I add non-ascii characters to it (like “éâ” or “臭小孩”), vim still says it's UTF-8, but chardet says it's ISO-8859-2?? (confidence > .85)
Thanks for being so responsive. I'll take a closer look at it tonight and tell you if I come up with anything.
So I posted about this on reddit, and somebody helped me get one step closer to the answer:
If I launch GUI vim from the Finder, I get the error.
But if I launch GUI vim from the terminal (with mvim
), then the error goes away!
Clearly this is an issue with the way MacVim is implemented and not with vint itself. Sorry for the trouble!
EDIT: @lcd047 figured it out! It's the LC_CTYPE
environment variable. Still don't know what to do about it, though.
So I've been investigating this problem a little further. @lcd047 (from Syntastic) suggested it might be wise to look at the output of :echo system('env')
. I thought I'd share just in case you found it useful.
I ran the command in both settings (invoking from terminal and invoking from Finder), then removed all the identical lines. Here's what was left:
Launched from the terminal, it looks like this:
TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
TERM_PROGRAM_VERSION=361.1
TERM_SESSION_ID=510177A0-89AD-482B-93E8-313C3DD5A225
SHLVL=2
LC_CTYPE=UTF-8
and launched from the Finder, it looks like this:
SHLVL=1
So @lcd407 totally figured it out. The problem is that Finder doesn't preserve locales. If I set let g:syntastic_vim_vint_exe = 'LC_CTYPE=UTF-8 vint'
, then everything works fine
I'm reopening this issue per his/her suggestion:
Also, vint should provide some kind of fallback when locales are not available.
Thank you @kuniwak!
Thanks for sharing the cause! 🎉
I'll fix it later, but also you can send PullRequest to solve it. Would you send the PullRequest?
I wish I could, but I really don't know python at all! I'd just wind up making your code worse, I think, so I'll leave this one to you ;)
OK, I'll fix it later!
I have a similar issue (and similar to #225). Except that in my case, it does not even work from the terminal, even if setting LC_CTYPE=UTF-8
.
The python encoding test script yields the following results:
Checking: `/home/tim/.local/lib/python2.7/site-packages/vint/asset/default_config.yaml`
{'confidence': 1.0, 'encoding': 'ascii', 'language': ''}
I'm getting an error when I run
:SyntasticCheck
on VimL files. I have vim configured with only the options suggested for new users in Syntastic's README:Here's the output for the Syntastic debug log:
It appears this problem has cropped up with other linters, as well. Maybe a null value is being passed as an argument to
io.open
?I'd dig through the traceback in more detail, but I don't know python at all. :\