coq_nvim icon indicating copy to clipboard operation
coq_nvim copied to clipboard

Feature Request: Make use of a 'require("coq_nvim").setup()' style lua function.

Open koshell opened this issue 2 years ago • 2 comments

Specifically a function would be useful since then we could inspect its return value.

For context: I am frequently moving my neovim config between machines so I frequently re-downloading my plugins. Plugins that have a specific update process are not uncommon, :MasonUpdate comes to mind. But most plugins place their update step after the initial loading of the plugin, for example you run :MasonUpdate after running require('mason').setup() and as such most of the package managers I have use use a similar structure. Where as coq_nvim requires (assuming a new install) :COQdeps being executed before :COQnow ( which seems equivalent to setup() for all intents and purposes ). This makes automating the initial setup process for coq_nvim functionally impossible with some of the current popular package managers.

Things I have attempted to resolve this on my end:

  • Run vim.cmd.COQdeps() in a pcall. This seems to be a naive approach on my part since it would appear vim function calls never return an error unless they don't exist outright. Or at the very least COQdeps() doesn't.

  • Run COQdeps on every single startup. This on face value seems like the solution however COQdeps is very noisy and opens panes. This makes running it on every startup impractical to say the least. If there was some way to run it silently that would make this more practical but I don't know if 'just run COQdeps every time' is a acceptable solution.

Although without looking over the code (and learning a bit more lua) I don't know if there is a implementation reason for the setup process, and for clarity I think COQdeps and COQnow are fine commands for manual setup. Specifically I see two solutions for making automatic installation a little more practical :

  1. Create a setup() function that is functionally equivalent to :COQnow but is silent by default and returns a true or false value, true if coq_nvim was loaded correctly and false if :COQdeps needs to be executed. From here it is fairly trivial to execute :COQdeps when needed. Ideally including a second lua function, something like coq_deps() (unsure what the lua function naming scheme is typically) which silently installs the deps without the opening any panes (this function could also return an error or similar if something goes wrong in this step).

  2. Similar to above, make a setup() function that is functionally equivalent to :COQnow but silent by default. This time however we fold the logic of :COQdeps inside it. Now if coq_nvim detects that it needs its dependencies setup it just does that internally as part of it's initial setup before continuing along as normal.

koshell avatar Jun 26 '23 22:06 koshell

Have you tried using the build (or equivalent) field provided by some plugin managers? It runs some command (on a terminal or an intermal vim command) after a plugin is installed/downloaded. You could use :COQdeps as a build command.

TheLeoP avatar Jul 10 '23 21:07 TheLeoP

I think my code config could help u U just have to install a lsp and you're done it work for me soo why not you try it out

https://gitlab.com/Watynecc/config-files

-- lsp
vim.g.coq_settings = {
    auto_start = 'shut-up',
    clients = {
        tmux = { enabled = false },
        buffers = {
            enabled = false,
        }
    },
}
require("mason").setup()
require("mason-lspconfig").setup_handlers({
     function (server_name) -- default handler (optional)
        require("lspconfig")[server_name].setup(require('coq').lsp_ensure_capabilities({}))
     end
})

Watynecc avatar Nov 04 '23 19:11 Watynecc