dressing.nvim icon indicating copy to clipboard operation
dressing.nvim copied to clipboard

The selector looks too small and broken with telescope backend

Open cryptomilk opened this issue 1 year ago • 0 comments

Describe the bug

The selector UI from dessing for the telescope backend looks strange.

telescope-selector-ui: image

dressing.nvim: image

The size is different, because of how I set up the telescope UI. However dressing produces a broken UI with my settings. Below is a repro.lua file to reproduce it easily.

System information

  • OS: linux
  • Neovim version: 0.10
  • Is this related to a specific vim.ui.select backend? If so, which one? telescope
  • Dressing config:
-- Paste your call to require("dressing").setup(...) in here
require('dressing').setup({})

To Reproduce Steps to reproduce the behavior:

  1. nvim -u repro.lua

repro.lua

-- DO NOT change the paths
local root = vim.fn.fnamemodify('./.repro', ':p')

-- set stdpaths to use .repro
for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
    vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end

-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        'git',
        'clone',
        '--filter=blob:none',
        'https://github.com/folke/lazy.nvim',
        lazypath,
    })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    'cryptomilk/nightcity.nvim',
    -- add any other plugins here
    'nvim-telescope/telescope.nvim',
    'nvim-lua/popup.nvim',
    'nvim-lua/plenary.nvim',
    'stevearc/dressing.nvim',
}
require('lazy').setup(plugins, {
    root = root .. '/plugins',
})

require('nightcity').setup({
    style = 'kabuki', -- The theme comes in two styles: kabuki or afterlife
    terminal_colors = true, -- Use colors used when opening a `:terminal`
    invert_colors = {
        -- Invert colors for the following syntax groups
        cursor = true,
        diff = true,
        error = true,
        search = true,
        selection = false,
        signs = false,
        statusline = true,
        tabline = false,
    },
    font_style = {
        -- Style to be applied to different syntax groups
        comments = { italic = true },
        keywords = { italic = true },
        functions = { bold = true },
        variables = {},
        search = { bold = true },
    },
    -- Plugin integrations. Use `default = false` to disable all integrations.
    plugins = { default = true },
    --- You can override specific highlights to use other groups or a hex color
    --- function will be called with a Highlights and ColorScheme table
    ---@param groups Highlight groups
    ---@param colors ColorScheme
    on_highlights = function(groups, colors) end,
})

vim.cmd.colorscheme('nightcity')
-- add anything else here

local actions = require('telescope.actions')
local action_state = require('telescope.actions.state')
local sorters = require('telescope.sorters')
local previewers = require('telescope.previewers')

local set_prompt_to_entry_value = function(prompt_bufnr)
    local entry = action_state.get_selected_entry()
    if not entry or not type(entry) == 'table' then
        return
    end

    action_state
        .get_current_picker(prompt_bufnr)
        :reset_prompt(entry.ordinal)
end

require('telescope').setup({
    defaults = {
        vimgrep_arguments = {
            '/usr/bin/rg',
            '--hidden',
            '--no-heading',
            '--with-filename',
            '--line-number',
            '--column',
            '--smart-case',
            [[--glob=!.git/*]],
            [[--glob=!node_modules/*]],
        },
        prompt_prefix = '❯ ',
        selection_caret = '❯ ',
        selection_strategy = 'reset',
        sorting_strategy = 'ascending',
        scroll_strategy = 'cycle',
        color_devicons = true,

        file_sorter = sorters.get_fzy_sorter,

        file_previewer = previewers.vim_buffer_cat.new,
        grep_previewer = previewers.vim_buffer_vimgrep.new,
        qflist_previewer = previewers.vim_buffer_qflist.new,

        set_env = { ['COLORTERM'] = 'truecolor' },

        layout_strategy = 'flex',
        layout_config = {
            width = 0.95,
            height = 0.85,
            prompt_position = 'bottom',
            scroll_speed = 1, -- scroll by 1 line in previewer

            horizontal = {
                width = 0.9,
                preview_cutoff = 60,
                preview_width = function(_, cols, _)
                    if cols > 200 then
                        return math.floor(cols * 0.7)
                    else
                        return math.floor(cols * 0.6)
                    end
                end,
            },
            vertical = {
                width = 0.75,
                height = 0.85,
                preview_height = 0.4,
                mirror = true,
            },
            flex = {
                -- change to horizontal after 120 cols
                flip_columns = 120,
            },
        },

        mappings = {
            i = {
                ['<C-x>'] = actions.delete_buffer,
                ['<C-s>'] = actions.select_horizontal,
                ['<C-v>'] = actions.select_vertical,
                ['<C-t>'] = actions.select_tab,

                ['<C-j>'] = actions.move_selection_next,
                ['<C-k>'] = actions.move_selection_previous,
                ['<S-up>'] = actions.preview_scrolling_up,
                ['<S-down>'] = actions.preview_scrolling_down,
                ['<C-up>'] = actions.preview_scrolling_up,
                ['<C-down>'] = actions.preview_scrolling_down,

                -- TODO: look into using 'actions.set.shift_selection'
                ['<C-u>'] = actions.move_to_top,
                ['<C-d>'] = actions.move_to_middle,
                ['<C-b>'] = actions.move_to_top,
                ['<C-f>'] = actions.move_to_bottom,

                ['<M-q>'] = actions.send_to_qflist + actions.open_qflist,
                ['<C-q>'] = actions.send_selected_to_qflist
                    + actions.open_qflist,
                ['<C-y>'] = set_prompt_to_entry_value,

                ['<C-c>'] = actions.close,
            },
            n = {
                ['<CR>'] = actions.select_default + actions.center,
                ['<C-x>'] = actions.delete_buffer,
                ['<C-s>'] = actions.select_horizontal,
                ['<C-v>'] = actions.select_vertical,
                ['<C-t>'] = actions.select_tab,

                ['j'] = actions.move_selection_next,
                ['k'] = actions.move_selection_previous,
                ['<S-up>'] = actions.preview_scrolling_up,
                ['<S-down>'] = actions.preview_scrolling_down,
                ['<C-up>'] = actions.preview_scrolling_up,
                ['<C-down>'] = actions.preview_scrolling_down,

                ['<C-u>'] = actions.move_to_top,
                ['<C-d>'] = actions.move_to_middle,
                ['<C-b>'] = actions.move_to_top,
                ['<C-f>'] = actions.move_to_bottom,

                ['<C-q>'] = actions.send_to_qflist,
                ['<M-q>'] = actions.send_to_qflist + actions.open_qflist,

                ['<C-c>'] = actions.close,
                ['<Esc>'] = false,
            },
        },
    },
})

require('dressing').setup({})

vim.ui.select({ "first", "second", "third" }, {
    prompt = "Make selection: ",
    kind = "test",
  },
  function(item, lnum)
    if item and lnum then
      vim.notify(string.format("selected '%s' (idx %d)", item, lnum), vim.log.levels.INFO)
    else
      vim.notify("Selection canceled", vim.log.levels.INFO)
    end
  end)

Screenshots See above.

cryptomilk avatar Jul 15 '24 11:07 cryptomilk