diff options
Diffstat (limited to 'fnl')
-rw-r--r-- | fnl/nvrc/colors.fnl | 39 | ||||
-rw-r--r-- | fnl/nvrc/ignite.fnl | 1 | ||||
-rw-r--r-- | fnl/nvrc/pack.fnl | 1 | ||||
-rw-r--r-- | fnl/nvrc/packs/feline.fnl | 114 | ||||
-rw-r--r-- | fnl/nvrc/ui/modules/diagnostics.fnl | 21 | ||||
-rw-r--r-- | fnl/nvrc/ui/modules/misc.fnl | 14 | ||||
-rw-r--r-- | fnl/nvrc/ui/modules/vi_mode.fnl | 40 | ||||
-rw-r--r-- | fnl/nvrc/ui/statusline.fnl | 28 |
8 files changed, 131 insertions, 127 deletions
diff --git a/fnl/nvrc/colors.fnl b/fnl/nvrc/colors.fnl index 074d870..bfc3ebf 100644 --- a/fnl/nvrc/colors.fnl +++ b/fnl/nvrc/colors.fnl @@ -25,6 +25,19 @@ (import-macros {: highlight! : link!} :nvrc.macro.color) (vim.cmd (.. "colorscheme " colorscheme)) + ; Statusline + (highlight! :StatusLine {:fg (. colors :fg) :bg (. colors :bg)}) + (highlight! :StatusLineNC {:fg (. colors :grey) :bg (. colors :black) :underline true}) + (highlight! :StatusLinePad {:fg (. colors :skyblue) :bg (. colors :bg)}) + (highlight! :StatusLineAccent {:fg (. colors :green) :bg (. colors :bg)}) + (highlight! :StatusLineInsertAccent {:fg (. colors :red) :bg (. colors :bg)}) + (highlight! :StatusLineVisualAccent {:fg (. colors :yellow) :bg (. colors :bg)}) + (highlight! :StatusLineReplaceAccent {:fg (. colors :violet) :bg (. colors :bg)}) + (highlight! :StatusLineCmdLineAccent {:fg (. colors :green) :bg (. colors :bg)}) + (highlight! :StatusLineTerminalAccent {:fg (. colors :skyblue) :bg (. colors :bg)}) + (highlight! :StatusLineFile {:fg (. colors :orange) :bg (. colors :bg) :bold true}) + (highlight! :StatusLineFileData {:fg (. colors :magenta) :bg (. colors :bg) :bold true}) + ; Buffer (highlight! :EndOfBuffer {:fg (. colors :bg)}) (highlight! :FloatBorder {:fg (. colors :blue)}) @@ -40,21 +53,15 @@ (highlight! :CmpItemKind {:fg (. colors :fg)}) (highlight! :CmpItemMenu {:fg (. colors :fg)}) - ; Misc - (highlight! :StatusLine {:bg (. colors :bg)}) - (highlight! :StatusLineNC {:fg (. colors :grey) :bg (. colors :black) :underline true}) - (highlight! :TabLine {:fg (. colors :fg) :bg (. colors :mgrey)}) - (highlight! :TabLineFill {:fg (. colors :fg) :bg (. colors :bg)}) - (highlight! :TabLineSel {:fg (. colors :fg) :bg (. colors :grey2)}) - (highlight! :LineNr {:fg (. colors :grey)}) - (highlight! :NvimInternalError {:fg (. colors :red)}) - (highlight! :VertSplit {:fg (. colors :grey2)}) - ; LSP (highlight! :DiagnosticError {:fg (. colors :red)}) (highlight! :DiagnosticWarn {:fg (. colors :yellow)}) - (highlight! :DiagnosticInformation {:fg (. colors :green)}) + (highlight! :DiagnosticInfo {:fg (. colors :green)}) (highlight! :DiagnosticHint {:fg (. colors :grey)}) + (highlight! :DiagnosticSignError {:fg (. colors :red) :bg (. colors :bg)}) + (highlight! :DiagnosticSignWarn {:fg (. colors :yellow) :bg (. colors :bg)}) + (highlight! :DiagnosticSignInfo {:fg (. colors :green) :bg (. colors :bg)}) + (highlight! :DiagnosticSignHint {:fg (. colors :grey) :bg (. colors :bg)}) (highlight! :LspReferenceRead {:underline true}) (highlight! :LspReferenceText {:underline true}) (highlight! :LspReferenceWrite {:underline true}) @@ -70,6 +77,14 @@ (highlight! :LirSymLink {:fg (. colors :grey)}) (highlight! :LirEmptyDirText {:fg (. colors :blue)}) (highlight! :LirFloatCurdirWindowNormal {:bg (. colors :black)}) - (highlight! :LirFloatCurdirWindowDirName {:fg (. colors :skyblue)})) + (highlight! :LirFloatCurdirWindowDirName {:fg (. colors :skyblue)}) + + ; Misc + (highlight! :TabLine {:fg (. colors :fg) :bg (. colors :mgrey)}) + (highlight! :TabLineFill {:fg (. colors :fg) :bg (. colors :bg)}) + (highlight! :TabLineSel {:fg (. colors :fg) :bg (. colors :grey2)}) + (highlight! :LineNr {:fg (. colors :grey)}) + (highlight! :NvimInternalError {:fg (. colors :red)}) + (highlight! :VertSplit {:fg (. colors :grey2)})) colors diff --git a/fnl/nvrc/ignite.fnl b/fnl/nvrc/ignite.fnl index 58f3414..9eab014 100644 --- a/fnl/nvrc/ignite.fnl +++ b/fnl/nvrc/ignite.fnl @@ -2,4 +2,5 @@ (require :nvrc.options) (require :nvrc.keymaps) (require :nvrc.events) +(require :nvrc.ui.statusline) (require :nvrc.pack) diff --git a/fnl/nvrc/pack.fnl b/fnl/nvrc/pack.fnl index 75d222d..61dd2d8 100644 --- a/fnl/nvrc/pack.fnl +++ b/fnl/nvrc/pack.fnl @@ -11,7 +11,6 @@ (pack :nvim-treesitter/nvim-treesitter-refactor {:after :nvim-treesitter}) (pack :nvim-treesitter/nvim-treesitter-textobjects {:after :nvim-treesitter})]}) -(pack! :feline-nvim/feline.nvim {:req :feline}) (pack! :Pocco81/TrueZen.nvim {:cmd :TZAtaraxis}) (pack! :antoinemadec/FixCursorHold.nvim) (pack! :luukvbaal/stabilize.nvim {:init :stabilize}) diff --git a/fnl/nvrc/packs/feline.fnl b/fnl/nvrc/packs/feline.fnl deleted file mode 100644 index fc4a082..0000000 --- a/fnl/nvrc/packs/feline.fnl +++ /dev/null @@ -1,114 +0,0 @@ -(local feline (require :feline)) -(local lsp (require :feline.providers.lsp)) -(local lsp_severity vim.diagnostic.severity) -(local vi_mode (require :feline.providers.vi_mode)) - -(local colors (require :nvrc.colors)) -(local utils (require :nvrc.utils)) - -(local vi_mode_colors {:NORMAL (. colors :green) - :INSERT (. colors :red) - :VISUAL (. colors :yellow) - :OP (. colors :green) - :BLOCK (. colors :skyblue) - :REPLACE (. colors :violet) - :V-REPLACE (. colors :violet) - :ENTER (. colors :skyblue) - :MORE (. colors :skyblue) - :SELECT (. colors :orange) - :COMMAND (. colors :green) - :SHELL (. colors :green) - :TERM (. colors :green) - :NONE (. colors :yellow)}) - -(local modules {:pad {:provider "▊ " :hl {:fg (. colors :skyblue)}} - :current_position {:provider :position - :left_sep " " - :right_sep {1 " " - 2 {:str :vertical_bar_thin - :hl {:fg :fg :bg :bg}}}} - :vi_mode {:provider :vi_mode - :icon "" - :right_sep " " - :hl (fn [] - {:name (vi_mode.get_mode_highlight_name) - :fg (vi_mode.get_mode_color)})} - :file {:info {:provider {:name :file_info - :opts {:file_modified_icon "[+]" - :file_readonly_icon "!w "}} - :icon "" - :right_sep " " - :hl {:fg (. colors :orange) :style :bold}} - :encoding {:provider :file_encoding - :icon "" - :right_sep " " - :hl {:fg (. colors :magenta) :style :bold}} - :type {:provider :file_type - :icon "" - :right_sep " " - :hl {:fg (. colors :magenta) :style :bold}} - :size {:provider :file_size - :right_sep {1 " " - 2 {:str :vertical_bar_thin - :hl {:fg :fg :bg :bg}}}}} - :line_percentage {:provider :line_percentage - :right_sep " " - :hl {:style :bold}} - :scroll_bar {:provider :scroll_bar - :right_sep " " - :hl {:fg (. colors :skyblue) :style :bold}} - :lsp {:name {:provider :lsp_client-names - :icon "" - :right_sep " " - :hl {:fg (. colors :yellow)}} - :diag_err {:provider :diagnostic_errors - :enabled #(lsp.diagnostics_exist lsp_severity.ERROR) - :left_sep " " - :icon :E - :hl {:fg (. colors :red)}} - :diag_warn {:provider :diagnostic_warnings - :enabled #(lsp.diagnostics_exist lsp_severity.WARN) - :left_sep " " - :icon :W - :hl {:fg (. colors :yellow)}} - :diag_info {:provider :diagnostic_info - :enabled #(lsp.diagnostics_exist lsp_severity.INFO) - :left_sep " " - :icon :I - :hl {:fg (. colors :skyblue)}} - :diag_hint {:provider :diagnostic_hints - :enabled #(lsp.diagnostics_exist lsp_severity.HINT) - :left_sep " " - :icon :H - :hl {:fg (. colors :white)}}}}) - -(local comps {:left {:active [(. modules :pad) - (. modules :vi_mode) - (. modules :file :info) - (. modules :file :size) - (. modules :current_position) - (. modules :lsp :diag_err) - (. modules :lsp :diag_warn) - (. modules :lsp :diag_info) - (. modules :lsp :diag_hint)] - :inactive []} - :right {:active [(. modules :file :encoding) - (. modules :file :type) - (. modules :line_percentage) - (. modules :scroll_bar)] - :inactive []}}) - -(local components - {:active [comps.left.active comps.right.active] - :inactive [comps.left.inactive comps.right.inactive]}) - -(local properties - {:force_inactive {:filetypes [:lir :packer] - :buftypes [:terminal :packer]}}) - -(feline.setup {:theme colors - :default_bg (. colors :bg) - :default_fg (. colors :fg) - : components - : properties - : vi_mode_colors}) diff --git a/fnl/nvrc/ui/modules/diagnostics.fnl b/fnl/nvrc/ui/modules/diagnostics.fnl new file mode 100644 index 0000000..a1e2530 --- /dev/null +++ b/fnl/nvrc/ui/modules/diagnostics.fnl @@ -0,0 +1,21 @@ +(fn diagnostics [] + (let [count {} + levels {:errors :Error :warnings :Warn :info :Info :hints :Hint}] + (each [k level (pairs levels)] + (tset count k (vim.tbl_count (vim.diagnostic.get 0 {:severity level})))) + (var errors "") + (var warnings "") + (var hints "") + (var info "") + (when (not= (. count :errors) 0) + (set errors (.. "%#DiagnosticSignError#E" (. count :errors)))) + (when (not= (. count :warnings) 0) + (set warnings + (.. " %#DiagnosticSignWarning#W" (. count :warnings)))) + (when (not= (. count :hints) 0) + (set hints (.. " %#DiagnosticSignHint#H" (. count :hints)))) + (when (not= (. count :info) 0) + (set info (.. " %#DiagnosticSignInformation#I" (. count :info)))) + (.. errors warnings hints info "%#StatusLine#"))) + +{: diagnostics} diff --git a/fnl/nvrc/ui/modules/misc.fnl b/fnl/nvrc/ui/modules/misc.fnl new file mode 100644 index 0000000..24d84f9 --- /dev/null +++ b/fnl/nvrc/ui/modules/misc.fnl @@ -0,0 +1,14 @@ +(fn file-size [] + "feline.nvim's file size calculation module." + (let [suffix [:b :k :M :G :T :P :E]] + (var index 1) + (var fsize (vim.fn.getfsize (vim.api.nvim_buf_get_name 0))) + (when (< fsize 0) + (set fsize 0)) + (while (and (> fsize 1024) (< index 7)) + (set fsize (/ fsize 1024)) + (set index (+ index 1))) + (string.format (or (and (= index 1) "%g%s | ") "%.2f%s | ") fsize + (. suffix index)))) + +{: file-size} diff --git a/fnl/nvrc/ui/modules/vi_mode.fnl b/fnl/nvrc/ui/modules/vi_mode.fnl new file mode 100644 index 0000000..1b9f1a1 --- /dev/null +++ b/fnl/nvrc/ui/modules/vi_mode.fnl @@ -0,0 +1,40 @@ +(local modes {:n :NORMAL + :no :NORMAL + :v :VISUAL + :V "V-LINE" + "\022" "V-BLOCK" + :s :SELECT + :S "L-SELECT" + "\019" "B-SELECT" + :i :INSERT + :ic :INSERT + :R :REPLACE + :Rv "V-REPLACE" + :c :COMMAND + :cv "VIM-EX" + :ce :EX + :r :PROMPT + :rm :MOAR + :r? :CONFIRM + :! :SHELL + :t :TERMINAL}) + +(fn mode [] + (let [current-mode (. (vim.api.nvim_get_mode) :mode)] + (: (string.format "%s " (. modes current-mode)) :upper))) + +(fn update-mode-colors [] + (let [current-mode (. (vim.api.nvim_get_mode) :mode)] + (var mode-color "%#StatuslineAccent#") + (if (= current-mode :n) (set mode-color "%#StatuslineAccent#") + (or (= current-mode :i) (= current-mode :ic)) + (set mode-color "%#StatuslineInsertAccent#") + (or (or (= current-mode :v) (= current-mode :V)) + (= current-mode "\022")) + (set mode-color "%#StatusLineVisualAccent#") (= current-mode :R) + (set mode-color "%#StatusLineReplaceAccent#") (= current-mode :c) + (set mode-color "%#StatusLineCmdLineAccent#") (= current-mode :t) + (set mode-color "%#StatusLineTerminalAccent#")) + mode-color)) + +{: mode : update-mode-colors} diff --git a/fnl/nvrc/ui/statusline.fnl b/fnl/nvrc/ui/statusline.fnl new file mode 100644 index 0000000..49afa7f --- /dev/null +++ b/fnl/nvrc/ui/statusline.fnl @@ -0,0 +1,28 @@ +(import-macros {: setl!} :nvrc.macro.set) +(import-macros {: ag! + : au!} :nvrc.macro.event) + +(local {: mode : update-mode-colors} (require :nvrc.ui.modules.vi_mode)) +(local {: diagnostics} (require :nvrc.ui.modules.diagnostics)) +(local {: file-size} (require :nvrc.ui.modules.misc)) + +(global statusline {}) +(set statusline.enable (fn [] + (table.concat ["%#StatusLinePad#" + "▊ " + "%#StatusLine#" + (update-mode-colors) + (mode) + "%#StatusLineFile#" + "%f%m%r " + "%#StatusLine#" + (file-size) + "%l:%c | " + (diagnostics) + "%=" + "%#StatusLineFileData#" + "%y %n"]))) + +(ag! ui-statusline + (au! [WinEnter BufEnter] * #(setl! statusline "%!v:lua.statusline.enable()")) + (au! [WinLeave BufLeave] * #(setl! statusline ""))) |