Steal some of drusks changes to feline config

This commit is contained in:
elkowar 2021-10-13 08:13:23 +02:00
parent 4abaf5a870
commit ec67bebca0
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F

View file

@ -10,6 +10,8 @@
feline-lsp feline.providers.lsp} feline-lsp feline.providers.lsp}
require-macros [macros]}) require-macros [macros]})
(set vim.opt.termguicolors true)
(local modes (local modes
{:n {:text "NORMAL" :color colors.neutral_aqua} {:n {:text "NORMAL" :color colors.neutral_aqua}
:i {:text "INSERT" :color colors.neutral_yellow} :i {:text "INSERT" :color colors.neutral_yellow}
@ -29,27 +31,19 @@
:V {:text "VISUAL LINE" :color colors.neutral_blue} :V {:text "VISUAL LINE" :color colors.neutral_blue}
"" {:text "VISUAL BLOCK" :color colors.neutral_blue}}) "" {:text "VISUAL BLOCK" :color colors.neutral_blue}})
;(def bar-bg colors.dark1)
(def bar-bg colors.dark0) (def bar-bg colors.dark0)
(def horiz-separator-color colors.light1)
(defn or-empty [x] (or x "")) (defn or-empty [x] (or x ""))
(defn spaces [x] (if x (.. " " x " ") "")) (defn spaces [x] (if x (.. " " x " ") ""))
(defn get-current-filepath [] (defn get-current-filepath []
(let [file (utils.shorten-path (vim.fn.bufname) 5 50)] (let [file (utils.shorten-path (vim.fn.bufname) 5 30)]
(if (a.empty? file) "" (if (a.empty? file) ""
nvim.bo.readonly (.. "RO " file) nvim.bo.readonly (.. "RO " file)
(and nvim.bo.modifiable nvim.bo.modified) (.. file " ●") (and nvim.bo.modifiable nvim.bo.modified) (.. file " ●")
(.. file " ")))) (.. file " "))))
(defn lsp-diagnostic-component [kind color]
{:enabled #(~= 0 (vim.lsp.diagnostic.get_count 0 kind))
:provider #(spaces (vim.lsp.diagnostic.get_count 0 kind))
:left_sep ""
:right_sep ""
:hl {:fg bar-bg :bg color}})
(defn vim-mode-hl [use-as-fg?] (defn vim-mode-hl [use-as-fg?]
(let [color (. modes (vim.fn.mode) :color)] (let [color (. modes (vim.fn.mode) :color)]
(if use-as-fg? {:bg bar-bg :fg color} {:bg color :fg bar-bg}))) (if use-as-fg? {:bg bar-bg :fg color} {:bg color :fg bar-bg})))
@ -58,6 +52,8 @@
(or-empty (utils.keep-if #(~= "master" $1) (or-empty (utils.keep-if #(~= "master" $1)
(?. vim.b :gitsigns_status_dict :head)))) (?. vim.b :gitsigns_status_dict :head))))
(defn vim-mode []
(.. " " (or (. modes (vim.fn.mode) :text) vim.fn.mode) " "))
(defn lsp-progress-provider [] (defn lsp-progress-provider []
(let [msgs (vim.lsp.util.get_progress_messages) (let [msgs (vim.lsp.util.get_progress_messages)
@ -66,34 +62,53 @@
(.. msg.title " " msg.message)))] (.. msg.title " " msg.message)))]
(or-empty (str.join " | " s)))) (or-empty (str.join " | " s))))
(defn lsp-diagnostic-component [kind color]
{:enabled #(~= 0 (vim.lsp.diagnostic.get_count 0 kind))
:provider #(spaces (vim.lsp.diagnostic.get_count 0 kind))
:left_sep ""
:right_sep ""
:hl {:fg bar-bg :bg color}})
(defn coordinates []
(let [[line col] (vim.api.nvim_win_get_cursor 0)]
(.. " #" line " ")))
; Fills the bar with an horizontal line
(defn inactive-separator-provider []
(if (not= (vim.fn.winnr) (vim.fn.winnr :j))
(string.rep "─" (vim.api.nvim_win_get_width 0))
""))
(def components {:active {} :inactive {}}) (def components {:active {} :inactive {}})
(tset components.active 1 (tset components.active 1
[{:provider #(.. " " (or (. modes (vim.fn.mode) :text) vim.fn.mode) " ") [{:provider vim-mode :hl #(vim-mode-hl false)}
:hl #(vim-mode-hl false)}
{:provider get-current-filepath :left_sep " "} {:provider get-current-filepath :left_sep " "}
{:provider git-status-provider :left_sep " " :hl #(vim-mode-hl true)}]) {:provider git-status-provider :left_sep " " :hl #(vim-mode-hl true)}])
(tset components.active 2 (tset components.active 2
[{:provider lsp-progress-provider [{:provider lsp-progress-provider
:left_sep " "
:right_sep " "
:enabled #(< 0 (length (vim.lsp.buf_get_clients)))}]) :enabled #(< 0 (length (vim.lsp.buf_get_clients)))}])
(tset components.active 3 (tset components.active 3
[{:provider #vim.bo.filetype [{:provider vim.bo.filetype :right_sep " " :hl #(vim-mode-hl true)}
:hl #(vim-mode-hl true) (lsp-diagnostic-component "Information" colors.neutral_green)
:right_sep " "} (lsp-diagnostic-component "Hint" colors.neutral_aqua)
(lsp-diagnostic-component "Information" colors.neutral_purple) (lsp-diagnostic-component "Warning" colors.neutral_yellow)
(lsp-diagnostic-component "Hint" colors.neutral_blue)
(lsp-diagnostic-component "Warn" colors.neutal_yellow)
(lsp-diagnostic-component "Error" colors.neutral_red) (lsp-diagnostic-component "Error" colors.neutral_red)
{:provider #(let [[line col] (vim.api.nvim_win_get_cursor 0)] (.. " " line ":" col " ")) {:provider coordinates :hl #(vim-mode-hl false)}])
:hl #(vim-mode-hl false)}])
(tset components.inactive 1
[{:provider inactive-separator-provider
:hl {:bg "NONE" :fg horiz-separator-color}}])
(feline.setup (feline.setup
{:colors {:bg bar-bg {:colors {:fg colors.dark4 :bg colors.dark0}
:fg colors.dark4} :default_hl {:inactive
{:fg horiz-separator-color
:bg "NONE"}}
:components components}) :components components})