Skip to content
This repository
Browse code

Move file type detection back to plugin script (issues #16 & #17)

Since I published the notes.vim plug-in I cannot remember ever
getting a single complaint about the file type not loading,
however since I introduced "ftdetect/notes.vim" I've gotten
several complaints. I'm hoping this commit will resolve the
issues some users have been experiencing.

Still it's strange that I'm not experiencing the issue myself.

Oh well.
  • Loading branch information...
commit 9933c4f2fcf31fb45dda6e78b06003f41994e349 1 parent 4be5e0b
Peter Odding authored December 14, 2011
4  autoload/xolox/notes.vim
... ...
@@ -1,12 +1,12 @@
1 1
 " Vim auto-load script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: December 11, 2011
  3
+" Last Change: December 14, 2011
4 4
 " URL: http://peterodding.com/code/vim/notes/
5 5
 
6 6
 " Note: This file is encoded in UTF-8 including a byte order mark so
7 7
 " that Vim loads the script using the right encoding transparently.
8 8
 
9  
-let g:xolox#notes#version = '0.16.15'
  9
+let g:xolox#notes#version = '0.16.16'
10 10
 let s:scriptdir = expand('<sfile>:p:h')
11 11
 
12 12
 function! xolox#notes#init() " {{{1
19  ftdetect/notes.vim
... ...
@@ -1,19 +0,0 @@
1  
-" Vim file type detection script
2  
-" Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: December 11, 2011
4  
-" URL: http://peterodding.com/code/vim/notes
5  
-
6  
-" Initialize the configuration defaults.
7  
-call xolox#notes#init()
8  
-
9  
-" Define the automatic commands used to recognize notes.
10  
-
11  
-execute 'autocmd BufNewFile,BufRead'
12  
-        \ xolox#notes#autocmd_pattern(g:notes_directory, 1)
13  
-        \ 'if empty(&buftype) | setlocal filetype=notes | endif'
14  
-
15  
-execute 'autocmd BufNewFile,BufRead'
16  
-        \ xolox#notes#autocmd_pattern(g:notes_shadowdir, 0)
17  
-        \ 'if empty(&buftype) | setlocal filetype=notes | endif'
18  
-
19  
-" vim: ts=2 sw=2 et
8  plugin/notes.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: December 11, 2011
  3
+" Last Change: December 13, 2011
4 4
 " URL: http://peterodding.com/code/vim/notes/
5 5
 
6 6
 " Support for automatic update using the GLVS plug-in.
@@ -45,6 +45,12 @@ augroup PluginNotes
45 45
   exe 'au BufWriteCmd' xolox#notes#autocmd_pattern(g:notes_directory, 1) 'call xolox#notes#save()'
46 46
 augroup END
47 47
 
  48
+augroup filetypedetect
  49
+  let s:template = 'au BufNewFile,BufRead %s if &bt == "" | setl ft=notes | end'
  50
+  execute printf(s:template, xolox#notes#autocmd_pattern(g:notes_directory, 1))
  51
+  execute printf(s:template, xolox#notes#autocmd_pattern(g:notes_shadowdir, 0))
  52
+augroup END
  53
+
48 54
 " Make sure the plug-in is only loaded once.
49 55
 let g:loaded_notes = 1
50 56
 

0 notes on commit 9933c4f

Please sign in to comment.
Something went wrong with that request. Please try again.