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 gone after diff #265

Open
mosheavni opened this issue Dec 25, 2024 · 2 comments
Open

folds are gone after diff #265

mosheavni opened this issue Dec 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mosheavni
Copy link

Neovim version (nvim -v | head -n1)

NVIM v0.11.0-dev-1410+gc51bf5a6b2

Operating system/version

macOS 15.2

How to reproduce the issue

cat mini.lua

vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
local temp_dir = vim.uv.os_getenv 'TEMP' or '/tmp'
local package_root = vim.fs.joinpath(temp_dir, 'nvim', 'site', 'lazy')
local lazypath = vim.fs.joinpath(temp_dir, 'nvim', 'site') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim
    .system({
      'git',
      'clone',
      '--filter=blob:none',
      '--single-branch',
      'https://github.com/folke/lazy.nvim.git',
      lazypath,
    }, { text = true })
    :wait()
end
vim.opt.runtimepath:prepend(lazypath)

_G.load_config = function()
  vim.lsp.set_log_level 'trace'
  require('vim.lsp.log').set_format_func(vim.inspect)
  local nvim_lsp = require 'lspconfig'

  -- Add the server that troubles you here
  local name = 'lua_ls'
  local capabilities = vim.lsp.protocol.make_client_capabilities()
  capabilities.textDocument.foldingRange = {
    dynamicRegistration = false,
    lineFoldingOnly = true,
  }

  nvim_lsp[name].setup { capabilities = capabilities }
  require('ufo').setup { open_fold_hl_timeout = 0 }

  print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
end

require('lazy').setup({
  'neovim/nvim-lspconfig',
  {
    'kevinhwang91/nvim-ufo',
    dependencies = { 'kevinhwang91/promise-async' },
    init = function()
      vim.o.foldcolumn = '1'
      vim.o.foldlevel = 99
      vim.o.foldlevelstart = 99
      vim.o.foldenable = true
    end,
  },
}, {
  root = package_root,
})
_G.load_config()

nvim -nu mini.lua

  1. edit any lua file (even the mini.lua one): :e mini.lua
  2. make sure there are folds
  3. run :diffthis
  4. run :diffoff
  5. no folds

Expected behavior

folds should reappear after diff is turned off

Actual behavior

folds are gone after diff

@mosheavni mosheavni added the bug Something isn't working label Dec 25, 2024
@kevinhwang91
Copy link
Owner

The folding state before diffthis can't be restored now, will add a feature to save and restore folding state.

@mosheavni
Copy link
Author

The folding state before diffthis can't be restored now, will add a feature to save and restore folding state.

amazing! it's working now :)

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

2 participants