1
0
Fork 0

nvim: Add fileformat and encoding to heirline

This commit is contained in:
Daniel Kempkens 2022-05-25 23:21:25 +02:00
parent f99d9a48e5
commit 014898f41f
2 changed files with 34 additions and 27 deletions

View file

@ -125,8 +125,18 @@
(let [ft vim.bo.filetype] (let [ft vim.bo.filetype]
(if (> (ft:len) 0) ft "no ft"))) (if (> (ft:len) 0) ft "no ft")))
:hl {:fg colors.white}}) :hl {:fg colors.white}})
(set mod.encoding {:provider (fn []
(let [vim-enc (if (not= vim.bo.fenc nil)
vim.bo.fenc
vim.o.enc)
enc (if (> (vim-enc:len) 0) vim-enc
"no enc")]
(.. enc " ")))
:hl {:fg colors.white}})
(set mod.filetype-block (set mod.filetype-block
(heirline-utils.insert mod.filetype-block mod.file-icon mod.filetype)) (heirline-utils.insert mod.filetype-block mod.file-icon mod.filetype
{:provider " | " :hl {:fg colors.white}}
mod.encoding))
;; git ;; git
(set mod.git {:condition heirline-conditions.is_git_repo (set mod.git {:condition heirline-conditions.is_git_repo
:init (fn [self] :init (fn [self]
@ -209,29 +219,26 @@
ctx))) ctx)))
:hl {:fg colors.white}}) :hl {:fg colors.white}})
;; Buffer Options ;; Buffer Options
(set mod.buffer-options {:init (fn [self] (set mod.buffer-options
(set self.has-options? {:static {:format {:dos "" :unix "" :mac ""}}
(or (buffer-variable-exists? :nifoc_lsp_enabled) :hl {:fg colors.black :bg colors.orange}
(buffer-variable-exists? :nifoc_treesitter_enabled) 1 {:provider " "}
vim.wo.spell))) 2 {:provider (fn []
:hl {:fg colors.black :bg colors.orange} (when (buffer-variable-exists? :nifoc_lsp_enabled)
1 {:condition (fn [self] " "))}
self.has-options?) 3 {:provider (fn []
:provider " "} (when (or (buffer-variable-exists? :nifoc_lsp_formatter_enabled)
2 {:provider (fn [] (not= (vim.opt_local.formatprg:get) ""))
(when (buffer-variable-exists? :nifoc_lsp_enabled) " "))}
" "))} 4 {:provider (fn []
3 {:provider (fn [] (when (buffer-variable-exists? :nifoc_treesitter_enabled)
(when (or (buffer-variable-exists? :nifoc_lsp_formatter_enabled) " "))}
(not= (vim.opt_local.formatprg:get) 5 {:provider (fn []
"")) (when vim.wo.spell
" "))} "暈"))}
4 {:provider (fn [] 6 {:provider (fn [self]
(when (buffer-variable-exists? :nifoc_treesitter_enabled) (let [f vim.bo.fileformat]
" "))} (.. (. self :format f) " ")))}})
5 {:provider (fn []
(when vim.wo.spell
"暈"))}})
;; Position ;; Position
(set mod.position (set mod.position
{:init (fn [self] {:init (fn [self]

View file

@ -73,11 +73,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1653497002, "lastModified": 1653508182,
"narHash": "sha256-L2kb16MAU59LIEWq7ODNsz5AHw5B5Dn9DNaKJF8pG/M=", "narHash": "sha256-yiy/CqoDdy9Z+FuAgftPrSJgiDDnJJEbJ5c4gXNLaW8=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "2c8489e57a04c913ba9e029cc2849a4bbac9673b", "rev": "51ea4217f724c049fde3d29a6aaa77ed2707c4ba",
"type": "github" "type": "github"
}, },
"original": { "original": {