nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.84k stars 835 forks source link

Using telescope disables some neovim settings #377

Closed jacksonludwig closed 3 years ago

jacksonludwig commented 3 years ago

Description

If using Telescope to open the first file after opening neovim, a number of vim settings do not take effect. For example, I have number/relative numbers set in my init.lua, but when opening a file for the first time with Telescope, there are no line numbers.

Expected Behavior

All of my settings are used when opening a file through telescope.

Actual Behavior

Various settings, such as line numbers, expandtab, and list, are disabled even though I have them set to be enabled. However, many settings still work, such as undofile, colorscheme, keybindings, etc.

Details

Reproduce 1. Use a config with Telescope and some options set (the example config with just ``set number relativenumber`` was enough for me to see the problem) 2. open neovim 3. run something like ``lua require("telescope.builtin").find_files()`` 4. open a file
Environment - nvim version: v0.5.0-dev, build type release, LuaJIT 2.1.0-beta3 - Operating system: NixOS - Telescope commit: f15af583ebdce3c1b89cdfec05664c84e3d3ff51
Configuration

```viml set nocompatible hidden laststatus=2 if !filereadable('/tmp/plug.vim') silent !curl --insecure -fLo /tmp/plug.vim \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim endif source /tmp/plug.vim call plug#begin('/tmp/plugged') Plug 'nvim-lua/popup.nvim' Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim' call plug#end() autocmd VimEnter * PlugClean! | PlugUpdate --sync | close set number relativenumber lua << EOF require('telescope').setup{ defaults = { vimgrep_arguments = { 'rg', '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case' }, prompt_position = "bottom", prompt_prefix = ">", selection_strategy = "reset", sorting_strategy = "descending", layout_strategy = "horizontal", layout_defaults = {}, file_ignore_patterns = {}, shorten_path = true, winblend = 0, width = 0.75, preview_cutoff = 120, results_height = 1, results_width = 0.8, border = {}, borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰'}, color_devicons = true, use_less = true, } } EOF ```

elianiva commented 3 years ago

I coudn't reproduce this. https://streamable.com/u540nm

jacksonludwig commented 3 years ago

Okay I think this is actually some strange interaction with https://github.com/mhinz/vim-startify

I did not realize, but startify was being loaded by the minimal init.vim. Once I deleted it I do not get the issue with and without the minimal init.vim.

I am unsure if I should close this issue as I don't know if the source of the issue is in startify or this repo.

elianiva commented 3 years ago

Hmm, I tried it with startify (using your minimal vimrc and my own config) and I still couldn't reproduce it.

jacksonludwig commented 3 years ago

That is very strange, I had this issue on both arch and Nix as well. I don't know what else could cause it, and I still experience it with no config or plugins besides startify + telescope.

kkharji commented 3 years ago

possibly related to https://github.com/nvim-telescope/telescope.nvim/issues/62

Conni2461 commented 3 years ago

Whats most likely happen is that the preview window options leave their window. It happend to me like once every 1000 runs and most of the times with startify. But for me it wasn't really deterministic and since buffer_previewer got introduced it stopped happening at all.

jacksonludwig commented 3 years ago

@Conni2461 yep I think you're right, since there's no line numbers in the previewer, set number? returns no number, and set list? returns no list. I'm still confused as to what is causing it do be deterministic on my end but that seems to be where the issue is coming from.

Conni2461 commented 3 years ago

https://github.com/nvim-telescope/telescope.nvim/issues/207 Should be the correct related issue. I just don't think we can fix that on our side. But also i haven't had that issue when using:

require('telescope').setup {
  defaults = {
    file_previewer = previewers.vim_buffer_cat.new,
    grep_previewer = previewers.vim_buffer_vimgrep.new,
    qflist_previewer = previewers.vim_buffer_qflist.new,
  }
}

It also might be that termopen, which we use to start bat/cat causes option to leave the window. Could you tell me if its better with the other previewers?

jacksonludwig commented 3 years ago

hmm, I still seem to get the same problem when using those previewers.

Conni2461 commented 3 years ago

Hmmm. I am really confused about this because i can't reproduce it with startify. But you can just change the options applied to the vim_buffer_previewers with that:

autocmd User TelescopePreviewerLoaded setlocal number relativenumber wrap list

Maybe that helps but that will also style the previewer differently. if that doesn't help either, I'm completely lost and won't be able to help you :|

ahmedkhalf commented 3 years ago

I coudn't reproduce this. https://streamable.com/u540nm

It happens to me when my window is small and/or font is large with dashboard.nvim

The issues shown above might be of help for reproduction.

ahmedkhalf commented 3 years ago

Furthermore, I'd like to add that one intellectual named @ChristianChiarulli found on a dashboard.nvim issue that removing nobuflisted from the autocommand in autoload/dashboard.vim is a possible, but not ideal workaround. I hope this helps to debug this issue.

ronisbr commented 3 years ago

I am having the same problem! If the terminal is small enough that the preview window of Telescope is not shown in dashboard, then some options are disabled.

ronisbr commented 3 years ago

I just found an "acceptable" workaround until Telescope fix the issue. Add to your telescope configuration:

    layout_defaults = {
      flex = {
        flip_columns = 130
      }
    },
    layout_strategy = 'flex',

Hence, if the window is narrow, then the preview will be shown on top. If the preview window is shown, then this bug does not happen.

aditya-K2 commented 3 years ago

Okay I think this is actually some strange interaction with https://github.com/mhinz/vim-startify

I did not realize, but startify was being loaded by the minimal init.vim. Once I deleted it I do not get the issue with and without the minimal init.vim.

I am unsure if I should close this issue as I don't know if the source of the issue is in startify or this repo.

I had the same Issue uninstalling startify did work, So I can confirm this (this might not be the case for others)

Conni2461 commented 3 years ago

I just merged a commit that should help with nobuflisted (so startify and others).

Big thanks to @l-kershaw

Closing. Feel free to reopen when this issue still persists.