complete-computing-environment/doom_modeline.org

3.3 KiB

Doom Modeline

(provide 'cce/doom-modeline)

I'm trying something new, coming back to a modeline customization suite. This time, we find ourselves with the Doom Mode Line, which I use in a pretty "out of the box" configuration for now. I add icon representations for EXWM buffers so that they're not just default "document" icons.

(use-package nerd-icons)
(use-package doom-modeline
  :after nerd-icons
  :custom
  (nerd-icons-font-family "Symbols Nerd Font Mono")
  :config
  (setq doom-modeline-unicode-fallback t
        doom-modeline-enable-word-count nil
        doom-modeline-minor-modes t)
  (doom-modeline-mode 1)
  (add-to-list 'nerd-icons-mode-icon-alist
               '(exwm-mode nerd-icons-faicon "nf-fa-desktop"
                          :height 1.0 :face all-the-icons-purple))
  <<org-titles-modeline>>
  )

org-roam buffer titles in Doom Modeline

This function overrides/extends the function which Doom Modeline uses to set the buffer title in the modeline. It queries the org-roam database for the file's title, and falls back to the 'auto help:doom-modeline-buffer-file-name-style if there isn't one.

(defun doom-modeline-buffer-file-name ()
  "Propertize file name based on `doom-modeline-buffer-file-name-style'."
  (let* ((buffer-file-name (file-local-name (or (buffer-file-name (buffer-base-buffer)) "")))
         (buffer-file-truename (file-local-name
                                (or buffer-file-truename (file-truename buffer-file-name) "")))
         (file-name
          (when (equal major-mode 'org-mode)
            (caar (org-roam-db-query [:select title :from files :where (= file $s1)]
                                     (buffer-file-name)))))
         (file-name-fallback
          (if (doom-modeline-project-p)
              (doom-modeline--buffer-file-name buffer-file-name buffer-file-truename 'shrink 'shrink 'hide)
            (propertize "%b" 'face 'doom-modeline-buffer-file)))
         (file-name
          (propertize (or file-name file-name-fallback) 'face 'doom-modeline-buffer-file)))
    (propertize (if (string-empty-p file-name)
                    (propertize "%b" 'face 'doom-modeline-buffer-file)
                  file-name)
                'mouse-face 'mode-line-highlight
                'help-echo (concat buffer-file-truename
                                   (unless (string= (file-name-nondirectory buffer-file-truename)
                                                    (buffer-name))
                                     (concat "\n" (buffer-name)))
                                   "\nmouse-1: Previous buffer\nmouse-3: Next buffer")
                'local-map mode-line-buffer-identification-keymap)))