Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@xolox authored
View
4 autoload/xolox/notes.vim
@@ -1,12 +1,12 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: December 11, 2011
+" Last Change: December 14, 2011
" URL: http://peterodding.com/code/vim/notes/
" Note: This file is encoded in UTF-8 including a byte order mark so
" that Vim loads the script using the right encoding transparently.
-let g:xolox#notes#version = '0.16.15'
+let g:xolox#notes#version = '0.16.16'
let s:scriptdir = expand('<sfile>:p:h')
function! xolox#notes#init() " {{{1
View
19 ftdetect/notes.vim
@@ -1,19 +0,0 @@
-" Vim file type detection script
-" Author: Peter Odding <peter@peterodding.com>
-" Last Change: December 11, 2011
-" URL: http://peterodding.com/code/vim/notes
-
-" Initialize the configuration defaults.
-call xolox#notes#init()
-
-" Define the automatic commands used to recognize notes.
-
-execute 'autocmd BufNewFile,BufRead'
- \ xolox#notes#autocmd_pattern(g:notes_directory, 1)
- \ 'if empty(&buftype) | setlocal filetype=notes | endif'
-
-execute 'autocmd BufNewFile,BufRead'
- \ xolox#notes#autocmd_pattern(g:notes_shadowdir, 0)
- \ 'if empty(&buftype) | setlocal filetype=notes | endif'
-
-" vim: ts=2 sw=2 et
View
8 plugin/notes.vim
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: December 11, 2011
+" Last Change: December 13, 2011
" URL: http://peterodding.com/code/vim/notes/
" Support for automatic update using the GLVS plug-in.
@@ -45,6 +45,12 @@ augroup PluginNotes
exe 'au BufWriteCmd' xolox#notes#autocmd_pattern(g:notes_directory, 1) 'call xolox#notes#save()'
augroup END
+augroup filetypedetect
+ let s:template = 'au BufNewFile,BufRead %s if &bt == "" | setl ft=notes | end'
+ execute printf(s:template, xolox#notes#autocmd_pattern(g:notes_directory, 1))
+ execute printf(s:template, xolox#notes#autocmd_pattern(g:notes_shadowdir, 0))
+augroup END
+
" Make sure the plug-in is only loaded once.
let g:loaded_notes = 1
Please sign in to comment.
Something went wrong with that request. Please try again.