I'm writing a custom ftplugin for handling systemd
file type. I've copied parts of code from vim's own systemd ftplugin and now the latter conflicts with my own code:
Error detected while processing BufRead Autocommands for "*/etc/systemd/*.conf"..FileType Autocommands for "*"..function <SNR>1
4_LoadFTPlugin[18]..script /usr/share/vim/vim90/ftplugin/systemd.vim:
line 12:
E174: Command already exists: add ! to replace it: Sman silent exe '!' . KeywordLookup_systemd(<q-args>) | redraw!
From what I see, the error comes from the system-wide ftplugin. The problem is, it uses the normal b:did_ftplugin
guard improperly. Instead of this:
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
...it does this:
if !exists('b:did_ftplugin')
" some code that sets b:did_ftplugin
endif
" some more code
As such, the code that is not guarded comes into conflict with my own code.
I suppose this is something that should be patched upstream, but in the meantime, is there a way to prevent Vim from loading the system-wide ftplugin/systemd.vim
and only load mine?
:runtime ftplugin/systemd.vim
, like for the Man plugin, but I haven’t checked.ftplugin/man.vim
for some serious weirdness.) I'll contact the maintainer and suggest a patch.