trunacate statusline components on less space
This commit is contained in:
parent
1b5ecdce45
commit
671321e0c8
|
@ -21,10 +21,6 @@ local user_sep_style = require("core.utils").load_config().plugins.options.statu
|
|||
local sep_l = sep_style[user_sep_style]["left"]
|
||||
local sep_r = sep_style[user_sep_style]["right"]
|
||||
|
||||
local width_below = function(text, thresh)
|
||||
return vim.o.columns / #text >= thresh
|
||||
end
|
||||
|
||||
local modes = {
|
||||
["n"] = { "NORMAL", "St_NormalMode" },
|
||||
["no"] = { "N-PENDING", "St_NormalMode" },
|
||||
|
@ -77,8 +73,12 @@ M.fileInfo = function()
|
|||
end
|
||||
|
||||
M.gps = function()
|
||||
local gps_present, gps = pcall(require, "nvim-gps")
|
||||
return gps_present and gps.is_available() and gps.get_location() or ""
|
||||
if vim.o.columns < 140 or not package.loaded["nvim-gps"] then
|
||||
return ""
|
||||
end
|
||||
|
||||
local gps = require "nvim-gps"
|
||||
return (gps.is_available() and gps.get_location()) or ""
|
||||
end
|
||||
|
||||
M.git = function()
|
||||
|
@ -101,7 +101,7 @@ end
|
|||
M.LSP_progress = function()
|
||||
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
||||
|
||||
if not Lsp then
|
||||
if vim.o.columns < 120 or not Lsp then
|
||||
return ""
|
||||
end
|
||||
|
||||
|
@ -113,7 +113,7 @@ M.LSP_progress = function()
|
|||
local frame = math.floor(ms / 120) % #spinners
|
||||
local content = string.format(" %%<%s %s %s (%s%%%%) ", spinners[frame + 1], title, msg, percentage)
|
||||
|
||||
return width_below(content, 5.3) and ("%#St_LspProgress#" .. content) or ""
|
||||
return ("%#St_LspProgress#" .. content) or ""
|
||||
end
|
||||
|
||||
M.LSP_Diagnostics = function()
|
||||
|
@ -137,15 +137,14 @@ end
|
|||
M.LSP_status = function()
|
||||
local lsp_attached = next(vim.lsp.buf_get_clients()) ~= nil
|
||||
local content = lsp_attached and " LSP ~ " .. vim.lsp.get_active_clients()[1].name .. " " or false
|
||||
return content and width_below(content, 5.3) and ("%#St_LspStatus#" .. content) or ""
|
||||
return content and ("%#St_LspStatus#" .. content) or ""
|
||||
end
|
||||
|
||||
M.cwd = function()
|
||||
local left_sep = "%#ST_EmptySpace2#" .. sep_l .. "%#St_cwd_sep#" .. sep_l
|
||||
local dir_icon = "%#St_cwd_icon#" .. " "
|
||||
local dir_name = "%#St_cwd_text#" .. " " .. fn.fnamemodify(fn.getcwd(), ":t") .. " "
|
||||
|
||||
return left_sep .. dir_icon .. dir_name
|
||||
return (vim.o.columns > 120 and left_sep .. dir_icon .. dir_name) or ""
|
||||
end
|
||||
|
||||
M.cursor_position = function()
|
||||
|
|
Loading…
Reference in New Issue