Coder Social home page Coder Social logo

Disabling folding about wiki.vim HOT 10 CLOSED

GordianDziwis avatar GordianDziwis commented on July 29, 2024
Disabling folding

from wiki.vim.

Comments (10)

lervag avatar lervag commented on July 29, 2024

I'm sorry, but I don't quite follow. Could you please explain what you want to achieve?

from wiki.vim.

lervag avatar lervag commented on July 29, 2024

I never enable folds in this plugin, I just set the foldmethod. If you don't want folds, you can either disable them globally with set nofoldenable in your vimrc, or for wiki files with autocmd Filetype wiki set nofoldenable.

from wiki.vim.

GordianDziwis avatar GordianDziwis commented on July 29, 2024

I tried it with a minimal init.vim

set nocompatible              " be iMproved, required
filetype off                  " required
call plug#begin('~/.vim/bundle')
Plug 'lervag/wiki.vim'
call plug#end()
syntax on
filetype plugin indent on    " required

let g:wiki_root = '~/Cloud/wiki/'
set nofoldenable
autocmd Filetype wiki set nofoldenable

And the wiki is still folded. I thought it was the plugin, because the filetype stuff gets sourced after the init.vim

from wiki.vim.

lervag avatar lervag commented on July 29, 2024

Sorry, this was actually a bug. In the code that opens a wiki link, I do normal! zMzvzz to focus the link target, but zM enables folds. I was not aware. I've fixed this now.

from wiki.vim.

rattletat avatar rattletat commented on July 29, 2024

Hi @lervag, is it possible that you overwrite the foldlevel user option? Using the index command (and this Focusing part), foldlevel=0 is forced.

Maybe something like this would be better:

" Focus
  if &foldenable
    if l:same_file || &foldlevel > 0
      normal! zv
    else
      normal! zMzv
    endif
  endif

However, I'm not sure why you close all folds by default in the first place. Isn't it done automatically?

from wiki.vim.

lervag avatar lervag commented on July 29, 2024

Good questions.

However, I'm not sure why you close all folds by default in the first place. Isn't it done automatically?

No, not necessarily. That is, people could use different foldlevel settings. But I do agree that the current version overrides this!

Perhaps it is better to fully avoid the zM. People could use the autocmd event to customize if they want a different behaviour, after all.

I'd like more opinions on this. @jabirali for instance, what do you think?

Note: I've accepted your suggested change as a bugfix.

from wiki.vim.

jabirali avatar jabirali commented on July 29, 2024

Sorry about the late reply... I've been a lot sick lately, so haven't kept up with my notifications :).

I'd like more opinions on this. @jabirali for instance, what do you think?

Personally, I think I like the same behaviour as you: I like that folding allows me to only see the relevant parts of the file, and I believe the zMzv solution fits well with that workflow.

If you do keep this behaviour, perhaps the snippet of @rattletat can be generalized to all fold levels? Quickly checking the docs, it seems like replacing zMzv by zx is the most correct solution, and seems to be supported on both Vim and Neovim?

If you decide to remove the zM part, I think it could be nice to mention briefly how to set it up again in the documentation :).

from wiki.vim.

lervag avatar lervag commented on July 29, 2024

replacing zMzv by zx is the most correct solution

The docs for zx:

							*zx*
zx		Update folds: Undo manually opened and closed folds: re-apply
		'foldlevel', then do "zv": View cursor line.
		Also forces recomputing folds.  This is useful when using
		'foldexpr' and the buffer is changed in a way that results in
		folds not to be updated properly.

I'm not so sure if this is right, though. In the l:same_file || &foldlevel > 0 case, we don't want to disturb the manually changed folds, only to ensure that the current line is visible (i.e. zv). In the other case, we know that &foldlevel = 0, which means zx should behave the same as zMzv, right? Thus, this proposed change does not really change anything? Or did I miss something?

Or did you mean to change the entire snippet and do zx in all cases? I don't like that, because e.g. navigation inside the same file should not close other open folds.

Perhaps, though, that this is better (and what you meant)?

    if l:same_file
      normal! zv
    else
      normal! zx
    endif

Opinions, @rattletat and @jabirali?

If you decide to remove the zM part, I think it could be nice to mention briefly how to set it up again in the documentation :).

Agreed, will do that if I make the change.

from wiki.vim.

jabirali avatar jabirali commented on July 29, 2024

Indeed, that's what I meant :).

Having a different behavior for l:same_file is not the issue. I was mainly thinking that I like the current zMzv behaviour, but think it would be ideal if wiki.vim behaved roughly the same way for foldlevel=0 and foldlevel>0.

My understanding of the documentation is that replacing zMzv with zx allows you to handle all fold levels with the same code (as in the code snippet you posted), and provide a consistent behavior.

from wiki.vim.

lervag avatar lervag commented on July 29, 2024

Agreed, thanks. I'll update accordingly.

from wiki.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.