Vimjas / vint

Fast and Highly Extensible Vim script Language Lint implemented in Python.
MIT License
700 stars 33 forks source link

Spurious scriptencoding error when checking multiple files #363

Open puremourning opened 4 years ago

puremourning commented 4 years ago

The warning "Set encoding before setting scriptencoding (see :help :scriptencoding)" is reported when a set encoding= is found in any file after :scriptencoding

To reproduce:

set encoding=utf-8
scriptencoding utf-8
set encoding=utf-8

Expected result: no error Actual result:

dir2/file2.vim:1:1: Set encoding before setting scriptencoding (see :help :scriptencoding)
lelutin commented 3 years ago

Hi there, I can confirm that I'm seeing this issue with vint 0.4a3 on my .vim directory (it actually contains my vimrc file)

my vimrc sets encoding first and then scriptencoding. there's one more file that sets scriptencoding and that causes the error to show up

offa commented 2 years ago

Workaround:

policies:
  ProhibitEncodingOptionAfterScriptEncoding:
    enabled: false
lelutin commented 2 years ago

Hi there, I can confirm that adding the snippet of configuration that @offa mentioned to ~/.vintrc.yaml takes out the error about the encoding.

It also takes out all legit checks for this within files though.

The way I worked arount this issue was to modify my ~/.vimrc in this way to disable the warning only where the error was being produced:

  " vint: -ProhibitEncodingOptionAfterScriptEncoding
  set encoding=utf-8
  scriptencoding utf-8
  " vint: +ProhibitEncodingOptionAfterScriptEncoding
puremourning commented 2 years ago

I just use my fork which includes the fix https://github.com/Vimjas/vint/pull/364