packer.nvim icon indicating copy to clipboard operation
packer.nvim copied to clipboard

ft directive not really working

Open SephVelut opened this issue 2 years ago • 5 comments

NVIM v0.8.0-dev I'm on packer.nvim commit 4dedd3b (5 weeks ago)

Given only this use call

use { "catppuccin/nvim", as = "catppuccin", ft = "lua" }

I expect catppuccin to be loaded when lua files are opened. Currently, :scriptnames does not show catppuccin is loaded when a lua file is opened. Can be "fixed" by removing ft = "lua" reinstall recompile. Or simply manually moving catppuccin from /pack/packer/opt to /pack/packer/start.

set filetype? returns filetype=lua just fine.

SephVelut avatar Apr 27 '22 18:04 SephVelut

some plugins behave differently then others when they are designed without lazy loading in mind generally some plugins will work out of the box while others might not as for me if i use the ft option for lazy loading it works with all my packages if you're sure that the ft lazyloading is not properly working in packer you might as well set the package to opt = true and add a ftplugin/lua.lua in which you add

vim.cmd("packadd catppuccin")

which lazyloads also on ft opening

danielnehrig avatar May 06 '22 11:05 danielnehrig

This might be a general misconception held by me about opt/ft options, but I have a plugin (vim-solidity in the below example) that has:

{
  ft = 'solidity',
  opt = true,
}

But when I check my startup logs I can see that this plugin is loaded at startup as well. I thought adding these two options would make this plugin only be loaded when I open a solidity file. Anyone able to clarify, or is this a bug?

Startup logs...
times in msec
clock   self+sourced   self:  sourced script
clock   elapsed:              other lines

000.021  000.021: --- NVIM STARTING ---
003.027  003.006: locale set
075.202  072.175: inits 1
075.285  000.083: window checked
075.289  000.004: parsing arguments
079.093  003.803: init lua interpreter
079.920  000.827: expanding arguments
080.158  000.239: inits 2
080.599  000.441: init highlight
080.601  000.002: waiting for UI
084.058  003.457: done waiting for UI
084.066  000.007: init screen for UI
084.211  000.145: init default mappings
084.554  000.343: init default autocommands
124.177  000.076  000.076: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/ftplugin.vim
174.188  000.231  000.231: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/indent.vim
309.736  001.791  001.791: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/filetype.lua
465.045  000.112  000.112: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/LuaSnip/ftdetect/snippets.vim
469.512  048.588  048.476: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/filetype.vim
475.476  000.673  000.673: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/ftplugin.vim
477.064  000.042  000.042: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/indent.vim
6462.403  6233.086  6181.992: sourcing /Users/kyle/.config/nvim/init.lua
6462.503  144.556: sourcing vimrc file(s)
6572.670  000.197  000.197: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/syntax/synload.vim
6574.189  060.153  059.956: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/syntax/syntax.vim
6614.886  000.390  000.390: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/gzip.vim
6630.083  000.087  000.087: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/health.vim
6679.860  000.150  000.150: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/man.vim
6905.646  000.362  000.362: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim
6907.274  042.881  042.519: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/matchit.vim
6949.007  000.434  000.434: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/matchparen.vim
6981.368  001.446  001.446: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/netrwPlugin.vim
7067.199  000.103  000.103: sourcing /Users/kyle/.local/share/nvim/rplugin.vim
7067.298  035.084  034.981: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/rplugin.vim
7111.625  000.203  000.203: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/shada.vim
7179.721  000.124  000.124: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/spellfile.vim
7215.228  001.189  001.189: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/tarPlugin.vim
7309.404  000.211  000.211: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/tohtml.vim
7341.832  000.141  000.141: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/tutor.vim
7375.136  000.461  000.461: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/plugin/zipPlugin.vim
11576.100  000.097  000.097: sourcing /Users/kyle/.config/nvim/colors/void.vim
23611.996  000.074  000.074: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/opt/vim-solidity/ftdetect/solidity.vim
23612.037  16183.541  16183.370: sourcing /Users/kyle/.config/nvim/plugin/packer_compiled.lua
23612.639  823.642: loading rtp plugins
23732.245  042.018  042.018: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/dashboard-nvim/plugin/dashboard.lua
23793.358  003.269  003.269: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/loupe/plugin/loupe.vim
25798.458  1940.531  1940.531: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/LuaSnip/plugin/luasnip.vim
25808.127  000.051  000.051: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/neoformat/plugin/neoformat.vim
25905.296  047.279  047.279: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/neovim-session-manager/plugin/session_manager.lua
26008.700  061.218  061.218: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/nvim-cmp/plugin/cmp.lua
26081.184  000.119  000.119: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer/plugin/nvim-lsp-installer.vim
26128.421  000.528  000.528: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/nvim-lspconfig/plugin/lspconfig.lua
26557.861  392.610  392.610: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/nvim-treesitter/plugin/nvim-treesitter.lua
26607.976  000.143  000.143: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/nvim-web-devicons/plugin/nvim-web-devicons.vim
26655.895  000.168  000.168: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/plenary.nvim/plugin/plenary.vim
26701.684  003.115  003.115: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/telescope.nvim/plugin/telescope.lua
26731.706  000.265  000.265: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/trouble.nvim/plugin/trouble.vim
26771.654  002.244  002.244: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/vim-rainbow/plugin/rainbow.vim
26896.429  002.835  002.835: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/vim-sleuth/plugin/sleuth.vim
26999.536  000.873  000.873: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/vim-surround/plugin/surround.vim
27031.337  000.123  000.123: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/vim-tpipeline/plugin/tpipeline.vim
27076.997  000.184  000.184: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/zen-mode.nvim/plugin/zen-mode.vim
27078.012  967.799: loading packages
27140.421  000.907  000.907: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/indentLine/after/plugin/indentLine.vim
27239.357  012.150  012.150: sourcing /Users/kyle/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp/after/plugin/cmp_nvim_lsp.lua
27239.934  148.865: loading after plugins
27239.953  000.019: inits 3
27390.228  150.275: reading ShaDa
28005.343  615.116: opening buffers
28091.544  086.201: BufEnter autocommands
28091.550  000.006: editing files in windows
28382.224  290.674: VimEnter autocommands
28382.230  000.006: UIEnter autocommands
28432.119  000.384  000.384: sourcing /opt/homebrew/Cellar/neovim/0.7.2/share/nvim/runtime/autoload/provider/clipboard.vim
28432.163  049.549: before starting main loop
28436.629  004.466: first screen update
28436.634  000.005: --- NVIM STARTED ---

EDIT: Also, if anyone has any suggestions to debugging why my startup is insanely slow any help would be greatly appreciated. As you can see my startup can be nearly unbearably slow.

avegancafe avatar Oct 13 '22 20:10 avegancafe

@avegancafe vim-solidity, in particular, does not need ft lazyloading - it already uses ftplugin, and packer is loading parts of it because it provides ftdetect scripts which are necessary to discover the solidity filetype to begin with. For debugging your start time, I would suggest using a plugin like https://github.com/dstein64/vim-startuptime to identify the main culprits.

wbthomason avatar Oct 14 '22 21:10 wbthomason

@SephVelut I'm not really able to reproduce this, using the config you pasted. Is this still a problem for you?

Also @avegancafe: note that ft implies opt, so you don't need to manually mark opt = true.

wbthomason avatar Oct 14 '22 21:10 wbthomason

@SephVelut Note that I'm testing with :lua require 'catppuccin'.setup(), which correctly fails (with impatient.nvim disabled, as that cache can interfere) for non-Lua files and correctly executes for Lua files in my experiments. I do not see catppuccin in :scriptnames, but I'm not sure if Lua scripts sourced via packadd show there?

wbthomason avatar Oct 14 '22 21:10 wbthomason