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_l = sep_style[user_sep_style]["left"]
|
||||||
local sep_r = sep_style[user_sep_style]["right"]
|
local sep_r = sep_style[user_sep_style]["right"]
|
||||||
|
|
||||||
local width_below = function(text, thresh)
|
|
||||||
return vim.o.columns / #text >= thresh
|
|
||||||
end
|
|
||||||
|
|
||||||
local modes = {
|
local modes = {
|
||||||
["n"] = { "NORMAL", "St_NormalMode" },
|
["n"] = { "NORMAL", "St_NormalMode" },
|
||||||
["no"] = { "N-PENDING", "St_NormalMode" },
|
["no"] = { "N-PENDING", "St_NormalMode" },
|
||||||
@ -77,8 +73,12 @@ M.fileInfo = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.gps = function()
|
M.gps = function()
|
||||||
local gps_present, gps = pcall(require, "nvim-gps")
|
if vim.o.columns < 140 or not package.loaded["nvim-gps"] then
|
||||||
return gps_present and gps.is_available() and gps.get_location() or ""
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local gps = require "nvim-gps"
|
||||||
|
return (gps.is_available() and gps.get_location()) or ""
|
||||||
end
|
end
|
||||||
|
|
||||||
M.git = function()
|
M.git = function()
|
||||||
@ -101,7 +101,7 @@ end
|
|||||||
M.LSP_progress = function()
|
M.LSP_progress = function()
|
||||||
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
local Lsp = vim.lsp.util.get_progress_messages()[1]
|
||||||
|
|
||||||
if not Lsp then
|
if vim.o.columns < 120 or not Lsp then
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ M.LSP_progress = function()
|
|||||||
local frame = math.floor(ms / 120) % #spinners
|
local frame = math.floor(ms / 120) % #spinners
|
||||||
local content = string.format(" %%<%s %s %s (%s%%%%) ", spinners[frame + 1], title, msg, percentage)
|
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
|
end
|
||||||
|
|
||||||
M.LSP_Diagnostics = function()
|
M.LSP_Diagnostics = function()
|
||||||
@ -137,15 +137,14 @@ end
|
|||||||
M.LSP_status = function()
|
M.LSP_status = function()
|
||||||
local lsp_attached = next(vim.lsp.buf_get_clients()) ~= nil
|
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
|
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
|
end
|
||||||
|
|
||||||
M.cwd = function()
|
M.cwd = function()
|
||||||
local left_sep = "%#ST_EmptySpace2#" .. sep_l .. "%#St_cwd_sep#" .. sep_l
|
local left_sep = "%#ST_EmptySpace2#" .. sep_l .. "%#St_cwd_sep#" .. sep_l
|
||||||
local dir_icon = "%#St_cwd_icon#" .. " "
|
local dir_icon = "%#St_cwd_icon#" .. " "
|
||||||
local dir_name = "%#St_cwd_text#" .. " " .. fn.fnamemodify(fn.getcwd(), ":t") .. " "
|
local dir_name = "%#St_cwd_text#" .. " " .. fn.fnamemodify(fn.getcwd(), ":t") .. " "
|
||||||
|
return (vim.o.columns > 120 and left_sep .. dir_icon .. dir_name) or ""
|
||||||
return left_sep .. dir_icon .. dir_name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
M.cursor_position = function()
|
M.cursor_position = function()
|
||||||
|
Loading…
Reference in New Issue
Block a user