danielfalk / smart-open.nvim

Neovim plugin for fast file-finding
MIT License
498 stars 25 forks source link

Add ability to pass in picker options through telescope setup #49

Open dlvhdr opened 10 months ago

dlvhdr commented 10 months ago

I would like to customize smart-open like so:

telescope.setup({
  extensions = {
    smart_open = {
      preview = { hide_on_startup = true },
      layout_config = {
        width = 0.65,
      },
      mappings = {
        i = {
          ["<esc>"] = require("telescope.actions").close,
        },
      },
    },
  },

Many plugins allow passing in these standard telescope picker options

danielfalk commented 3 months ago

This should work on the 0.2.x branch now.

ebkalderon commented 3 months ago

I can't seem to reproduce the config provided by the OP in the 0.2.x branch. The pass-through options appear to be ignored.

Below is the lazy.nvim configuration I used to configure telescope.nvim and smart-open.nvim:

Click to reveal full config ```lua local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath, }) end vim.opt.rtp:prepend(lazypath) require('lazy').setup({ -- spec = "ebk.plugins", { "nvim-telescope/telescope.nvim", event = "VimEnter", dependencies = { "nvim-lua/plenary.nvim", { "nvim-telescope/telescope-fzf-native.nvim", build = "make", cond = function() return vim.fn.executable("make") == 1 end, }, { "danielfalk/smart-open.nvim", branch = "0.2.x", dependencies = { "kkharji/sqlite.lua" }, config = true, }, { "nvim-telescope/telescope-ui-select.nvim" }, { "nvim-tree/nvim-web-devicons" }, }, config = function() require("telescope").setup({ defaults = { file_ignore_patterns = { ".git/", "node_modules/", "target/", "%.gif", "%.jpeg", "%.jpg", "%.png", }, }, extensions = { smart_open = { preview = { hide_on_startup = true }, layout_config = { width = 0.65, }, mappings = { i = { [""] = require("telescope.actions").close, }, }, }, ["ui-select"] = { require("telescope.themes").get_dropdown(), }, }, }) pcall(require("telescope").load_extension, "fzf") pcall(require("telescope").load_extension, "smart_open") pcall(require("telescope").load_extension, "ui-select") local builtin = require("telescope.builtin") vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [h]elp" }) vim.keymap.set("n", "sH", builtin.highlights, { desc = "[S]earch [H]ighlight Groups" }) vim.keymap.set("n", "sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" }) vim.keymap.set("n", "sf", builtin.find_files, { desc = "[S]earch [F]iles" }) vim.keymap.set("n", "ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" }) vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) vim.keymap.set("n", "sr", builtin.resume, { desc = "[S]earch [R]esume" }) vim.keymap.set("n", "s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set("n", "", builtin.buffers, { desc = "[ ] Find existing buffers" }) end, }, }) ```

In fact, it seems as if several smart-open.nvim options aren't being respected anymore with the above Neovim configuration applied (e.g. disable_devicons, show_scores, open_buffer_indicators) but others are (ignore_patterns). Would someone kindly provide a sanity-check?

dlvhdr commented 3 months ago

I'm able to pass in these options which works, so thanks!

ebkalderon commented 3 months ago

Hmm, it seems that extensions.smart_open.mappings = { ... } is being applied for me, using the full config above, but extensions.smart_open.preview.hide_on_startup = true and extensions.smart_open.layout_config.width = 0.65 appear to not be applied. Not sure why this is, exactly. :man_shrugging: Is anyone able to reproduce?