aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/heirline.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/plugins/heirline.lua')
-rw-r--r--.config/nvim/lua/plugins/heirline.lua339
1 files changed, 235 insertions, 104 deletions
diff --git a/.config/nvim/lua/plugins/heirline.lua b/.config/nvim/lua/plugins/heirline.lua
index dc415d5..5c3eb44 100644
--- a/.config/nvim/lua/plugins/heirline.lua
+++ b/.config/nvim/lua/plugins/heirline.lua
@@ -43,47 +43,47 @@ local RightSpace = { provider = "" }
local ViMode = {
init = function(self)
self.mode = vim.fn.mode(1)
- if not self.once then
- vim.cmd("au ModeChanged *:*o redrawstatus")
- end
- self.once = true
+ --if not self.once then
+ -- vim.cmd("au ModeChanged *:*o redrawstatus")
+ --end
+ --self.once = true
end,
static = {
mode_names = {
- n = "NORMAL ",
- no = "N·OPERATOR PENDING ",
- nov = "N?",
- noV = "N?",
- ["no\22"] = "N? ",
- niI = "Ni",
- niR = "Nr",
- niV = "Nv",
- nt = "Nt",
- v = "VISUAL ",
- vs = "Vs",
- V = "V·LINE ",
+ n = " NORMAL ",
+ no = "PENDING ",
+ nov = " N? ",
+ noV = " N? ",
+ ["no\22"] = " N? ",
+ niI = " Ni ",
+ niR = " Nr ",
+ niV = " Nv ",
+ nt = "TERMINAL",
+ v = " VISUAL ",
+ vs = " Vs ",
+ V = " V·LINE ",
["\22"] = "V·BLOCK ",
["\22s"] = "V·BLOCK ",
- s = "SELECT ",
- S = "S·LINE ",
+ s = " SELECT ",
+ S = " S·LINE ",
["\19"] = "S·BLOCK ",
- i = "INSERT ",
- ix = "insert x ",
- ic = "insert c ",
+ i = " INSERT ",
+ ix = "insert x",
+ ic = "insert c",
R = "REPLACE ",
- Rc = "Rc",
- Rx = "Rx",
+ Rc = " Rc ",
+ Rx = " Rx ",
Rv = "V·REPLACE ",
- Rvc = "Rv",
- Rvx = "Rv",
+ Rvc = " Rv ",
+ Rvx = " Rv ",
c = "COMMAND ",
- cv = "VIM EX ",
- ce = "EX ",
- r = "PROMPT ",
- rm = "MORE ",
+ cv = " VIM EX ",
+ ce = " EX ",
+ r = " PROMPT ",
+ rm = " MORE ",
["r?"] = "CONFIRM ",
- ["!"] = "SHELL ",
- t = "TERMINAL ",
+ ["!"] = " SHELL ",
+ t = "TERMINAL",
},
},
provider = function(self)
@@ -113,9 +113,8 @@ local LSPActive = {
end,
hl = { fg = colors.lightgray, bold = false },
}
-
local Navic = {
- condition = require("nvim-navic").is_available,
+ condition = function() return require("nvim-navic").is_available() end,
static = {
-- create a type highlight map
type_hl = {
@@ -204,7 +203,7 @@ local Navic = {
provider = function(self)
return self.child:eval()
end,
- hl = { fg = colors.white },
+ hl = { fg = "gray" },
update = 'CursorMoved'
}
@@ -270,7 +269,7 @@ local Git = {
--hl = { fg = "orange" },
hl = { fg = colors.orange, bg = colors.bg },
{
- -- git branch name
+ -- git branch name
provider = function(self)
return " " .. self.status_dict.head
end,
@@ -337,26 +336,69 @@ local Git = {
-- Debugger
-- Display informations from nvim-dap!
-local DAPMessages = {
- -- display the dap messages only on the debugged file
- condition = function()
- local session = require("dap").session()
- if session then
- local filename = vim.api.nvim_buf_get_name(0)
- if session.config then
- local progname = session.config.program
- return filename == progname
- end
- end
- return false
- end,
- provider = function()
- return " " .. require("dap").status()
- end,
- hl = { fg = utils.get_highlight("Debug").fg },
- -- Debugger on_click: step-over, step-into, next, previous, stop buttons
- -- coming soon!
-}
+-- Note that we add spaces separately, so that only the icon characters will be clickable
+--local DAPMessages = {
+-- condition = function()
+-- local session = require("dap").session()
+-- return session ~= nil
+-- end,
+-- provider = function()
+-- return " " .. require("dap").status() .. " "
+-- end,
+-- hl = "Debug",
+-- {
+-- provider = "",
+-- on_click = {
+-- callback = function()
+-- require("dap").step_into()
+-- end,
+-- name = "heirline_dap_step_into",
+-- },
+-- },
+-- { provider = " " },
+-- {
+-- provider = "",
+-- on_click = {
+-- callback = function()
+-- require("dap").step_out()
+-- end,
+-- name = "heirline_dap_step_out",
+-- },
+-- },
+-- { provider = " " },
+-- {
+-- provider = " ",
+-- on_click = {
+-- callback = function()
+-- require("dap").step_over()
+-- end,
+-- name = "heirline_dap_step_over",
+-- },
+-- },
+-- { provider = " " },
+-- {
+-- provider = "ﰇ",
+-- on_click = {
+-- callback = function()
+-- require("dap").run_last()
+-- end,
+-- name = "heirline_dap_run_last",
+-- },
+-- },
+-- { provider = " " },
+-- {
+-- provider = "",
+-- on_click = {
+-- callback = function()
+-- require("dap").terminate()
+-- require("dapui").close({})
+-- end,
+-- name = "heirline_dap_close",
+-- },
+-- },
+-- { provider = " " },
+-- -- icons:       ﰇ  
+--}
-- Tests
-- This requires the great ultest.
@@ -535,7 +577,7 @@ local Spell = {
hl = { bold = true, fg = colors.yellow },
}
-local help_file_name = {
+local HelpFileName = {
condition = function()
return vim.bo.filetype == "help"
end,
@@ -546,9 +588,51 @@ local help_file_name = {
hl = { fg = colors.blue },
}
+local SearchCount = {
+ condition = function()
+ return vim.v.hlsearch ~= 0 and vim.o.cmdheight == 0
+ end,
+ init = function(self)
+ local ok, search = pcall(vim.fn.searchcount)
+ if ok and search.total then
+ self.search = search
+ end
+ end,
+ provider = function(self)
+ local search = self.search
+ return string.format("[%d/%d]", search.current, math.min(search.total, search.maxcount))
+ end,
+}
+
+local MacroRec = {
+ condition = function()
+ return vim.fn.reg_recording() ~= "" and vim.o.cmdheight == 0
+ end,
+ provider = " ",
+ hl = { fg = "orange", bold = true },
+ utils.surround({ "[", "]" }, nil, {
+ provider = function()
+ return vim.fn.reg_recording()
+ end,
+ hl = { fg = "green", bold = true },
+ }),
+ update = {
+ "RecordingEnter",
+ "RecordingLeave",
+ }
+}
+
+local ShowCmd = {
+ condition = function()
+ return vim.o.cmdheight == 0
+ end,
+ provider = ":%3.5(%S%)",
+}
+
local cursor_location = {
- { provider = " %1(%4l:%-3(%c%) %)%*", hl = { fg = colors.black, bold = true } },
+ { provider = " %1(%4l:%-3(%c%) %)%*", hl = { fg = colors.black, bold = true } },
}
+
local Ruler = { cursor_location }
--utils.make_flexible_component(
@@ -635,8 +719,8 @@ FileNameBlock = utils.insert(
FileNameBlock,
FileIcon,
utils.insert(FileNameModifier, FileName), -- a new table where FileName is a child of FileNameModifier
- unpack(FileFlags), -- A small optimisation, since their parent does nothing
- { provider = "%<" } -- this means that the statusline is cut here when there's not enough space
+ unpack(FileFlags), -- A small optimisation, since their parent does nothing
+ { provider = "%<" } -- this means that the statusline is cut here when there's not enough space
)
local FileInfoBlock = {
@@ -679,30 +763,51 @@ local left = {
{ Space, hl = { bg = colors.nobg, force = true } },
{ Git, hl = { bg = colors.nobg, force = true } },
}
+
local middle = {
- { Align, hl = { bg = colors.nobg, force = true } },
- --{ Navic, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
- { DAPMessages, hl = { bg = colors.nobg, force = true } },
- { Align, hl = { bg = colors.nobg, force = true } },
+ { Align, hl = { bg = colors.nobg, force = true } },
+ --{ Navic, hl = { bg = colors.nobg, force = true } },
+ --{ DAPMessages, hl = { bg = colors.nobg, force = true } },
+ { Align, hl = { bg = colors.nobg, force = true } },
}
+
local right = {
- { Space, hl = { bg = colors.nobg, force = true } },
+ --{ Space, hl = { bg = colors.nobg, force = true } },
{ Diagnostics, hl = { bg = colors.nobg, force = true } },
{ Space, hl = { bg = colors.nobg, force = true } },
{ LSPActive, hl = { bg = colors.nobg, force = true } },
{ Space, hl = { bg = colors.nobg, force = true } },
{ FileInfoBlock, hl = { bg = colors.nobg, force = true } },
- { RightSpace, hl = { bg = colors.nobg, force = true } },
+ { RightSpace, hl = { bg = colors.nobg, force = true } },
{ Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
}
local sections = { left, middle, right }
local DefaultStatusline = { sections }
+local specialleft = {
+ { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ { LeftSpace, hl = { bg = colors.nobg, force = true } },
+}
+
+local specialmiddle = {
+ { Align, hl = { bg = colors.nobg, force = true } },
+ --{ DAPMessages, hl = { bg = colors.nobg, force = true } },
+ { Align, hl = { bg = colors.nobg, force = true } },
+}
+
+local specialright = {
+ { RightSpace, hl = { bg = colors.nobg, force = true } },
+ { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+}
+
+local specialsections = { specialleft, specialmiddle, specialright }
+
local InactiveStatusline = {
condition = conditions.is_not_active,
- { FileNameBlock, hl = { bg = colors.nobg, force = true } },
- { Align, hl = { bg = colors.nobg, force = true } },
+ --{ FileNameBlock, hl = { bg = colors.nobg, force = true } },
+ --{ Align, hl = { bg = colors.nobg, force = true } },
+ specialsections
}
local SpecialStatusline = {
@@ -712,44 +817,68 @@ local SpecialStatusline = {
filetype = { "^git.*", "fugitive", "dashboard", },
})
end,
- { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
- { LeftSpace, hl = { bg = colors.nobg, force = true } },
- { Space, hl = { bg = colors.nobg, force = true } },
- { Align, hl = { bg = colors.nobg, force = true } },
- { RightSpace, hl = { bg = colors.nobg, force = true } },
- { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ specialsections
}
+--local InactiveStatusline = SpecialStatusline
+
local TerminalStatusline = {
condition = function()
return conditions.buffer_matches({ buftype = { "terminal" } })
end,
-
- -- Quickly add a condition to the ViMode to only show it when buffer is active!
- --{ condition = conditions.is_active, ViMode, Space },
- { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
- { LeftSpace, hl = { bg = colors.nobg, force = true } },
- { FileNameBlock, hl = { bg = colors.nobg, force = true } },
- { Space, hl = { bg = colors.nobg, force = true } },
- { Align, hl = { bg = colors.nobg, force = true } },
- { RightSpace, hl = { bg = colors.nobg, force = true } },
- { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ specialsections
}
local StatusLine = {
static = {
+ --mode_colors = {
+ -- n = colors.blue,
+ -- i = colors.green,
+ -- v = colors.purple,
+ -- V = colors.purple,
+ -- ["\22"] = colors.purple,
+ -- c = colors.orange,
+ -- s = colors.purple,
+ -- S = colors.purple,
+ -- ["\19"] = colors.purple,
+ -- R = colors.red,
+ -- r = colors.red,
+ -- ["!"] = colors.orange,
+ -- t = colors.orange,
+ --},
mode_colors = {
n = colors.blue,
- i = colors.green,
+ no = colors.blue,
+ nov = colors.blue,
+ noV = colors.blue,
+ ["no\22"] = colors.blue,
+ niI = colors.blue,
+ niR = colors.blue,
+ niV = colors.blue,
+ nt = colors.blue,
v = colors.purple,
+ vs = colors.purple,
V = colors.purple,
["\22"] = colors.purple,
- c = colors.orange,
+ ["\22s"] = colors.purple,
s = colors.purple,
S = colors.purple,
["\19"] = colors.purple,
+ i = colors.green,
+ ix = colors.green,
+ ic = colors.green,
R = colors.red,
+ Rc = colors.red,
+ Rx = colors.red,
+ Rv = colors.red,
+ Rvc = colors.red,
+ Rvx = colors.red,
+ c = colors.orange,
+ cv = colors.orange,
+ ce = colors.orange,
r = colors.red,
+ rm = colors.red,
+ ["r?"] = colors.red,
["!"] = colors.orange,
t = colors.orange,
},
@@ -780,6 +909,7 @@ local WinbarFileNameBlock = {
end,
hl = { bg = colors.bg },
}
+
local WinbarFileName = {
provider = function(self)
-- first, trim the pattern relative to the current directory. For other
@@ -804,8 +934,8 @@ WinbarFileNameBlock = utils.insert(
WinbarFileNameBlock,
FileIcon,
utils.insert(WinbarFileName), -- a new table where FileName is a child of FileNameModifier
- unpack(FileFlags), -- A small optimisation, since their parent does nothing
- { provider = "%<" } -- this means that the statusline is cut here when there's not enough space
+ unpack(FileFlags), -- A small optimisation, since their parent does nothing
+ { provider = "%<" } -- this means that the statusline is cut here when there's not enough space
)
vim.api.nvim_create_autocmd("User", {
@@ -860,11 +990,11 @@ local CloseButton = {
local Center = {
fallthrough = false,
{
- -- Hide the winbar for special buffers
+ -- Hide the winbar for special buffers
condition = function()
return conditions.buffer_matches({
- buftype = { "nofile", "prompt", "help", "quickfix" },
- filetype = { "^git.*", "fugitive", "dashboard", },
+ buftype = { "terminal", "nofile", "prompt", "help", "quickfix" },
+ filetype = { "dap-ui", "NvimTree", "^git.*", "fugitive", "dashboard", },
})
end,
init = function()
@@ -872,7 +1002,7 @@ local Center = {
end,
},
{
- -- A special winbar for terminals
+ -- A special winbar for terminals
condition = function()
return conditions.buffer_matches({ buftype = { "terminal" } })
end,
@@ -881,7 +1011,7 @@ local Center = {
--TerminalName,
},
{
- -- An inactive winbar for regular files
+ -- An inactive winbar for regular files
condition = function()
return not conditions.is_active()
end,
@@ -1097,29 +1227,30 @@ require("heirline").setup({
})
-- Yep, with heirline we're driving manual!
+vim.o.showtabline = 2
vim.cmd([[au FileType * if index(['wipe', 'delete', 'unload'], &bufhidden) >= 0 | set nobuflisted | endif]])
local function get_bufs()
- return vim.tbl_filter(function(bufnr)
- return vim.api.nvim_buf_is_loaded(bufnr) and vim.bo[bufnr].buflisted
- end, vim.api.nvim_list_bufs())
+ return vim.tbl_filter(function(bufnr)
+ return vim.api.nvim_buf_is_loaded(bufnr) and vim.bo[bufnr].buflisted
+ end, vim.api.nvim_list_bufs())
end
local function goto_buf(index)
- local bufs = get_bufs()
- if index > #bufs then
- index = #bufs
- end
- vim.api.nvim_win_set_buf(0, bufs[index])
+ local bufs = get_bufs()
+ if index > #bufs then
+ index = #bufs
+ end
+ vim.api.nvim_win_set_buf(0, bufs[index])
end
local function addKey(key, index)
- vim.keymap.set("", "<A-" .. key .. ">", function()
- goto_buf(index)
- end, { noremap = true, silent = true })
+ vim.keymap.set("", "<A-" .. key .. ">", function()
+ goto_buf(index)
+ end, { noremap = true, silent = true })
end
for i = 1, 9 do
- addKey(i, i)
+ addKey(i, i)
end
addKey("0", 10)