h1mesuke/unite-outline

Foldmarker Support & Argument to Force Outline Certain Filetype

Opened this issue · 6 comments

I just found this very handy tool. Great Job!

One thing I notice that is missing is fold marker support! It should be easy to parse based on &fmr. Will you consider to add it?

And how to force outline to use filetype other than current &ft. For example, I have a document containing some markdown style headers but it is not a strict markdown file. Unite outline:markdown does not work.

One thing I notice that is missing is fold marker support!

unite-outline has supported it already. Try :Unite outline:foldings
However, it is still experimental and not satisfactory for me, so I haven't written its document yet.

And how to force outline to use filetype other than current &ft. For example, I have a document containing some markdown style headers but it is not a strict markdown file. Unite outline:markdown does not work.

I'll add it to the todo list.

I just tried :Unite outline:foldings. AS you said, it is still experimental. Two problems I found so far:

  1. It seems not working when the {{{1 has text afterwards.
  2. It does not differentiate levels of foldmarkers

Hope this would be solved soon. Thanks for your quick response!

hmm...

Have you set 'foldenable' and 'foldmethod' options correctly?
unite-outline uses foldlevel() to extract foldings, so it doesn't work unless these options are set on your buffer.

unite-outline uses foldlevel() to extract foldings, so it doesn't work unless these options are set on your buffer.

foldlevel() works just fine. But the headings will only be generated from the fisrt level 1 → n. The next level 1 heading is ignored.

For example,

Level 1
     Level 2
          Level 3
Level 1
     Level 2

Only

Level 1
    Level 2
        Level 3

shows up.

Sorry. I found that the problem can't be solved as long as it uses foldlevel() to find foldings.
I seem to have to find another way...

I'll add the foldmarker support to the todo list. It will be solved by considering foldmarker as a pseudo filetype.

I am using the following code to outline my vimrc (foldmarker={{{,}}}, foldmethod=marker)

let g:unite_source_outline_info = {}
let g:unite_source_outline_info.vim = { 'heading': '^\".*[{]\{3}' }
function! g:unite_source_outline_info.vim.create_heading(which, heading_line, matched_line, context)
    let level = foldlevel(a:context.matched_lnum)
    let heading = { 'word': substitute(a:matched_line, '^"\|[{]\{3}', '', 'g'), 'level' : level }
    return heading
endfunction

Here is how it looks:

image

I don't use {{{level syntax although it doesn't make any difference (in current implementation level is just appended at the end of the heading text). The function just deletes ^" and {{{ in order to supply heading text so you can use comments both before and after {{{.

Your undocumented option doesn't present any levels.