junegunn / vim-plug

:hibiscus: Minimalist Vim Plugin Manager
https://junegunn.github.io/vim-plug/
MIT License
33.7k stars 1.9k forks source link

Vim plug and lua plugins: calling setup & config functions #1252

Closed Twix53791 closed 10 months ago

Twix53791 commented 10 months ago

Hi, I am just posting here the solution of a problem on which I spent all my day...

The problem: many lua plugins require for their configuration, or even to run, to call a lua function. For example:

use({
    'emileferreira/nvim-strict',
    config = function()
        require('strict').setup()
    end
})

How to call such a function from vim plug like in packer (above)?

Of course all these plugins I found did'nt give any instructions about installing them with vim plug (always Lazy, packer... lua things...). On the web I found many tutorial about setting the vim config in lua, even to use vim plug from lua, but not the inverse.

Like often, it was so simple and evident than no one on the web thought it was usefull to explain that for the newbies a bit slow on the uptake like me... The solution is to use an include of lua code in init.vim, BUT not in the vim plug block delimited by call plug#begin() and call plug#end() but after (if I understood well!). Like that:

lua <<EOF
require("catppuccin").setup({
    flavour = "latte", -- latte, frappe, macchiato, mocha
    background = { -- :h background
        light = "latte",
        dark = "mocha",
    },
    transparent_background = true, -- disables setting the background color.
})
EOF

One day of roaming on the web to understand that... I hope this small post will avoid such a exhausting experience to some people after me!

bblacher commented 6 months ago

Oh my god thank you so much for posting this! Finally solved my problem.