aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua')
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua246
1 files changed, 121 insertions, 125 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
index a165811..aace592 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
@@ -1,151 +1,147 @@
+local status_ok, lualine = pcall(require, "lualine")
+if not status_ok then
+ vim.notify("Failed to load module 'lualine'", vim.log.levels.ERROR)
+ return
+end
+
local utils = require("tobyvin.utils")
-local M = {}
-local function get_short_cwd()
+local get_short_cwd = function()
return vim.fn.fnamemodify(vim.fn.getcwd(), ":~")
end
-M.to_char = function(str)
+local to_char = function(str)
return str:sub(1, 1)
end
-M.setup = function()
- local status_ok, lualine = pcall(require, "lualine")
- if not status_ok then
- return
- end
+local winbar_cond = function()
+ return vim.bo.buflisted
+end
- local winbar_cond = function()
- return vim.bo.buflisted
- end
+local git = {
+ "branch",
+ {
+ "diff",
+ source = function()
+ local gitsigns = vim.b.gitsigns_status_dict
+ if gitsigns then
+ return {
+ added = gitsigns.added,
+ modified = gitsigns.changed,
+ removed = gitsigns.removed,
+ }
+ end
+ end,
+ padding = { left = 0, right = 1 },
+ },
+}
- local git = {
- "branch",
- {
- "diff",
- source = function()
- local gitsigns = vim.b.gitsigns_status_dict
- if gitsigns then
- return {
- added = gitsigns.added,
- modified = gitsigns.changed,
- removed = gitsigns.removed,
- }
- end
- end,
- padding = { left = 0, right = 1 },
- },
- }
-
- local workspace = {
- {
- function()
- return utils.diagnostic
- .indicator(nil)
- :gsub("DiagnosticSignError", "lualine_b_diagnostics_error_normal")
- :gsub("DiagnosticSignWarn", "lualine_b_diagnostics_warn_normal")
- :gsub("DiagnosticSignInfo", "lualine_b_diagnostics_info_normal")
- :gsub("DiagnosticSignHint", "lualine_b_diagnostics_hint_normal")
- end,
- padding = { left = 1, right = 0 },
- color = "StatusLineNC",
- },
- {
- "filename",
- path = 1,
- },
- }
+local workspace = {
+ {
+ function()
+ return utils.diagnostic
+ .indicator(nil)
+ :gsub("DiagnosticSignError", "lualine_b_diagnostics_error_normal")
+ :gsub("DiagnosticSignWarn", "lualine_b_diagnostics_warn_normal")
+ :gsub("DiagnosticSignInfo", "lualine_b_diagnostics_info_normal")
+ :gsub("DiagnosticSignHint", "lualine_b_diagnostics_hint_normal")
+ end,
+ padding = { left = 1, right = 0 },
+ color = "StatusLineNC",
+ },
+ {
+ "filename",
+ path = 1,
+ },
+}
- local buffer = {
- {
- "filename",
- color = "WinBar",
- cond = winbar_cond,
- },
- {
- "diagnostics",
- source = { utils.diagnostic.buf_count },
- symbols = {
- error = utils.diagnostic.signs.error.text,
- warn = utils.diagnostic.signs.warn.text,
- info = utils.diagnostic.signs.info.text,
- hint = utils.diagnostic.signs.hint.text,
- },
- update_in_insert = true,
- color = "WinBar",
- padding = { left = 0, right = 1 },
- cond = winbar_cond,
+local buffer = {
+ {
+ "filename",
+ color = "WinBar",
+ cond = winbar_cond,
+ },
+ {
+ "diagnostics",
+ source = { utils.diagnostic.buf_count },
+ symbols = {
+ error = utils.diagnostic.signs.error.text,
+ warn = utils.diagnostic.signs.warn.text,
+ info = utils.diagnostic.signs.info.text,
+ hint = utils.diagnostic.signs.hint.text,
},
- }
+ update_in_insert = true,
+ color = "WinBar",
+ padding = { left = 0, right = 1 },
+ cond = winbar_cond,
+ },
+}
- lualine.setup({
- options = {
- component_separators = "",
- section_separators = "",
- disabled_filetypes = {
- "netrw",
- "alpha",
- winbar = vim.fn.getcompletion("Neogit*", "filetype"),
- },
+lualine.setup({
+ options = {
+ component_separators = "",
+ section_separators = "",
+ disabled_filetypes = {
+ "netrw",
+ "alpha",
+ winbar = vim.fn.getcompletion("Neogit*", "filetype"),
},
+ },
- sections = {
- lualine_a = { { "mode", fmt = M.to_char } },
- lualine_b = git,
- lualine_c = workspace,
- lualine_x = {
- "encoding",
- "fileformat",
- "filetype",
- },
+ sections = {
+ lualine_a = { { "mode", fmt = to_char } },
+ lualine_b = git,
+ lualine_c = workspace,
+ lualine_x = {
+ "encoding",
+ "fileformat",
+ "filetype",
},
+ },
- inactive_sections = {
- lualine_c = { "filename" },
- lualine_x = {
- "filetype",
- "location",
- },
+ inactive_sections = {
+ lualine_c = { "filename" },
+ lualine_x = {
+ "filetype",
+ "location",
},
+ },
- winbar = {
- lualine_b = buffer,
- lualine_c = {
- {
- -- Hack to prevent lualine_b from taking over the lualine_c when navic has no results
- function()
- return require("nvim-navic").get_location():gsub("^$", " ")
- end,
- color = "WinBarNC",
- cond = winbar_cond,
- },
+ winbar = {
+ lualine_b = buffer,
+ lualine_c = {
+ {
+ -- Hack to prevent lualine_b from taking over the lualine_c when navic has no results
+ function()
+ return require("nvim-navic").get_location():gsub("^$", " ")
+ end,
+ color = "WinBarNC",
+ cond = winbar_cond,
},
},
+ },
- tabline = {
- lualine_b = { { "buffers", mode = 4 } },
- lualine_y = { "tabs" },
- },
+ tabline = {
+ lualine_b = { { "buffers", mode = 4 } },
+ lualine_y = { "tabs" },
+ },
- extensions = {
- "fzf",
- "man",
- "nvim-dap-ui",
- "symbols-outline",
- "quickfix",
- "toggleterm",
- {
- sections = {
- lualine_c = {
- get_short_cwd,
- },
- },
- filetypes = {
- "netrw",
+ extensions = {
+ "fzf",
+ "man",
+ "nvim-dap-ui",
+ "symbols-outline",
+ "quickfix",
+ "toggleterm",
+ {
+ sections = {
+ lualine_c = {
+ get_short_cwd,
},
},
+ filetypes = {
+ "netrw",
+ },
},
- })
-end
-
-return M
+ },
+})