It is unclear why you are using the after
directory. From :help after-directory
:
5. In the "after" directory in your home directory. This is for
personal preferences to overrule or add to the distributed defaults
or system-wide settings (rarely needed).
So unless you are overwriting the ftplugin
preferences from a plugin, you should use the .vim/ftplugin/processing.vim
. For details you check :help filetype-plugin
and :help write-filetype-plugin
.
The filetype detection could also be done without the after
, as explained in :help new-filetype
. One of the recommend ways it to use the filetype.vim
:
C. If your file type can be detected by the file name.
1. Create your user runtime directory. You would normally use the first
item of the 'runtimepath' option. Example for Unix: >
:!mkdir ~/.vim
2. Create a file that contains autocommands to detect the file type.
Example: >
" my filetype file
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.mine setfiletype mine
au! BufRead,BufNewFile *.xyz setfiletype drawing
augroup END
Write this file as "filetype.vim" in your user runtime directory. For
example, for Unix: >
:w ~/.vim/filetype.vim
Edit:
I moved ftdetect and ftplugin out of ~/.vim/after/ to ~/.vim/ but it doesn’t change anything.
Indeed, I tried it here with the same results. As suggested in the comments, :verbose set syntax?
showed the culprit:
" Set up the connection between FileType and Syntax autocommands.
" This makes the syntax automatically set when the file type is detected.
augroup syntaxset
au! FileType * exe "set syntax=" . expand("<amatch>")
augroup END
From :help FileType
:
FileType When the 'filetype' option has been set. (...)
So despite you set the syntax correctly, after your ftplugin
is loaded the autocmd above overwrites it.
As this is in the Vim runtime files, you shouldn't change it. So one option would be to set the filetype to java, and on the java ftplugin
check the file extension (e.g.: using expand("%:e")
) and set the pde options instead of the java options.
Another approach would be delaying the setting of the syntax until the filetype is finished:
" ~/.vim/ftplugin/pde.vim
if exists("b:did_ftplugin")
finish
endif
augroup pdeSyntax
au!
autocmd Syntax <buffer> call SetPdeSyntax()
augroup END
function! SetPdeSyntax()
" remove the augroup
au! pdeSyntax
set syntax=java
endfunction
:verbose set syntax?
report?/usr/local/share/vim/vim81/syntax/syntax.vim
which is also the 6th entry in:scriptnames
.