diff options
| author | Robert Günzler <r@gnzler.io> | 2022-06-15 04:45:05 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-06-15 04:45:25 +0200 |
| commit | ac19dca86b962f1f00a16d0e6688c8f692204926 (patch) | |
| tree | b0f65a95acebd6b9f0e7229b83d3df90ca4f7559 /.vim/lua/statusline.lua | |
| parent | 37e8a51ab0393b2232b9c7594560f29b7b2e0088 (diff) | |
vim: use winbar for file title, free up statusbar
navic/lsp-status/lsp_diagnostics show in the new free spot in the statusbar
Diffstat (limited to '.vim/lua/statusline.lua')
| -rw-r--r-- | .vim/lua/statusline.lua | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/.vim/lua/statusline.lua b/.vim/lua/statusline.lua index e0dc104..3f0856c 100644 --- a/.vim/lua/statusline.lua +++ b/.vim/lua/statusline.lua @@ -1,8 +1,6 @@ local spinner_ok, spinner = pcall(require, 'spinner') -if not spinner_ok then - vim.notify('spinner not found') -else +if spinner_ok then spinner.setup { spinner = {'⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'}, interval = 120, -- spinner frame rate in ms @@ -13,33 +11,36 @@ function _G.statusline() local bufnr = vim.fn.bufnr() or 0 local hi = statusline_color(vim.fn.mode()) - local sl = '' - -- left - sl = sl .. hi + local sl = hi -- sl = sl .. statusline_append([[ ⢷]], '%#StatusLineIcon#', hi) - sl = sl .. statusline_append([[%<%F %-m %-r]], hi, hi) - -- right - sl = sl .. [[ %= ]] -- spacer + sl = sl .. statusline_append(statusline_ts(), + '%#StatusLineTreesitter#', hi) + + sl = sl .. statusline_append(statusline_lsp_diagnostics(bufnr, hi), + '%#StatusLineDiagnostics#', hi) + + sl = sl .. statusline_append(vim.trim(require('lsp-status').status()), + '%#StatusLineLsp#', hi) - sl = sl .. statusline_append(statusline_dap(), '%#StatusLineDap#', hi) - sl = sl .. statusline_append(statusline_notify(hi), '%#StatusLineNotify#', hi) + sl = sl .. statusline_append(statusline_dap(), + '%#StatusLineDap#', hi) - local lsp_status = require('lsp-status').status() - sl = sl .. statusline_append(vim.trim(lsp_status), '%#StatusLineLsp#', hi) + sl = sl .. [[ %= ]] -- spacer + + sl = sl .. statusline_append(statusline_notify(hi), + '%#StatusLineNotify#', hi) if spinner_ok then - local lsp_spinner = spinner.status(bufnr) - sl = sl .. statusline_append(lsp_spinner, '%#StatusLineJobs#', hi) + sl = sl .. statusline_append(spinner.status(bufnr), + '%#StatusLineJobs#', hi) end - local lsp_diagnostics = statusline_lsp_diagnostics(bufnr, hi) - sl = sl .. statusline_append(lsp_diagnostics, '%#StatusLineDiagnostics#', hi) - - local lsp_lightbulb = require('nvim-lightbulb').get_status_text() - sl = sl .. statusline_append(lsp_lightbulb, '%#StatusLineLightbulb#', hi) + sl = sl .. statusline_append(require('nvim-lightbulb').get_status_text(), + '%#StatusLineLightbulb#', hi) sl = sl .. statusline_append([[ %l:%v %y]], hi, hi) + return sl end @@ -98,9 +99,20 @@ function _G.statusline_combine_hi(outer_name, inner_name) vim.api.nvim_set_hl(0, hi, {bg = outer.background, fg = inner.foreground, gui = gui}) return hi end - +function _G.statusline_ts() + local data = require('nvim-navic').get_data() + if not data then return '' end + local s = {} + for i = 1, #data do + table.insert(s, string.format('%%#CmpItemKind%s#%s%%* %%#StatusLine#%s%%*', data[i].type, data[i].icon, data[i].name)) + end + return table.concat(s, ' > ') +end function _G.statusline_dap() - local s = require('dap').status() + local dap_ok, dap = pcall(require, 'dap') + if not dap_ok then return '' end + + local s = dap.status() if s == '' then return s end return '[DAP: ' .. s .. ']' end @@ -230,4 +242,12 @@ vim.keymap.set('n', '<leader>n', function() end) wk_register { ['<leader>n'] = {'notifications'} } -vim.opt.statusline = '%!luaeval("statusline()")' +-- vim.opt.statusline = '%!luaeval("statusline()")' +vim.opt.statusline = '%{%v:lua.statusline()%}' + +-- WINBAR -- +vim.opt.winbar = [[%f %-m %-r]] -- keep it simple +-- function _G.winbar() +-- return [[%<%F %-m %-r]] +-- end +-- vim.opt.winbar = '%{%v:lua.winbar()%}' |