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

View file

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