添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I have never write a plugin before, so this might be a stupid question.

When writing my own Neovim config based on LazyVim, I noticed I could not get rid of ftplugin or autocmd FileType . For example, the plugin vimtex , which is famous for LaTeX users, would create a lot of keybindings to <localleader>l by default. It's necessary that use autocmd to create whichkeys' hints for LaTeX files only. Another example is rust-tools also provides some commands that only work in Rust files.

I know it's possible to use autocmd FileType instead of ftplugin . But Vim/Neovim provide ftplugin and after/ftplugin , there is no reason to ignore them.

I'm wondering if we can provide some keymaps to <localleader> according to filetype by default. As I mentioned, I know autocmd FileType could finish this work, but configs in ftplugin would be easier to be found.

In other words, can we provide a plugin whose files are structured as follows?

$XDG_DATA_HOME/LazyVim/
|-- ftplugin/
|   |-- some_language.lua
|-- lua/
|   |-- lazyvim/
|   |   |-- plugins/extras/lang/
|   |   |   |-- some_language.lua
|-- ...

BTW, you're really a hero for Nvim plugins! I will create a PR to bring ZenMode and Twilight into LazyVim!

Sorry for wasting your time but I just realise that which-key can fulfill my requirement, i.e. only creating hints for activated plugins that are enabled by filetypes. I made this mistake because my old configurations used ftplugin to trigger which-key register.

Other usages of ftplugin I can get now are personal configurations more or less.

Thanks for your reply!