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

Basic implementation of a buffer list #1065

Closed
wants to merge 4 commits into from
Closed

Conversation

lenormf
Copy link
Contributor

@lenormf lenormf commented Dec 22, 2016

Hi,

Here's what it looks like (my theme+default):

a

b

c

d

As you can see, the separator is customizable, as well as the faces used to render the bar. A unicode ellipsis is inserted at the beginning/end of the list when there wasn't enough space to print an entire buffer name.

Read the first commit message for all the details.

@lenormf lenormf force-pushed the buflist branch 2 times, most recently from aad6d49 to 424999e Compare December 23, 2016 17:04
@lenormf
Copy link
Contributor Author

lenormf commented Dec 23, 2016

Following the advice of @doppioandante, I've decided not to implement any kind of smart behaviour in the buffer list, the buffers are now displayed from left to right, with no attempts at showing buffers surrounding the active one.

@lisael
Copy link
Contributor

lisael commented Jan 19, 2017

Isn't there a naming clash with %val{buflist} ?

@lenormf
Copy link
Contributor Author

lenormf commented Jan 20, 2017

I don't think so, what makes you say that? The commits merely add an ncurses UI widget, it doesn't interfere with options.

@lisael
Copy link
Contributor

lisael commented Jan 20, 2017

Not technically speaking, but for the user, it may be confusing reading the same name for two different things. (The fact is I had to make an effort to forget about %opt{buflist} while reading the PR. Maybe I used this a lot, recently :) )

@lenormf
Copy link
Contributor Author

lenormf commented May 18, 2017

Branch rebased against 3a0d948, and the second commit has been squashed into the other for easiness of maintainance purposes.

@Delapouite
Copy link
Contributor

Thanks for this PR.

How do you use this buffer list in practice? By using buffer-next and buffer-previous commands?
I tried to analyze my workflow with a similar buffer bar offered by vim. The main difference is that each buffer name in this list is prepended by a number, like so:

1 buffer-foo | 2 buffer-bar | 3 buffer-qux …

This way I've bound key mapping to quickly jump to a specific buffer. Like <a-1>.

Is this something convenient that's worth adding?

@lenormf
Copy link
Contributor Author

lenormf commented May 22, 2017

I consider this more of a widget and a visual representation of kakoune's state than an actual tool. Consequently I don't think I would like to add numbering to the bar, however you can add that feature very easily.

Also you could probably implement the bindings you mention with a shell scope (assuming the buffers in %val{buflist} are in a deterministic order -which I don't know if they are), it should get you pretty close to what you had with vim if combined with numbering.

@Delapouite
Copy link
Contributor

If someone is interested after reading this thread, here's an alternative suggestion by danr, using info

# Buffers (by danr 2017, public domain)
map global normal <a-,> :bp<ret>:bufinfo<ret>
map global normal <a-.> :bn<ret>:bufinfo<ret>
map global normal <a--> ga:bufinfo<ret>
map global normal <a-d> :db<ret>:bufinfo<ret>
map global normal <a-q> :db!<ret>:bufinfo<ret>

def bufinfo %{
    %sh{
        echo -n info -- %^
        (while read -d : buf; do
            if [[ "$buf" == "$kak_bufname" ]]; then
                echo "> $buf <"
            else
                echo "  $buf  "
            fi
        done) <<< "$kak_buflist"
        echo ^
    }
}

https://gist.github.com/danr/e69a55129a3fd27f1f098d4e167afccd

@alexherbo2
Copy link
Contributor

I would like the feedback on buffer change being built-in.

It’s something missing when doing ga or :buffer-next commands.

@Delapouite
Copy link
Contributor

I would like the feedback on buffer change being built-in.

You mean something like a BufChange hook?

@occivink
Copy link
Contributor

What you can do since recently is add

hook global WinDisplay .* bufinfo

in addition to the bufinfo implementation so that you get the popup without having to remap every commands that changes the current buffer.

@alexherbo2
Copy link
Contributor

@Delapouite No, I mean the feedback being built-in.

@lenormf
Copy link
Contributor Author

lenormf commented May 27, 2017

I documented the options/faces added, and rebased on 55d1d10.

@lenormf
Copy link
Contributor Author

lenormf commented Jun 3, 2017

Fixed some issues that glitched the rendering.

@Delapouite
Copy link
Contributor

Here's an alternative solution using external bars like lemonbar : https://github.com/mawww/kakoune/wiki/Bar

@mawww
Copy link
Owner

mawww commented Apr 4, 2018

In my view, #1942 superseeds this PR, and I have no intention to merge this PR, as it is pretty intrusive, closing.

@mawww mawww closed this Apr 4, 2018
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

Successfully merging this pull request may close these issues.

6 participants