Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folds are not applied when opening with Telescope #1277

Closed
danielnehrig opened this issue Sep 22, 2021 · 11 comments
Closed

Folds are not applied when opening with Telescope #1277

danielnehrig opened this issue Sep 22, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@danielnehrig
Copy link

danielnehrig commented Sep 22, 2021

Description

When opening a file with Telescope folds are not applied
but when opening a file with :e path/to/file.lua folds are applied as they should

note: this is using the treesitter folding method

Neovim version

NVIM v0.5.0
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/config -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/src -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/src/nvim/auto -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/include
Compiled by brew@BigSur

Features: +acl +iconv +tui
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.0/share/nvim"

Run :checkhealth for more info

Operating system and version

big sur 11.2.3 and Arch linux

checkhealth telescope

1 health#telescope#check
 2 ========================================================================
 3 ## Checking for required plugins
 4 ▏ - OK: plenary installed.
 5 ▏ - OK: nvim-treesitter installed.
 6
 7 ## Checking external dependencies
 8 ▏ - OK: rg: found ripgrep 12.1.1
 9 ▏ - OK: fd: found fd 8.2.1
10
11 ## ===== Installed extensions =====
12
13 ## Telescope Extension: `dotfiles`
14 ▏ - INFO: No healthcheck provided
15
16 ## Telescope Extension: `file_create`
17 ▏ - INFO: No healthcheck provided
18
19 ## Telescope Extension: `fzf`
20 ▏ - INFO: No healthcheck provided
21
22 ## Telescope Extension: `project`
23 ▏ - INFO: No healthcheck provided
 1 health#telescope#check
 2 ========================================================================
 3 ## Checking for required plugins
 4 ▏ - OK: plenary installed.
 5 ▏ - OK: nvim-treesitter installed.
 6
 7 ## Checking external dependencies
 8 ▏ - OK: rg: found ripgrep 12.1.1
 9 ▏ - OK: fd: found fd 8.2.1
10
11 ## ===== Installed extensions =====
12
13 ## Telescope Extension: `dotfiles`
14 ▏ - INFO: No healthcheck provided
15
16 ## Telescope Extension: `file_create`
17 ▏ - INFO: No healthcheck provided
18
19 ## Telescope Extension: `fzf`
20 ▏ - INFO: No healthcheck provided
21
22 ## Telescope Extension: `project`
23 ▏ - INFO: No healthcheck provided

Steps to reproduce

  1. nvim -nu minimal.lua
  2. apply folding settings from treesitter
    -- fold settings
    vim.wo.foldmethod = "expr"
    vim.wo.foldexpr = "nvim_treesitter#foldexpr()"
    vim.wo.foldtext =
        [[substitute(getline(v:foldstart),'\\t',repeat('\ ',&tabstop),'g').'...'.trim(getline(v:foldend)) ]]
    vim.wo.fillchars = "fold:\\"
    vim.wo.foldnestmax = 3
    vim.wo.foldminlines = 1
  1. open a file with telescope

Expected behavior

Buffer is folded when buffer is opened

Actual behavior

When buffer is opened the folds are not applied

Minimal config

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])
local package_root = "/tmp/nvim/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
    require("packer").startup({
        {
            "wbthomason/packer.nvim",
            {
                "nvim-telescope/telescope.nvim",
                requires = {
                    "nvim-lua/plenary.nvim",
                    {
                        "nvim-telescope/telescope-fzf-native.nvim",
                        run = "make",
                    },
                },
            },
            {
                "nvim-treesitter/nvim-treesitter",
            },
            -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
        },
        config = {
            package_root = package_root,
            compile_path = install_path .. "/plugin/packer_compiled.lua",
            display = { non_interactive = true },
        },
    })
end
_G.load_config = function()
    require("telescope").setup()
    require("telescope").load_extension("fzf")
    vim.wo.foldmethod = "expr"
    vim.wo.foldexpr = "nvim_treesitter#foldexpr()"
    vim.wo.foldtext =
        [[substitute(getline(v:foldstart),'\\t',repeat('\ ',&tabstop),'g').'...'.trim(getline(v:foldend)) ]]
    vim.wo.fillchars = "fold:\\"
    vim.wo.foldnestmax = 3
    vim.wo.foldminlines = 1

    require("nvim-treesitter.configs").setup({
        ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
        highlight = {
            enable = true,
        },
        indent = {
            enable = true,
        },
        autotag = {
            enable = true,
        },
    })
end
if vim.fn.isdirectory(install_path) == 0 then
    print("Installing Telescope and dependencies.")
    vim.fn.system({
        "git",
        "clone",
        "--depth=1",
        "https://github.com/wbthomason/packer.nvim",
        install_path,
    })
end
load_plugins()
require("packer").sync()
vim.cmd(
    [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
)
@danielnehrig danielnehrig added the bug Something isn't working label Sep 22, 2021
@Conni2461
Copy link
Member

dup of #559

TLDR: i dont know how to fix it and the workaround that worked in the past no longer works.

@Conni2461
Copy link
Member

fixed by #1643 Closing

@Conni2461
Copy link
Member

I had to revert the PR :(

@lervag
Copy link

lervag commented Aug 18, 2022

Any progress here? I'm surprised to see this bug and the lack of interest. Perhaps you have all found a workaround?

@christoph-blessing
Copy link
Contributor

I am using the workaround described here: tmhedberg/SimpylFold#130 (comment)

@lervag
Copy link

lervag commented Aug 18, 2022

Thanks; I found the same solution in #559 as well and it works for me. But it is silly that we need this at all. :\

@DasOhmoff
Copy link

I have the same issue as well

@chaudry-786
Copy link

@lervag I agree. this is also ruining indent lines for me. Can someone please look into it.

@tummetott
Copy link

+1. very annoying

@milanglacier
Copy link
Contributor

milanglacier commented May 4, 2023

I guess this might not be a problem of telescope, and instead it might be a bug of neovim (or treesitter):

this is a minimal example:

suppose I am at my neovim root directory (~/.config/nvim), and I have defined the following command:

vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
vim.keymap.set('i', '<C-x>', function() vim.cmd.edit 'lua/conf/builtin_extend.lua' end)

and typing <C-x> within any file (say init.lua) and then the fold is not activated in the builtin_extend.lua just opened.

It is also worthy to note that telescope plays nicely with set foldmethod=indent.

@Conni2461
Copy link
Member

folds were fixed in #2726 fix is applied to latest master, 0.1.x and the latest stable release 0.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants