Skip to content

Commit 0ba62c4

Browse files
authored
fix: do not treat directories as editable on VimEnter (#217)
Fixes #212
1 parent 5b875ac commit 0ba62c4

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

plugin/editorconfig.vim

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ function! s:UseConfigFiles() abort " Apply config to the current buffer {{{1
208208
let b:editorconfig_tried = 1
209209
let l:buffer_name = expand('%:p')
210210

211+
" Only process normal buffers (do not treat help files as '.txt' files)
212+
" When starting Vim with a directory, the buftype might not yet be set:
213+
" Therefore, also check if buffer_name is a directory.
214+
if index(['', 'acwrite'], &buftype) == -1 || isdirectory(l:buffer_name)
215+
return
216+
endif
217+
211218
if empty(l:buffer_name)
212219
if g:EditorConfig_enable_for_new_buf
213220
let l:buffer_name = getcwd() . "/."
@@ -378,16 +385,6 @@ endfunction " }}}2
378385
" }}}1
379386

380387
function! s:ApplyConfig(config) abort " Set the buffer options {{{1
381-
" Only process normal buffers (do not treat help files as '.txt' files)
382-
if index(['', 'acwrite'], &buftype) == -1
383-
return
384-
endif
385-
386-
" Do not process netrw buffers
387-
if &filetype == 'netrw'
388-
return
389-
endif
390-
391388
if g:EditorConfig_verbose
392389
echo 'Options: ' . string(a:config)
393390
endif

0 commit comments

Comments
 (0)