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

Output format #412

Closed
WscriChy opened this issue Nov 8, 2013 · 9 comments
Closed

Output format #412

WscriChy opened this issue Nov 8, 2013 · 9 comments

Comments

@WscriChy
Copy link

WscriChy commented Nov 8, 2013

Is it possible or is it planned to change the output format of the plugin.

Example:

Now I have each line like <buffer number> <some flags> <path>/<filename> (<time>)

Is it possible to change this patter, for example, to [<filename>] <path> ?

Thanks,

@Shougo
Copy link
Owner

Shougo commented Nov 9, 2013

You can change output format by unite-filters.
:help unite-filters

@WscriChy
Copy link
Author

WscriChy commented Nov 9, 2013

As I understood unite-filters controls content of search. Am I wrong?
But I am talking about changing the view of the records in the output list.

@Shougo
Copy link
Owner

Shougo commented Nov 10, 2013

No.
unite-filters can change candidates abbr. It is not only to control contents of search.
So you can change output format.

@WscriChy
Copy link
Author

Any hints or small example, please?

@Shougo
Copy link
Owner

Shougo commented Nov 11, 2013

It is converter_file_directory in autoload/unite/filters/converter_file_directory.vim. It changes candidates' abbr.

@osyo-manga
Copy link
Collaborator

@WscriChy

Like this?

let s:filters = {
\   "name" : "my_converter",
\}

function! s:filters.filter(candidates, context)
    for candidate in a:candidates
        let bufname = bufname(candidate.action__buffer_nr)
        let filename = fnamemodify(bufname, ':p:t')
        let path = fnamemodify(bufname, ':p:h')

        " Customize output format.
        let candidate.abbr = printf("[%s] %s", filename, path)
    endfor
    return a:candidates
endfunction

call unite#define_filter(s:filters)
unlet s:filters


call unite#custom#source('buffer', 'converters', 'my_converter')

@Shougo
Copy link
Owner

Shougo commented Nov 11, 2013

Yes.

@WscriChy
Copy link
Author

Great! Thanks.

@ReneFroger
Copy link

@osyo-manga, after a year, your code is useful for me too! Just wanted to say thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants