0

I'm trying to customize a plugin and I want to know if there's a way to just set a single option without calling setup, or to change an option after setup has been called.

local actions = require('telescope.actions')
local telescope = require('telescope')

telescope.setup{
    pickers = {
        find_files = {
            hidden = true,
            find_command = {
                'rg',
                '--color=never',
                '--files',
                '--no-ignore',
                '--iglob',
                '!.git',
                '--iglob',
                '!node_modules/**/*',
                '--iglob',
                '!.idea/',
                '--iglob',
                '!dist/'
            }
        }
    },
    defaults = {
        mappings = {
            i = {
                ["<A-j>"] = function () actions.move_selection_next(vim.api.nvim_get_current_buf()) end,
                ["<A-k>"] = function () actions.move_selection_previous(vim.api.nvim_get_current_buf()) end
            }
        },
        vimgrep_arguments = {
            'rg',
            '--color=never',
            '--no-heading',
            '--with-filename',
            '--line-number',
            '--column',
            '--smart-case',
            '--iglob',
            '!.git',
            '--iglob',
            '!node_modules/**/*',
            '--iglob',
            '!.idea/',
            '--iglob',
            '!dist/',
            '-u'
        },

    }
}

telescope.load_extension('projects')

Is there an way to change the find_files setting, ideally using lua, without calling setup again? A use case would be changing a single setting if a certain file is opened.

3
  • 1
    Welcome to Vi and Vim! My intuition is that each lua plugin provides it's own setup function, which happens (?) to be a convention, not a requirement. So for each plugin you would need to find out what is available to dynamically adjust any settings.
    – D. Ben Knoble
    Jul 21, 2022 at 14:25
  • 1
    That is my understanding as well. I thought there might be a similar convention for changing settings. In the case of telescope, the only other option I could find is passing custom arguments to the commands on each call, which isn't ideal.
    – WillOw
    Jul 21, 2022 at 14:40
  • 1
    For the settings you’ve posted, you might be interested in learning how to use the default vimgrep and grep commands. Especially the latter can be customized using grepprg to use, eg, ripgrep (which is what i do)
    – D. Ben Knoble
    Jul 21, 2022 at 16:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.