feat: Allow calling setup again to change configuration #126

Open
jacobsandlund wants to merge 2 commits from jacobsandlund/setup-again into main
jacobsandlund commented 2024-12-30 11:02:09 -05:00 (Migrated from github.com)

This PR adds the ability to call setup again with a different configuration. The use case that prompted this was wanting a way to toggle between using supermaven with cmp or with inline completion.

(For the curious, this is how I'm able to achieve this:)

local function toggle_cmp_or_supermaven()
    local cmp = require('cmp')
    local supermaven = require('supermaven-nvim')
    local current_setting = cmp.get_config().completion.autocomplete
    if current_setting and #current_setting > 0 then
        cmp.setup({ completion = { autocomplete = false } })
        supermaven.setup({
            disable_inline_completion = false,
        })
    else
        cmp.setup({ completion = { autocomplete = { cmp.TriggerEvent.TextChanged } } })
        supermaven.setup({
            disable_inline_completion = true,
        })
    end
end

vim.api.nvim_create_user_command('CmpSupermavenToggle', toggle_cmp_or_supermaven, {})
This PR adds the ability to call `setup` again with a different configuration. The use case that prompted this was wanting a way to toggle between using supermaven with `cmp` or with inline completion. (For the curious, this is how I'm able to achieve this:) ``` lua local function toggle_cmp_or_supermaven() local cmp = require('cmp') local supermaven = require('supermaven-nvim') local current_setting = cmp.get_config().completion.autocomplete if current_setting and #current_setting > 0 then cmp.setup({ completion = { autocomplete = false } }) supermaven.setup({ disable_inline_completion = false, }) else cmp.setup({ completion = { autocomplete = { cmp.TriggerEvent.TextChanged } } }) supermaven.setup({ disable_inline_completion = true, }) end end vim.api.nvim_create_user_command('CmpSupermavenToggle', toggle_cmp_or_supermaven, {}) ```
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin jacobsandlund/setup-again:jacobsandlund/setup-again
git switch jacobsandlund/setup-again

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff jacobsandlund/setup-again
git switch jacobsandlund/setup-again
git rebase main
git switch main
git merge --ff-only jacobsandlund/setup-again
git switch jacobsandlund/setup-again
git rebase main
git switch main
git merge --no-ff jacobsandlund/setup-again
git switch main
git merge --squash jacobsandlund/setup-again
git switch main
git merge --ff-only jacobsandlund/setup-again
git switch main
git merge jacobsandlund/setup-again
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
supermaven-inc/supermaven-nvim!126
No description provided.