馃 a tiny, customizable statusline for neovim
3
fork

Configure Feed

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

at main 91 lines 2.4 kB view raw
1if vim.g.loaded_lylla then 2 return 3end 4 5vim.g.loaded_lylla = true 6 7local lzrq = function(modname) 8 return vim.defaulttable(function(k) 9 return require(modname)[k] 10 end) 11end 12 13local config = lzrq("lylla.config") 14local utils = lzrq("lylla.utils") 15 16-- highlights ================================================================= 17 18---@type table<'normal'|'visual'|'command'|'insert'|'replace'|'operator', vim.api.keyset.highlight> 19local default_hls = { 20 normal = { link = "@property" }, 21 visual = { link = "@constant" }, 22 command = { link = "@function" }, 23 insert = { link = "@variable" }, 24 replace = { link = "@type" }, 25 operator = { link = "NonText" }, 26} 27 28local function set_hl(name, hl) 29 hl.default = true 30 vim.api.nvim_set_hl(0, name, hl) 31end 32 33local function inithls() 34 vim.iter(pairs(default_hls)):each(function(mode, defaulthl) 35 local hl = config.get().hls[mode] 36 local name, revname = utils.get_modehl_name(mode) 37 if hl then 38 set_hl(name, hl) 39 elseif vim.tbl_isempty(vim.api.nvim_get_hl(0, { name = name })) then 40 set_hl(name, defaulthl) 41 end 42 set_hl(revname, utils.reverse_hl(name)) 43 end) 44end 45 46-- init ======================================================================= 47 48local function init() 49 vim.api.nvim_create_autocmd({ "UIEnter", "WinNew", "WinEnter" }, { 50 group = vim.api.nvim_create_augroup("@lylla.win", { clear = true }), 51 callback = function() 52 local win = vim.api.nvim_get_current_win() 53 if not require("lylla.statusline").wins[win] then 54 require("lylla.statusline"):new(win):init() 55 end 56 end, 57 }) 58 59 vim.api.nvim_create_autocmd("WinClosed", { 60 group = vim.api.nvim_create_augroup("@lylla.close", { clear = true }), 61 callback = function(ev) 62 local stl = require("lylla.statusline").wins[ev.match] 63 if stl then 64 stl:close() 65 end 66 end, 67 }) 68 69 if config.get().tabline ~= vim.NIL then 70 require("lylla.tabline").setup() 71 end 72 73 vim.api.nvim_create_autocmd("ColorScheme", { 74 group = vim.api.nvim_create_augroup("@lylla.hls", { clear = true }), 75 callback = function() 76 inithls() 77 end, 78 }) 79 inithls() 80end 81 82if vim.v.vim_did_enter > 0 then 83 init() 84else 85 vim.api.nvim_create_autocmd("VimEnter", { 86 group = vim.api.nvim_create_augroup("@lylla.init", { clear = true }), 87 callback = function() 88 init() 89 end, 90 }) 91end