From 00213842594d8262c35b64b03b176d6e831a6e94 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sat, 17 Oct 2020 15:56:13 +0200 Subject: Make sure polyglot_disable does not skip native vim files, fixes #591 --- ftdetect/polyglot.vim | 25 ++++++++++++++----------- plugin/polyglot.vim | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 34dfdf8b..01a465bb 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -13,6 +13,10 @@ if exists("did_load_polyglot") finish endif +" Line continuation is used here, remove 'C' from 'cpoptions' +let s:cpo_save = &cpo +set cpo&vim + let did_load_polyglot = 1 " It can happen vim filetype.vim loads first, then we need a reset @@ -23,10 +27,6 @@ endif " Prevent filetype.vim of vim from loading again let did_load_filetypes = 1 -" Line continuation is used here, remove 'C' from 'cpoptions' -let s:cpo_save = &cpo -set cpo&vim - " Be consistent across different systems set nofileignorecase @@ -117,12 +117,12 @@ func! s:StarSetf(ft) endif endfunc -" Load user-defined filetype.vim augroup filetypedetect -runtime! filetype.vim -augroup END -augroup filetypedetect +" Load user-defined filetype.vim and oter plugins ftdetect first +" This is to use polyglot-defined ftdetect always as fallback to user settings +runtime! filetype.vim +runtime! ftdetect/*.vim " DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE @@ -3421,15 +3421,18 @@ au BufNewFile,BufRead *.txt \| setf text \| endif -" Use the filetype detect plugins. They may overrule any of the previously -" detected filetypes. -runtime! ftdetect/*.vim " NOTE: The above command could have ended the filetypedetect autocmd group " and started another one. Let's make sure it has ended to get to a consistent " state. augroup END +" Use the filetype detect plugins. They may overrule any of the previously +" detected filetypes. +if exists("did_load_filetypes") && exists("g:polyglot_disabled") + unlet did_load_filetypes + runtime! $VIMRUNTIME/filetype.vim +endif " Restore 'cpoptions' let &cpo = s:cpo_save diff --git a/plugin/polyglot.vim b/plugin/polyglot.vim index 3148cff7..7cfa1069 100644 --- a/plugin/polyglot.vim +++ b/plugin/polyglot.vim @@ -1,3 +1,3 @@ if !exists("did_load_polyglot") - runtime! ftdetect/polyglot.vim + filetype plugin indent on endif -- cgit v1.2.3