anuvyklack / pretty-fold.nvim

Foldtext customization in Neovim
Apache License 2.0
436 stars 21 forks source link

Current Treesitter Updates crashes neovim with this plugin and Telescope #18

Open danielnehrig opened 2 years ago

danielnehrig commented 2 years ago

related: https://github.com/nvim-treesitter/nvim-treesitter/issues/2633 (though issue is not bound to rust specificly)

danielnehrig commented 2 years ago

minimal lua to reproduce the issue

-- File To reproduce issues with a minimal setup
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-treesitter/nvim-treesitter",
      },
      {
        "anuvyklack/pretty-fold.nvim",
        config = function()
          require("pretty-fold").setup({
            keep_indentation = false,
            fill_char = "━",
            sections = {
              left = {
                "━ ",
                function()
                  return string.rep("*", vim.v.foldlevel)
                end,
                " ━┫",
                "content",
                "┣",
              },
              right = {
                "┫ ",
                "number_of_folded_lines",
                ": ",
                "percentage",
                " ┣━━",
              },
            },
          })
          require("pretty-fold").ft_setup("cpp", {
            process_comment_signs = false,
            comment_signs = {
              "/**", -- c++ doxygen comments
            },
            stop_words = {
              "%s%*", -- a space and star char
              "@brief%s*", -- '@brief' and any number of spaces after
              -- or in sigle pattern:
              -- '%*%s*@brief%s*', -- * -> any number of spaces -> @brief -> all spaces after
            },
          })
          require("pretty-fold").ft_setup("javascriptreact", {
            process_comment_signs = false,
            comment_signs = {
              "/**", -- c++ doxygen comments
            },
            stop_words = {
              "%s%*", -- a space and star char
              "@brief%s*", -- '@brief' and any number of spaces after
              -- or in sigle pattern:
              -- '%*%s*@brief%s*', -- * -> any number of spaces -> @brief -> all spaces after
            },
          })
          require("pretty-fold").ft_setup("typescript", {
            process_comment_signs = false,
            comment_signs = {
              "/**", -- c++ doxygen comments
            },
            stop_words = {
              "%s%*", -- a space and star char
              "@brief%s*", -- '@brief' and any number of spaces after
              -- or in sigle pattern:
              -- '%*%s*@brief%s*', -- * -> any number of spaces -> @brief -> all spaces after
            },
          })
          require("pretty-fold").ft_setup("typescriptreact", {
            process_comment_signs = false,
            comment_signs = {
              "/**", -- c++ doxygen comments
            },
            stop_words = {
              "%s%*", -- a space and star char
              "@brief%s*", -- '@brief' and any number of spaces after
              -- or in sigle pattern:
              -- '%*%s*@brief%s*', -- * -> any number of spaces -> @brief -> all spaces after
            },
          })
          require("pretty-fold").ft_setup("typescript", {
            process_comment_signs = false,
            comment_signs = {
              "/**", -- c++ doxygen comments
            },
            stop_words = {
              "%s%*", -- a space and star char
              "@brief%s*", -- '@brief' and any number of spaces after
              -- or in sigle pattern:
              -- '%*%s*@brief%s*', -- * -> any number of spaces -> @brief -> all spaces after
            },
          })
          require("pretty-fold.preview").setup({ border = "rounded" })
        end,
      },
      -- 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()
  local telescope = require("telescope")
  local action_set = require("telescope.actions.set")
  telescope.setup({
    pickers = {
      find_files = {
        hidden = true,
        attach_mappings = function(_)
          action_set.select:enhance({
            post = function()
              vim.cmd(":normal! zx")
            end,
          })
          return true
        end,
      },
    },
    defaults = {
      prompt_prefix = "🔍 ",
      selection_caret = "> ",
      entry_prefix = "  ",
      initial_mode = "insert",
      selection_strategy = "reset",
      sorting_strategy = "descending",
      layout_strategy = "horizontal",
      file_sorter = require("telescope.sorters").get_generic_sorter,
      file_ignore_patterns = { ".git/", "node_modules", "__snapshots_-" },
      generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
      winblend = 0,
      border = {},
      borderchars = {
        "─",
        "│",
        "─",
        "│",
        "╭",
        "╮",
        "╯",
        "╰",
      },
      color_devicons = true,
      use_less = true,
      set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
      file_previewer = require("telescope.previewers").vim_buffer_cat.new,
      grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
      qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
      -- Developer configurations: Not meant for general override
      buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
    },
  })
  vim.wo.foldmethod = "expr"
  vim.wo.foldexpr = "nvim_treesitter#foldexpr()"
  vim.wo.foldnestmax = 3
  vim.wo.foldminlines = 1

  vim.keymap.set(
      { "n" },
      "<space>ff",
      ":Telescope find_files<CR>",
      {
        silent = true,
      }
    )
  require("nvim-treesitter.configs").setup({
    ensure_installed = {"lua"}, -- 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 commented 2 years ago

disabling the plugin in the minimal lua will not crash neovim