diff options
| author | Robert Günzler <r@gnzler.io> | 2024-05-15 09:00:31 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2024-05-15 09:00:31 +0200 |
| commit | 3dbe74f2eef627e2dc19b79fe06753d5dc09003f (patch) | |
| tree | b78d1cdab62cec9ed4bbe35447108547b935ef03 /.vim/lua/internal/statusline.lua | |
| parent | 0ab72c1113139c196115c974eadaded449002c32 (diff) | |
update nvim
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.vim/lua/internal/statusline.lua')
| -rw-r--r-- | .vim/lua/internal/statusline.lua | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/.vim/lua/internal/statusline.lua b/.vim/lua/internal/statusline.lua index 9d1ddc7..8ed5cae 100644 --- a/.vim/lua/internal/statusline.lua +++ b/.vim/lua/internal/statusline.lua @@ -7,6 +7,8 @@ function _G.statusline() sl = sl .. [[%-h%-w%-q%-f %-m %-r]] + sl = sl .. statusline_append(statusline_grapple(bufnr), 'StatusLineGrapple', hi) + -- sl = sl .. statusline_append(statusline_ts(), 'StatusLineTreesitter', hi) sl = sl .. [[ %= ]] -- spacer @@ -64,18 +66,16 @@ function _G.statusline_append(element, hi, default_hi, opts) end function _G.statusline_combine_hi(outer_name, inner_name) - local outer = vim.api.nvim_get_hl_by_id(vim.api.nvim_get_hl_id_by_name(outer_name), true) - local inner = vim.api.nvim_get_hl_by_id(vim.api.nvim_get_hl_id_by_name(inner_name), true) - local hi = 'auto' .. outer_name .. inner_name - if pcall(vim.api.nvim_get_hl_by_name, hi, true) then - return hi - end - local gui - gui = inner.bold and 'bold' - gui = inner.italic and 'italic' - gui = inner.underline and 'underline' - vim.api.nvim_set_hl(0, hi, { bg = outer.background, fg = inner.foreground, gui = gui }) - return hi + local outer = vim.api.nvim_get_hl(0, { name = outer_name, create = false }) + local inner = vim.api.nvim_get_hl(0, { name = inner_name, create = false }) + local name = ('auto' .. outer_name .. inner_name) + vim.api.nvim_get_hl(0, + { name = name, create = true }) + local hi = inner + hi.bg = inner.fg + hi.fg = outer.bg + vim.api.nvim_set_hl(0, name, hi) + return name end function _G.statusline_lsp_diagnostics(bufnr, default_hi) @@ -86,20 +86,20 @@ function _G.statusline_lsp_diagnostics(bufnr, default_hi) if #error_num > 0 then local errs = vim.fn.sign_getdefined('DiagnosticSignError')[1].text .. #error_num s = s - .. statusline_append( - errs, - statusline_combine_hi('StatusLineDiagnostics', 'DiagnosticError'), - default_hi - ) + .. statusline_append( + errs, + statusline_combine_hi('StatusLine', 'DiagnosticError'), + default_hi + ) end if #warn_num > 0 then local warns = vim.fn.sign_getdefined('DiagnosticSignWarn')[1].text .. #warn_num s = s - .. statusline_append( - warns, - statusline_combine_hi('StatusLineDiagnostics', 'DiagnosticWarn'), - default_hi - ) + .. statusline_append( + warns, + statusline_combine_hi('StatusLine', 'DiagnosticWarn'), + default_hi + ) end return vim.trim(s) end @@ -128,6 +128,16 @@ function _G.statusline_ts() return table.concat(s, ' > ') end +function _G.statusline_grapple(bufnr) + local g = package.loaded.grapple + if not g then return '' end + return g.statusline() + -- if not g or not g.exists({ buffer = bufnr }) then + -- return '' + -- end + -- return '➥ ' .. g.key({ buffer = bufnr }) +end + function _G.statusline_lspstatus() local lst = package.loaded['lsp-status'] if not lst then @@ -175,12 +185,12 @@ function _G.statusline_notify(default_hi) local s = '' if n.hi then s = s - .. statusline_append( - n.lvl_string .. ' ', - statusline_combine_hi('StatusLineNotify', n.hi), - default_hi, - { append_space = false } - ) + .. statusline_append( + n.lvl_string .. ' ', + statusline_combine_hi('StatusLineNotify', n.hi), + default_hi, + { append_space = false } + ) end s = s .. statusline_append(vim.inspect(n.message), 'StatusLineNotify', default_hi) return vim.trim(s) |