diff options
| author | Robert Günzler <r@gnzler.io> | 2022-04-15 15:08:50 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-04-15 15:09:35 +0200 |
| commit | e9677f2bf9b88001ee063f2c99ef2447bd736fd5 (patch) | |
| tree | 9b84981d83ea40365896b1e20145f0ccd1096a06 /.vim/init.lua | |
| parent | 8480bb95d3a62ee30a1246a99f64e1c87288578d (diff) | |
fixup! vim: move statusline into separate file
Diffstat (limited to '.vim/init.lua')
| -rw-r--r-- | .vim/init.lua | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/.vim/init.lua b/.vim/init.lua index 545afcd..774a098 100644 --- a/.vim/init.lua +++ b/.vim/init.lua @@ -246,77 +246,6 @@ cmd [[ command! -nargs=* Make lua require('job').make({<f-args>}) ]] cmd [[ command! -nargs=* Sh lua require('job').sh(table.concat({<f-args>}, ' ')) ]] -- }}} --- STATUS LINE -- {{{ -require('spinner').setup { - spinner = {'⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'}, - interval = 120, -- spinner frame rate in ms -} -function _G.statusline() - local hi = statusline_color(vim.fn.mode()) - - local sl = '' - -- left - sl = sl .. hi - sl = sl .. statusline_append(' ⢷', '%#StatusLineIcon#', hi) - sl = sl .. [[ %<%F %-m %-r ]] - - -- right - sl = sl .. [[ %= ]] -- spacer - - local lsp_status = require('lsp-status').status() - sl = sl .. statusline_append(vim.trim(lsp_status), '%#StatusLineLsp#', hi) - - local lsp_spinner = require('spinner').status(vim.fn.bufnr()) - sl = sl .. statusline_append(lsp_spinner, '%#StatusLineJobs#', hi) - - local lsp_diagnostics = statusline_lsp_diagnostics(vim.fn.bufnr()) - 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 .. [[ %l:%v %y ]] - return sl -end --- statusline_append --- does item highlighting and conditionnal spacing -function _G.statusline_append(element, hi, default_hi) - if not element or element == '' then return '' end - if not (default_hi == '%*') then hi = '' end - return hi .. element .. default_hi .. ' ' -end -function _G.statusline_color(mode) - local hi = '%*' - if mode == 'i' then - -- hi = '%#StatusLineInsert#' - elseif mode == 'c' then - -- hi = '%#StatusLineCommand#' - elseif mode == 'v' or mode == 'V' or mode == '' then - hi = '%#StatusLineVisual#' - elseif mode == 'R' or mode == 'Rv' then - hi = '%#StatusLineReplace#' - end - -- return '%{g:actual_curwin==win_getid()?'.. hi ..':%#StatusLineNC#}' - return hi -end -function _G.statusline_lsp_diagnostics(bufnr) - -- Error, Warning, Information, Hint - local error_num = vim.diagnostic.get(bufnr, {severity = vim.diagnostic.severity.ERROR}) - local warn_num = vim.diagnostic.get(bufnr, {severity = vim.diagnostic.severity.WARN}) - - local s = '' - if #error_num > 0 then - s = s .. '%#DiagnosticError#' - s = s .. vim.fn.sign_getdefined('DiagnosticSignError')[1].text .. #error_num - end - if #warn_num > 0 then - s = s .. '%#DiagnosticWarn#' - s = s .. vim.fn.sign_getdefined('DiagnosticSignWarn')[1].text .. #warn_num - end - return s -end --- }}} - _G.statusline_enable_notifysend = false require('statusline') |