[2024-10-04] nvim custom status bar, minor updates to
alacritty
This commit is contained in:
parent
4f8211dc18
commit
5684f8c6ec
9 changed files with 169 additions and 28 deletions
|
@ -18,16 +18,19 @@ status_components.active[1][1] = {
|
|||
}
|
||||
end,
|
||||
left_sep = { str = 'block' },
|
||||
right_sep = { str = 'block' },
|
||||
-- Use the name of the mode instead of the icon
|
||||
icon = ''
|
||||
}
|
||||
status_components.active[1][2] = {
|
||||
provider = 'git_branch',
|
||||
right_sep = 'block'
|
||||
left_sep = 'block',
|
||||
icon = ''
|
||||
}
|
||||
status_components.active[1][3] = {
|
||||
provider = 'lsp_client_names'
|
||||
provider = 'lsp_client',
|
||||
left_sep = 'block',
|
||||
icon = '',
|
||||
update = {'WinClosed','BufDelete'}
|
||||
}
|
||||
status_components.active[3][1] = {
|
||||
provider = 'battery',
|
||||
|
@ -44,7 +47,8 @@ status_components.active[3][3] = {
|
|||
local custom_providers = {
|
||||
time = function()
|
||||
local time = tostring(vim.fn.strftime('%H:%M'))
|
||||
return ' ' .. time
|
||||
--return ' ' .. time
|
||||
return time
|
||||
end,
|
||||
word_count = function()
|
||||
if vim.api.nvim_buf_get_option(0, 'filetype') == 'markdown' then
|
||||
|
@ -59,13 +63,27 @@ local custom_providers = {
|
|||
battery = function()
|
||||
return require('battery').get_status_line()
|
||||
end,
|
||||
lsp_progress = function()
|
||||
--if not lsp.is_lsp_attached() then return ' LSP ' end
|
||||
return string.format(' %s ', require('lsp-progress').progress())
|
||||
lsp_client = function()
|
||||
local clients = vim.lsp.buf_get_clients()
|
||||
if next(clients) ~= nil then
|
||||
local name = string.format('%s',clients[1].name)
|
||||
--if name == 'matlab_ls' then
|
||||
-- local root = clients[1].root_dir
|
||||
-- local sandbox = root:match(".+/([^/]+)$")
|
||||
-- local handle = io.popen('p4 opened | grep tnrCRCDecode | sed \'s/^[^#]*//g\'')
|
||||
-- local result = handle:read("*a")
|
||||
-- return string.format('%s -> %s%s',name,result,sandbox)
|
||||
--else
|
||||
return name
|
||||
--end
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
}
|
||||
status_config.components = status_components
|
||||
status_config.custom_providers = custom_providers
|
||||
status_config.highlight_reset_triggers = {'ColorScheme'}
|
||||
require('feline').setup(status_config)
|
||||
-- Initialize the win_components table
|
||||
local win_components = {
|
||||
|
@ -81,14 +99,12 @@ win_components.active[1][1] = {
|
|||
provider = {
|
||||
name = 'file_info',
|
||||
opts = {
|
||||
type = 'unique',
|
||||
type = 'unique'
|
||||
}
|
||||
},
|
||||
left_sep = {
|
||||
str = 'block'
|
||||
},
|
||||
right_sep = { str = 'block' }
|
||||
}
|
||||
icon = '',
|
||||
left_sep = 'block'
|
||||
}
|
||||
win_components.active[1][2] = {
|
||||
provider = 'file_size',
|
||||
left_sep = 'block',
|
||||
|
|
|
@ -4,6 +4,7 @@ require('lspconfig').matlab_ls.setup(
|
|||
coq.lsp_ensure_capabilities({
|
||||
cmd = { "node", os.getenv("HOME") .. "/MATLAB-language-server/out/index.js", "--stdio" },
|
||||
root_dir = util.root_pattern('mw_anchor'),
|
||||
single_file_support = true,
|
||||
settings = {
|
||||
MATLAB = {
|
||||
indexWorkspace = false,
|
||||
|
|
65
nvim/lua/plugins/statusline.lua
Normal file
65
nvim/lua/plugins/statusline.lua
Normal file
|
@ -0,0 +1,65 @@
|
|||
local M = {}
|
||||
|
||||
M.modeMap = {
|
||||
n = "NORMAL", i = "INSERT", R = "REPLACE", v = "VISUAL", V = "V-LINE", [''] = "V-BLOCK",
|
||||
c = "COMMAND", s = "SELECT", S = "S-LINE", [''] = "S-BLOCK", t = "TERMINAL"
|
||||
}
|
||||
|
||||
GetMode = function()
|
||||
local m = vim.api.nvim_get_mode().mode
|
||||
return M.modeMap[m] .. " "
|
||||
end
|
||||
|
||||
GetDate = function()
|
||||
return tostring(vim.fn.strftime('%Y-%m-%d'))
|
||||
end
|
||||
|
||||
GetTime = function()
|
||||
local time = tostring(vim.fn.strftime('%H:%M:%S'))
|
||||
return time
|
||||
end
|
||||
|
||||
GetLSP = function()
|
||||
local clients = vim.lsp.buf_get_clients()
|
||||
if next(clients) ~= nil then
|
||||
local name = string.format('%s',clients[1].name)
|
||||
local root = clients[1].root_dir
|
||||
if name == 'matlab_ls' and root ~= nil then
|
||||
local sandbox = root:match(".+/([^/]+)$")
|
||||
--local handle = io.popen('p4 opened | grep tnrCRCDecode | sed \'s/^[^#]*//g\'')
|
||||
--local result = handle:read("*a")
|
||||
return string.format('[%s -> %s]',name,sandbox)
|
||||
else
|
||||
return "[" .. name .. "] "
|
||||
end
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
|
||||
GetGitStatus = function()
|
||||
local signs = vim.b.gitsigns_status_dict or {head = '', added = 0, changed = 0, removed = 0}
|
||||
local inRepo = signs.head ~= ''
|
||||
|
||||
return inRepo and string.format(
|
||||
'[%s: +%s ~%s -%s] ',
|
||||
signs.head, signs.added, signs.changed, signs.removed
|
||||
) or ''
|
||||
end
|
||||
|
||||
function M.statusline()
|
||||
local sline = " "
|
||||
sline = sline .. GetMode() .. GetGitStatus() .. GetLSP() .. "%=" .. GetDate() .. " " .. GetTime() .. " "
|
||||
return sline
|
||||
end
|
||||
|
||||
function M.winbar()
|
||||
return "%< %f %y%h%m%r%=%-5.(L%l C%c%V%) %P "
|
||||
end
|
||||
|
||||
local timer = vim.uv.new_timer()
|
||||
timer:start(0, 10000, vim.schedule_wrap(function()
|
||||
vim.cmd("let &stl=&stl")
|
||||
end))
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue