Modified Vim with complete and proper highlighting on folds

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Modified Vim with complete and proper highlighting on folds

Noel Henson
Everyone,

Here is my solution to the constant fold color. It allows a user script to
override the default folded-lines highlighting with whatever you want.  
I have added a new user function called foldhighlight (fdh, for short) that
contains a user script much like foldtext does.

But cooler than just allowing you to do something like:

setlocal foldhighlight=MyFoldHi(v:foldlevel)
" MyFoldHi(level) {{{2
" Determine the fold syntax of a fold.
function! MyFoldHi(level)
        return hlID("Folded".a:level)
endfunction

Which will set the highlight group to Folded0 to Foldedn. You will have to
update your colorscheme to include hl commands for these new highlight
groups.

Or... You can do something even cooler:

setlocal foldhighlight=MyFoldHi(v:foldstart)
" MyFoldHi(fold) {{{2
" Determine the fold syntax of a fold.
function! MyFoldHi(fold)
        return synID(a:fold,1,0)
endfunction

Which will have vim use the highlighting for the fold which is already
specified. In other words, body text will be green, folded or not. Tables
will be darkviolet, folded or not; etc. This way, no additional highlight
specifications are necessary for object we have already defined.

You can download a patched version of (g)vim for testing here:
www.vimoutliner.org/files/vim

For gvim, just ln -s vim gvim

You will also need the attached vo_base file to put into ~/.vim/ftplugin.

Let me know what you think.

Oh, and if you don't want to mess up your current vim. Just put the
downloaded vim somewhere else and call it with ./vim or ./gvim.

Happy VOing

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo

vo_base.vim (19K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Modified Vim with complete and proper highlighting on folds

Noel Henson
Modified patch. There was a bug in foldhidef(); one too many levels of
indirection. It now just returns the HLF_FL constant.

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo

foldhi.patch (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Modified Vim with complete and proper highlighting on folds

Herbert Sitz
Noel Henson wrote
Modified patch. There was a bug in foldhidef(); one too many levels of
indirection. It now just returns the HLF_FL constant.

Noel
Noel  -- Thanks, that looks like a nifty solution.  At one point I had looked into trying to create custom function in eval.c but didn't have the c knowledge to easily grok what was going on.  Still don't, but I'll learn something from trying to figure out how you did it.  I'll look forward to trying this out.  Hopefully it's something they'll accept into vim core.  -- Herb
Reply | Threaded
Open this post in threaded view
|

Re: Modified Vim with complete and proper highlighting on folds

Noel Henson
On Tuesday 15 September 2009, hsitz wrote:

> Noel Henson wrote:
> > Modified patch. There was a bug in foldhidef(); one too many levels of
> > indirection. It now just returns the HLF_FL constant.
> >
> > Noel
>
> Noel  -- Thanks, that looks like a nifty solution.  At one point I had
> looked into trying to create custom function in eval.c but didn't have
> the c knowledge to easily grok what was going on.  Still don't, but I'll
> learn something from trying to figure out how you did it.  I'll look
> forward to trying this out.  Hopefully it's something they'll accept
> into vim core.  -- Herb

Herb,

Let me know when you get ready to try it. I'm going to compile against
newer sources. The 7.2 version has the maximum number of folds set in two
different places and to two different values. Also, I have a bug in the vim
I uploaded. I added a visible function to a function list in
a non-alphabetic way. If you like, I'll even compile a special version of
vim for you.

As far as being accepted into the vim core. I doubt that will happen.  
Nobody on the vim-dev list is interested. I couldn't get any suggestions on
the best way to implement the change and the completed patch has been
completely ignored. I have a feeling that this patch will go the way of
Vince Negri's conceal patch; a great new feature but not enough need.

I'll probably just offer the patch on the VO site for those interested;
apparently just a very few of us VO users.

Hopefully the new way of hoisting will be of more interest.

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo
Reply | Threaded
Open this post in threaded view
|

RE: Modified Vim with complete and proper highlighting on folds

Zdenek Sekera
Noel,

> The 7.2 version has the maximum number of folds set in
> two
> different places and to two different values

What??? That shouldn't be. Did you tell Bram (or vim-dev)?
If not, please do.

Cheers and smiles,


---Zdenek

-----------------------------------------------------
Zdenek Sekera              | [hidden email]
LHC Computing Grid Project | +41 76 487 4971 (mobile)
CERN, IT Department        | +41 22 767 1068 (office)
CH-1211, Geneva 23, Switzerland


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo
Reply | Threaded
Open this post in threaded view
|

Re: Modified Vim with complete and proper highlighting on folds

Noel Henson
On Tuesday 15 September 2009, Zdenek Sekera wrote:

> Noel,
>
> > The 7.2 version has the maximum number of folds set in
> > two
> > different places and to two different values
>
> What??? That shouldn't be. Did you tell Bram (or vim-dev)?
> If not, please do.
>
> Cheers and smiles,
>
>
> ---Zdenek
>

I haven't mentioned it yet. I has probably been fixed in the newer sources.  
I built against 7.2.000. I'm heading out of town on business but when I get
back I want to build against the newest sources. I'll check to see if the
bug is still there.

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo