editorconfig / editorconfig-vim

EditorConfig plugin for Vim
http://editorconfig.org
Other
3.13k stars 137 forks source link

insert_final_newline = unset doesn't obey existing setting #168

Open jsit opened 3 years ago

jsit commented 3 years ago

I have insert_final_newline = unset in my .editorconfig, and set nofixendofline in my .vimrc.

When editorconfig runs, it turns fixendofline/fixeol on again, because insert_final_newline isn't set to false:

    if s:IsRuleActive('insert_final_newline', a:config)
        if exists('+fixendofline')
            if a:config["insert_final_newline"] == "false"
                setl nofixendofline
            else
                setl fixendofline
            endif
        elseif  exists(':SetNoEOL') == 2
            if a:config["insert_final_newline"] == "false"
                silent! SetNoEOL    " Use the PreserveNoEOL plugin to accomplish it
            endif
        endif
    endif

It may make more sense if unset just used the existing (no)fixeol setting.

The reason I'm using unset at all is because I have true in my home folder's .editorconfig, but want to unset it for a project in a subdirectory.

jsit commented 3 years ago

Maybe:

if a:config["insert_final_newline"] == "false" || !&fixendofline
    setl nofixendofline
cxw42 commented 3 years ago

Related to #136