Sunday, June 16, 2013

Why doesn't the syntax file load the function from the ftplugin file?

Hello,

The file vimfiles/ftplugin/notes.vim starts as follows:

if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1 " Don't load another plugin for this buffer

nmap <buffer> <localleader>u Yp$x^v$r-

nmap <buffer> <F5> :syn off\|syn on<cr>

setlocal spell
setlocal smartindent
setlocal textwidth=80
setlocal complete=.

if !exists("*s:MyNotesFoldLevel")
function! MyNotesFoldLevel(acline)

let cline = a:acline
<omitting rest of the function>
endfunction
endif
<omitting rest of the stuff in this file>

The file vimfiles/syntax/notes.vim starts as follows:

syn clear
if !exists("*s:MyNotesFoldLevel")
ru ftplugin/notes.vim
endif

%g/^/let i = line('.') |
\ let level = MyNotesFoldLevel(i) |
<omitting rest of the stuff in this file>

But the very first time a notes file is loaded, I get the error message:

Error detected while processing C:\opt\vim\vimfiles\syntax\notes.vim:
line 35:
E117: Unknown function: MyNotesFoldLevel
E15: Invalid expression: MyNotesFoldLevel(i) | <omitting rest of
the stuff>

After that, loading the same or different notes file is OK.

How to fix the error message for the very first load?

Thanks,

--Suresh

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment