Friday, February 13, 2026

Re: blacklist some ftplugins?

On 2026-02-12, Marc Chantreux wrote:
> Hello people,
>
> I saw there is a write-filetype-plugin section in a documentation and
> will read it (and maybe discuss about it) to get something I would like:
> ftplugins to provide suggestions instead of setting them (maybe it could
> be conventions on how to name the variable that can be the candidate to
> setup &mp).
>
> I have no time for this right now and just fixed the problem:
>
> find /usr/share/vim/vim91/ -name sh.vim |
> sed 'p;s!/!_!g' |
> xargs -n2 mv
>
> That was brutal. was there something less destructive?
> for exemple: a way yo blacklist some system filetypes?
>
> filetype plugin user=sh,raku # to say that I take care about those ones
> filetype plugin disable=sh,raku # to say I just don't want plugins for those ones
>
> thanks for any help and regards,

How about this? Put this autocommand early in your vimrc, before
any filetype or syntax commands:

autocmd Filetype sh,raku let b:did_ftplugin = 1

Then put this autocommand late in your vimrc, after all filetype and
syntax commands:

autocmd Filetype sh,raku syn clear | unlet! b:current_syntax


I use the following system in my vimrc for controlling which
filetypes get syntax highlighting, but I think the above is
sufficient. (b:syn is used to track the desired state of 'syntax'.
Other autocommands use it to control syntax highlighting when 'diff'
is turned on and off.)

" ":syntax manual" will enable syntax highlighting only for specific
" buffers in which :set syntax=ON" is set. See ":help :syn-manual".
"
syntax manual

let no_syntax_filetypes = [ 'c', 'cpp', 'man', 'netrw', 'objcpp', 'python', 'vim' ]
autocmd FileType * if !empty(expand("<amatch>"))
\ | if !count(no_syntax_filetypes, expand("<amatch>"))
\ | let b:syn="ON"
\ | if !&diff
\ | setlocal syntax=ON
\ | endif
\ | else
\ | syn clear
\ | if exists("b:current_syntax")
\ | unlet b:current_syntax
\ | endif
\ | endif
\ | endif

Regards,
Gary

--
--
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.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/20260213171426.GG14680%40phoenix.

No comments: