TheBB / spaceline

Powerline theme from Spacemacs
GNU General Public License v3.0
536 stars 59 forks source link

Top Bar #22

Open joehillen opened 8 years ago

joehillen commented 8 years ago

I've missed the top bar from the original vim powerline and it turns out it was super easy to add it to spacemacs using spaceline. Maybe you'd be interested in adding this to spaceline and spacemacs.

I have this spaceline-top layer in my spacemacs setup:

(defun spaceline-top/init-spaceline-top ()
  "Initialize spaceline-top"
  (defun spaceline-top-install (left right)
    "Install a top bar given by the lists of segment specs LEFT and RIGHT."
    (setq spaceline-top-left left)
    (setq spaceline-top-right right)
    (spaceline--update-global-excludes)
    (setq-default header-line-format '("%e" (:eval (spaceline--prepare spaceline-top-left spaceline-top-right)))))

  (spaceline-define-segment buffer-fullname
    (if (buffer-file-name)
        (abbreviate-file-name (buffer-file-name))
        (powerline-buffer-id)))

  (spaceline-top-install
   '(((workspace-number window-number)
      :fallback evil-state
      :separator "|"
      :face highlight-face)
     (buffer-modified buffer-fullname remote-host))

   `())
  )

Here's how it looks:

With a file name:

The only thing I wish is that the separators went in the other direction in the top bar, but it looks like that would require a much bigger change to spaceline.

TheBB commented 8 years ago

Somewhat bigger, at least. But yeah, I can add something like this. I doubt it would be by default in Spacemacs (particularly since the semantic layer takes over the header line) but It can be an option for users.

TheBB commented 8 years ago

What info do you want in the header exactly? I can try to make it look not like a carbon copy of the modeline.

joehillen commented 8 years ago

I doubt it would be by default in Spacemacs ... but It can be an option for users.

I was thinking the same.

What info do you want in the header exactly?

I'm happy with what I have in this example. I think it's good to keep it simple. The window number and full filepath are really helpful at the top.

justmytwospence commented 8 years ago

It would also be nice to have a way to to deactivate the entire topbar the same way you can deactivate an single segment. For example if I'm only displaying the path to the current file in the spaceline topbar, I would like to the whole thing to disappear in a buffer that isn't a file (your example displays the buffer-id instead, this is just another possible use case).

joehillen commented 8 years ago

@justmytwospence That's a good idea.

chrissound commented 6 years ago

Can anybody possibly explain how to get the above working? What functions do I need to call?

deb0ch commented 6 years ago

Just copy / pasting his code and then calling the defined function by addind

(spaceline-top/init-spaceline-top)

after it doesn't work ?

@justmytwospence I think you should be able to display that segment you're using to display the full path only when the buffer is visiting a file by adding :when (buffer-file-name) to its config.

chrissound commented 6 years ago

I didn't work for me when I tried. I'm using spacemacs - is there a particular section in the config it should be called from possibly? Thanks for the help.