Skip to content

Commit

Permalink
Conditionally define variables b:editorconfig_tried and b:editorconfi…
Browse files Browse the repository at this point in the history
…g_applied (editorconfig#142)

These can be used to introspect whether editorconfig hooks have run for a buffer
and whether they had any config to apply in order to make downstream heuristic
decisions such as whether to invoke vim-sleuth to guess buffer settings.

Resolves editorconfig#141.
  • Loading branch information
dbarnett authored Apr 4, 2021
1 parent 047c4b4 commit f305bc7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugin/editorconfig.vim
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ function! s:GetFilenames(path, filename) " {{{1
endfunction " }}}1

function! s:UseConfigFiles() abort " Apply config to the current buffer {{{1
let b:editorconfig_tried = 1
let l:buffer_name = expand('%:p')
" ignore buffers without a name
if empty(l:buffer_name)
Expand Down Expand Up @@ -242,9 +243,12 @@ function! s:UseConfigFiles() abort " Apply config to the current buffer {{{1
endfor

if s:editorconfig_core_mode ==? 'vim_core'
call s:UseConfigFiles_VimCore()
if s:UseConfigFiles_VimCore() == 0
let b:editorconfig_applied = 1
endif
elseif s:editorconfig_core_mode ==? 'external_command'
call s:UseConfigFiles_ExternalCommand()
let b:editorconfig_applied = 1
else
echohl Error |
\ echo "Unknown EditorConfig Core: " .
Expand Down

0 comments on commit f305bc7

Please sign in to comment.