wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.75k stars 261 forks source link

Exclude plugins from loading in specified file types #1074

Open bojanmilevski opened 1 year ago

bojanmilevski commented 1 year ago

It would be nice to exclude certain plugins from being loaded in certain files and/or filetypes. This would greatly increase performance and usability in lower-spec machines (like the Raspberry Pi for example), where resources are limited.

In my everyday-to-day use, I find myself constantly editing *.txt files - such as todo.txt, shopping-cart.txt or albums.txt, where most of my plugins are just not necessary. I certainly do not need lsp-config loading in these files.

To further explain my request, here is a very dumb, yet practical example of what I mean:

require('packer').startup(function(use)

    use {
        'neovim/nvim-lspconfig',
        exclude_file = '*.txt' -- accepts regex
    }

    use {
        'L3MON4D3/LuaSnip',
        exclude_file = 'main.rs'
    }

    use 'nvim-telescope/telescope.nvim'

end)

This would mean that any file ending in .txt (regex'd) would not load nvim-lspconfig and any file named main.rs (no hate to rustaceans), would not load LuaSnip, but both would load telescope.nvim.

Looking forward on collaborating and contributing!

XVilka commented 1 year ago

It also makes sense for using NeoVim as a pager:

For example, when opening man or info pages, or when used as git diff/git rebase, etc editor, you got the idea.

nat-418 commented 1 year ago

See this issue for a discussion on how to use the opt to lazy load plugins per filetype: https://github.com/wbthomason/packer.nvim/discussions/946

In a sense this is the opposite of what you are asking for, but it might get you the behavior you want in the end.