From eb93a040b56d3630a16fdf866d5a17ee5f06023f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 14 Jul 2015 18:56:15 +0200 Subject: [PATCH] Use ftdetect mechanism with `setf html` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In commit 12e3799 an aggressive method of detecting "html" filetypes was added. But it is too aggressive, and causes problems with (re)loading a file like the following, which got detected as "htmldjango" by Vim's `filetype.vim` process initially: {% load staticfiles %} While `BufRead,BufNewFile` is used typically, this patch keeps using `BufReadPost`, which appears to be used to target netrw explicitly?! --- ftdetect/ragtag.vim | 2 ++ plugin/ragtag.vim | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 ftdetect/ragtag.vim diff --git a/ftdetect/ragtag.vim b/ftdetect/ragtag.vim new file mode 100644 index 0000000..f48dfbb --- /dev/null +++ b/ftdetect/ragtag.vim @@ -0,0 +1,2 @@ +autocmd BufReadPost * if ! did_filetype() && getline(1)." ".getline(2). + \ " ".getline(3) =~? '<\%(!DOCTYPE \)\=html\>' | setf html | endif diff --git a/plugin/ragtag.vim b/plugin/ragtag.vim index 98fb66e..295ed89 100644 --- a/plugin/ragtag.vim +++ b/plugin/ragtag.vim @@ -23,8 +23,6 @@ endif augroup ragtag autocmd! - autocmd BufReadPost * if ! did_filetype() && getline(1)." ".getline(2). - \ " ".getline(3) =~? '<\%(!DOCTYPE \)\=html\>' | setf html | endif autocmd FileType *html*,wml,jsp,gsp,mustache,smarty call s:Init() autocmd FileType php,asp*,cf,mason,eruby,liquid,jst,eelixir call s:Init() autocmd FileType xml,xslt,xsd,docbk call s:Init()