2021-04-03 18:34:15 +00:00
|
|
|
|
(module plugins.galaxyline
|
|
|
|
|
{require {a aniseed.core
|
2021-05-10 13:53:33 +00:00
|
|
|
|
str aniseed.string
|
2021-04-03 18:34:15 +00:00
|
|
|
|
fennel aniseed.fennel
|
|
|
|
|
nvim aniseed.nvim
|
|
|
|
|
utils utils
|
2021-05-08 18:18:22 +00:00
|
|
|
|
colors colors
|
2021-04-03 18:34:15 +00:00
|
|
|
|
|
|
|
|
|
galaxyline galaxyline
|
|
|
|
|
gl-condition galaxyline.condition
|
|
|
|
|
gl-fileinfo galaxyline.provider_fileinfo
|
|
|
|
|
gl-diagnostic galaxyline.provider_diagnostic
|
|
|
|
|
gl-vcs galaxyline.provider_vcs}
|
|
|
|
|
|
|
|
|
|
require-macros [macros]})
|
|
|
|
|
|
2021-05-09 15:43:05 +00:00
|
|
|
|
(def- bar-bg-col colors.dark1)
|
|
|
|
|
|
2021-04-03 18:34:15 +00:00
|
|
|
|
(local modes
|
2021-05-02 15:15:33 +00:00
|
|
|
|
{:n {:text "NORMAL" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:i {:text "INSERT" :colors {:bg colors.neutral_yellow :fg colors.dark0}}
|
2021-05-10 13:53:33 +00:00
|
|
|
|
:c {:text "CMMAND" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
2021-05-02 15:15:33 +00:00
|
|
|
|
:ce {:text "NORMEX" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:cv {:text "EX" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:ic {:text "INSCOMP" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:no {:text "OP-PENDING" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:r {:text "HIT-ENTER" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:r? {:text "CONFIRM" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:R {:text "REPLACE" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:Rv {:text "VIRTUAL" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:s {:text "SELECT" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:S {:text "SELECT" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:t {:text "TERM" :colors {:bg colors.neutral_aqua :fg colors.dark0}}
|
|
|
|
|
:v {:text "VISUAL" :colors {:bg colors.neutral_blue :fg colors.dark0}}
|
|
|
|
|
:V {:text "VISUAL LINE" :colors {:bg colors.neutral_blue :fg colors.dark0}}
|
|
|
|
|
"" {:text "VISUAL BLOCK" :colors {:bg colors.neutral_blue :fg colors.dark0}}})
|
2021-04-03 18:34:15 +00:00
|
|
|
|
|
2021-05-10 13:53:33 +00:00
|
|
|
|
(fn get-current-filename []
|
|
|
|
|
(nvim.fn.expand "%:t"))
|
2021-04-03 18:34:15 +00:00
|
|
|
|
|
2021-05-10 13:53:33 +00:00
|
|
|
|
(fn get-current-filepath []
|
|
|
|
|
(let [file (utils.shorten-path (vim.fn.bufname) 5 50)]
|
2021-05-02 15:15:33 +00:00
|
|
|
|
(if (a.empty? file) ""
|
|
|
|
|
nvim.bo.readonly (.. "RO " file)
|
|
|
|
|
(and nvim.bo.modifiable nvim.bo.modified) (.. file " ")
|
|
|
|
|
file)))
|
2021-04-03 19:21:12 +00:00
|
|
|
|
|
2021-04-03 18:34:15 +00:00
|
|
|
|
(set galaxyline.short_line_list ["dbui" "diff" "peekaboo" "undotree" "vista" "vista_markdown"])
|
|
|
|
|
|
2021-04-03 19:21:12 +00:00
|
|
|
|
(fn make-lsp-diagnostic-provider [kind]
|
2021-04-03 18:34:15 +00:00
|
|
|
|
(fn []
|
|
|
|
|
(let [n (vim.lsp.diagnostic.get_count 0 kind)]
|
2021-04-03 19:21:12 +00:00
|
|
|
|
(if (= n 0) "" (.. " " n " ")))))
|
2021-04-03 18:34:15 +00:00
|
|
|
|
|
2021-05-10 13:53:33 +00:00
|
|
|
|
|
|
|
|
|
(set galaxyline.section.left
|
|
|
|
|
[{:ViMode {:provider
|
|
|
|
|
#(let [vim-mode (nvim.fn.mode)
|
|
|
|
|
modedata (or (. modes vim-mode)
|
|
|
|
|
{:text vim-mode
|
|
|
|
|
:colors {:bg colors.neutral_orange :fg colors.dark0}})]
|
|
|
|
|
(utils.highlight "GalaxyViMode" modedata.colors)
|
|
|
|
|
(.. " " modedata.text " "))}}
|
|
|
|
|
|
|
|
|
|
{:FileName {:provider get-current-filepath
|
|
|
|
|
:highlight [colors.light4 bar-bg-col]}}
|
|
|
|
|
|
|
|
|
|
{:Space {:provider #""
|
|
|
|
|
:highlight [colors.light0 bar-bg-col]}}])
|
|
|
|
|
|
2021-04-03 18:34:15 +00:00
|
|
|
|
(set galaxyline.section.right
|
2021-05-10 13:53:33 +00:00
|
|
|
|
[{:GitBranch {:highlight [colors.light4 bar-bg-col]
|
|
|
|
|
:provider
|
|
|
|
|
#(let [branch (gl-vcs.get_git_branch)]
|
|
|
|
|
(if (= "master" branch) "" branch))}}
|
|
|
|
|
|
|
|
|
|
{:FileType {:provider #nvim.bo.filetype
|
2021-05-09 15:43:05 +00:00
|
|
|
|
:highlight [colors.neutral_aqua bar-bg-col]}}
|
2021-04-03 18:34:15 +00:00
|
|
|
|
|
2021-05-02 15:15:33 +00:00
|
|
|
|
{:DiagnosticInfo {:provider (make-lsp-diagnostic-provider "Info")
|
|
|
|
|
:highlight [colors.dark1 colors.neutral_blue]}}
|
|
|
|
|
{:DiagnosticWarn {:provider (make-lsp-diagnostic-provider "Warning")
|
|
|
|
|
:highlight [colors.dark1 colors.neutral_yellow]
|
|
|
|
|
:separator ""}}
|
|
|
|
|
{:DiagnosticError {:provider (make-lsp-diagnostic-provider "Error")
|
|
|
|
|
:highlight [colors.dark1 colors.bright_red]
|
|
|
|
|
:separator ""}}
|
2021-05-10 13:53:33 +00:00
|
|
|
|
{:LineInfo {:provider #(.. " " (gl-fileinfo.line_column) " ")
|
2021-05-02 15:15:33 +00:00
|
|
|
|
:highlight "GalaxyViMode"
|
|
|
|
|
:separator ""}}])
|
2021-04-03 18:34:15 +00:00
|
|
|
|
|
|
|
|
|
(do
|
|
|
|
|
(fn add-segment-defaults [data]
|
2021-05-09 15:43:05 +00:00
|
|
|
|
(a.merge {:highlight [colors.light0 bar-bg-col]
|
2021-05-02 15:15:33 +00:00
|
|
|
|
:separator " "
|
|
|
|
|
:separator_highlight "StatusLine"}
|
|
|
|
|
data))
|
2021-04-03 18:34:15 +00:00
|
|
|
|
|
|
|
|
|
(fn map-gl-section [f section]
|
|
|
|
|
(icollect [_ elem (ipairs section)]
|
2021-05-02 15:15:33 +00:00
|
|
|
|
(collect [k v (pairs elem)]
|
|
|
|
|
(values k (f v)))))
|
2021-04-03 18:34:15 +00:00
|
|
|
|
|
|
|
|
|
(set galaxyline.section.left (map-gl-section add-segment-defaults galaxyline.section.left))
|
|
|
|
|
(set galaxyline.section.right (map-gl-section add-segment-defaults galaxyline.section.right)))
|
2021-05-09 15:43:05 +00:00
|
|
|
|
|
|
|
|
|
|
2021-05-10 13:53:33 +00:00
|
|
|
|
|
|
|
|
|
|