馃 a tiny, customizable statusline for neovim
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 2d41df65f2ea311423f0d4eff8e217387ac4cbec 72 lines 2.0 kB view raw
1local M = {} 2 3---@type table<'normal'|'visual'|'command'|'insert', vim.api.keyset.highlight> 4local default_hls = { 5 normal = { link = "MiniIconsAzure" }, 6 visual = { link = "MiniIconsPurple" }, 7 command = { link = "MiniIconsOrange" }, 8 insert = { link = "MiniIconsGrey" }, 9} 10 11function M.inithls() 12 local utils = require("lylla.utils") 13 vim.iter(pairs(default_hls)):each(function(mode, defaulthl) 14 local name = utils.get_modehl_name(mode) 15 16 local hl = require("lylla.config").get().hls[mode] 17 if hl then 18 vim.api.nvim_set_hl(0, name, hl) 19 return 20 end 21 22 if vim.tbl_isempty(vim.api.nvim_get_hl(0, { name = name })) then 23 vim.api.nvim_set_hl(0, name, defaulthl) 24 end 25 end) 26end 27 28function M.resethl() 29 local utils = require("lylla.utils") 30 vim.iter(pairs(default_hls)):each(function(mode, _) 31 local name = utils.get_modehl_name(mode) 32 vim.api.nvim_set_hl(0, name, {}) 33 end) 34end 35 36function M.init() 37 vim.api.nvim_create_autocmd("WinNew", { 38 group = vim.api.nvim_create_augroup("lylla:win:new", { clear = true }), 39 callback = function() 40 local win = vim.api.nvim_get_current_win() 41 require("lylla.statusline"):new(win):init() 42 end, 43 }) 44 local win = vim.api.nvim_get_current_win() 45 require("lylla.statusline"):new(win):init() 46 47 vim.api.nvim_create_autocmd("WinClosed", { 48 group = vim.api.nvim_create_augroup("lylla:close", { clear = true }), 49 callback = function(ev) 50 local stl = require("lylla.statusline").wins[ev.match] 51 if stl then 52 stl:close() 53 end 54 end, 55 }) 56 57 vim.api.nvim_create_autocmd("ColorSchemePre", { 58 group = vim.api.nvim_create_augroup("lylla:resethl", { clear = true }), 59 callback = function() 60 M.resethl() 61 end, 62 }) 63 vim.api.nvim_create_autocmd("ColorScheme", { 64 group = vim.api.nvim_create_augroup("lylla:inithls", { clear = true }), 65 callback = function() 66 M.inithls() 67 end, 68 }) 69 M.inithls() 70end 71 72return M