aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/cokeline.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/plugins/cokeline.lua')
-rw-r--r--.config/nvim/lua/plugins/cokeline.lua220
1 files changed, 220 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/cokeline.lua b/.config/nvim/lua/plugins/cokeline.lua
new file mode 100644
index 0000000..2b70c53
--- /dev/null
+++ b/.config/nvim/lua/plugins/cokeline.lua
@@ -0,0 +1,220 @@
+local state = require "state"
+
+return {
+ "willothy/nvim-cokeline",
+ lazy = false,
+ config = function()
+ local hl = require "cokeline.hlgroups"
+ local is_picking_focus = require("cokeline.mappings").is_picking_focus
+ local is_picking_close = require("cokeline.mappings").is_picking_close
+
+ local function has_diagnostics(buffer)
+ return buffer.diagnostics.errors > 0
+ or buffer.diagnostics.warnings > 0
+ or buffer.diagnostics.infos > 0
+ or buffer.diagnostics.hints > 0
+ end
+
+ require("cokeline").setup {
+ show_if_buffers_are_at_least = 0,
+ components = {
+ {
+ text = function(buffer)
+ return buffer.is_first and (require("cokeline.sidebar").get_width "left" == 0 and "" or "│")
+ or "▎"
+ end,
+ fg = function()
+ return hl.get_hl_attr("WinSeparator", "fg")
+ end,
+ bg = function()
+ return hl.get_hl_attr("Normal", "bg")
+ end,
+ },
+ {
+ text = function(buffer)
+ return (is_picking_focus() or is_picking_close()) and " " .. buffer.pick_letter or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("PrismiteYellow", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ return " " .. buffer.devicon.icon
+ end,
+ fg = function(buffer)
+ return buffer.devicon.color
+ end,
+ },
+ {
+ text = function(buffer)
+ return buffer.unique_prefix
+ end,
+ fg = function()
+ return hl.get_hl_attr("Comment", "fg")
+ end,
+ italic = true,
+ },
+ {
+ text = function(buffer)
+ return buffer.filename
+ end,
+ },
+ {
+ text = function(buffer)
+ return buffer.is_modified and " " or ""
+ end,
+ },
+ {
+ text = function(buffer)
+ return has_diagnostics(buffer) and " [" or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("WinSeparator", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ local errors = buffer.diagnostics.errors
+ return errors > 0 and errors or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("DiagnosticError", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ local bd = buffer.diagnostics
+ return (bd.errors > 0 and (bd.warnings > 0 or bd.infos > 0 or bd.hints > 0)) and "|" or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("WinSeparator", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ local warnings = buffer.diagnostics.warnings
+ return warnings > 0 and warnings or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("DiagnosticWarn", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ local bd = buffer.diagnostics
+ return (bd.warnings > 0 and (bd.infos > 0 or bd.hints > 0)) and "|" or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("WinSeparator", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ local infos = buffer.diagnostics.infos
+ return infos > 0 and infos or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("DiagnosticInfo", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ local bd = buffer.diagnostics
+ return (bd.infos > 0 and bd.hints > 0) and "|" or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("WinSeparator", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ local hints = buffer.diagnostics.hints
+ return hints > 0 and hints or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("DiagnosticHint", "fg")
+ end,
+ },
+ {
+ text = function(buffer)
+ return has_diagnostics(buffer) and "]" or ""
+ end,
+ fg = function()
+ return hl.get_hl_attr("WinSeparator", "fg")
+ end,
+ },
+ {
+ text = " ",
+ },
+ },
+ buffers = {
+ delete_on_right_click = false,
+ },
+ mappings = {
+ disable_mouse = true,
+ },
+ sidebar = {
+ components = {
+ {
+ text = function()
+ local width = require("cokeline.sidebar").get_width "left"
+ if #state.nvim_tree_root > width then
+ return state.nvim_tree_root:sub(1, width - 2) .. "…"
+ else
+ return state.nvim_tree_root
+ end
+ end,
+ bg = function()
+ return hl.get_hl_attr("TabLineSel", "bg")
+ end,
+ },
+ {
+ text = function()
+ return string.rep(
+ " ",
+ math.max(0, require("cokeline.sidebar").get_width "left" - #state.nvim_tree_root)
+ )
+ end,
+ bg = function()
+ return hl.get_hl_attr("TabLineSel", "bg")
+ end,
+ },
+ },
+ },
+ }
+ end,
+ dependencies = { "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" },
+ keys = {
+ {
+ "<leader>bp",
+ function()
+ require("cokeline.mappings").pick "focus"
+ end,
+ desc = "Pick a buffer to focus",
+ },
+ {
+ "<leader>bd",
+ function()
+ require("cokeline.mappings").pick "close"
+ end,
+ desc = "Pick a buffer to close",
+ },
+ {
+ "<Leader>p",
+ function()
+ require("cokeline.mappings").by_step("switch", -1)
+ end,
+ desc = "Move current buffer left",
+ silent = true,
+ },
+ {
+ "<Leader>n",
+ function()
+ require("cokeline.mappings").by_step("switch", 1)
+ end,
+ desc = "Move current buffer right",
+ silent = true,
+ },
+ },
+}