1
0
Fork 0
dotfiles/config/nvim/nifoc/statusline.fnl

63 lines
2 KiB
Text
Raw Normal View History

2022-04-05 19:57:44 +00:00
(let [mod {}
web-devicons (require :nvim-web-devicons)]
(fn buffer-not-empty? []
(not= (vim.fn.empty (vim.fn.expand "%:t")) 1))
(fn buffer-variable-exists? [key]
(and (buffer-not-empty?) (not= (. vim.b key) nil)))
(fn maybe-insert-git-status [format value result]
(when (and (not= value nil) (> value 0))
(table.insert result (string.format format value))))
(fn mod.line-column []
(let [line (tostring (vim.fn.line "."))
column (tostring (vim.fn.col "."))]
(string.format "%3s:%-3s" line column)))
(fn mod.current-line-percent []
(let [current-line (vim.fn.line ".")
total-lines (vim.fn.line "$")]
(if (= current-line 1) :Top
(= current-line total-lines) :Bot
"%2p%%")))
(fn mod.filetype []
(let [name (vim.fn.expand "%:t")
extension (vim.fn.expand "%:e")
ftype vim.bo.filetype]
(if (> (ftype:len) 0) (let [icon (web-devicons.get_icon name extension
{:default true})]
(.. ftype " " icon))
"no ft")))
2022-05-04 13:03:51 +00:00
(fn mod.gitsigns-diff-source []
(let [signs vim.b.gitsigns_status_dict]
(when signs
{:added signs.added :modified signs.changed :removed signs.removed})))
2022-04-05 19:57:44 +00:00
(fn mod.current-function []
2022-05-01 19:52:10 +00:00
(let [ctx vim.b.nifoc_lsp_current_context]
(if (and (not= ctx nil) (> (ctx:len) 0)) ctx "")))
2022-04-05 19:57:44 +00:00
(fn mod.spell-enabled? []
(if (and (buffer-not-empty?) vim.wo.spell) "ﮒ" ""))
(fn mod.fixer-enabled? []
(if (or (buffer-variable-exists? :nifoc_lsp_formatter_enabled)
(not= (vim.opt_local.formatprg:get) "")) "" ""))
2022-04-05 19:57:44 +00:00
(fn mod.treesitter-enabled? []
(if (buffer-variable-exists? :nifoc_treesitter_enabled) "" ""))
(fn mod.lsp-enabled? []
(if (buffer-variable-exists? :nifoc_lsp_enabled) "" ""))
2022-05-07 21:31:42 +00:00
(fn mod.extension-telescope []
{:filetypes [:TelescopePrompt]
:sections {:lualine_a [(fn []
:Telescope)]}})
2022-04-05 19:57:44 +00:00
mod)