summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/core/lualine
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-09-06 21:53:56 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-09-06 21:53:56 +0200
commit6a1732982287ef5aff2a6de171192b9e2bb90758 (patch)
tree543f94f80d548b9ed7a9d0daecb08575a01a9a45 /.config/nvim/lua/core/lualine
parentb89e893bfc7b8893dc4c13aa55f627096b32758a (diff)
Updates to nvim from lvim
Diffstat (limited to '.config/nvim/lua/core/lualine')
-rw-r--r--.config/nvim/lua/core/lualine/components.lua53
-rw-r--r--.config/nvim/lua/core/lualine/conditions.lua10
-rw-r--r--.config/nvim/lua/core/lualine/styles.lua7
3 files changed, 38 insertions, 32 deletions
diff --git a/.config/nvim/lua/core/lualine/components.lua b/.config/nvim/lua/core/lualine/components.lua
index 4777392..adae368 100644
--- a/.config/nvim/lua/core/lualine/components.lua
+++ b/.config/nvim/lua/core/lualine/components.lua
@@ -1,6 +1,17 @@
local conditions = require "core.lualine.conditions"
local colors = require "core.lualine.colors"
+local function diff_source()
+ local gitsigns = vim.b.gitsigns_status_dict
+ if gitsigns then
+ return {
+ added = gitsigns.added,
+ modified = gitsigns.changed,
+ removed = gitsigns.removed,
+ }
+ end
+end
+
return {
mode = {
function()
@@ -22,34 +33,29 @@ return {
end,
left_padding = 0,
right_padding = 0,
- condition = function()
- return true
- end,
+ condition = nil,
color = { fg = colors.fg, bg = colors.bg },
},
branch = {
- "branch",
+ "b:gitsigns_head",
icon = " ",
- condition = function()
- return conditions.hide_in_width() and conditions.check_git_workspace()
- end,
color = { gui = "bold", fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
filename = {
"filename",
- condition = function()
- return true
- end,
color = { fg = colors.fg, bg = colors.bg },
+ condition = nil,
},
diff = {
"diff",
+ source = diff_source,
symbols = { added = "  ", modified = "柳", removed = " " },
color_added = { fg = colors.green },
color_modified = { fg = colors.yellow },
color_removed = { fg = colors.red },
- condition = conditions.hide_in_width,
color = {},
+ condition = nil,
},
python_env = {
function()
@@ -67,15 +73,15 @@ return {
end
return ""
end,
- condition = conditions.hide_in_width,
color = { fg = colors.green },
+ condition = conditions.hide_in_width,
},
diagnostics = {
"diagnostics",
sources = { "nvim_lsp" },
symbols = { error = " ", warn = " ", info = " ", hint = " " },
- condition = conditions.hide_in_width,
color = {},
+ condition = conditions.hide_in_width,
},
treesitter = {
function()
@@ -84,14 +90,17 @@ return {
end
return ""
end,
- condition = conditions.hide_in_width,
color = { fg = colors.green },
+ condition = conditions.hide_in_width,
},
lsp = {
function(msg)
- msg = msg or "LSP Inactive"
+ msg = msg or "LS Inactive"
local buf_clients = vim.lsp.buf_get_clients()
if next(buf_clients) == nil then
+ if type(msg) == "boolean" or #msg == 0 then
+ return "LS Inactive"
+ end
return msg
end
local buf_ft = vim.bo.filetype
@@ -120,18 +129,18 @@ return {
return table.concat(buf_client_names, ", ")
end,
icon = " ",
- condition = conditions.hide_in_width,
color = { fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
location = {
"location",
- condition = conditions.hide_in_width,
color = { fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
progress = {
"progress",
- condition = conditions.hide_in_width,
color = { fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
spaces = {
function()
@@ -141,14 +150,14 @@ return {
end
return label .. vim.api.nvim_buf_get_option(0, "shiftwidth") .. " "
end,
- condition = conditions.hide_in_width,
color = {},
+ condition = conditions.hide_in_width,
},
encoding = {
"o:encoding",
upper = true,
- condition = conditions.hide_in_width,
color = { fg = colors.fg, bg = colors.bg },
+ condition = conditions.hide_in_width,
},
filetype = { "filetype", condition = conditions.hide_in_width, color = {} },
scrollbar = {
@@ -172,9 +181,7 @@ return {
end,
left_padding = 0,
right_padding = 0,
- condition = function()
- return true
- end,
+ condition = nil,
color = { fg = colors.yellow, bg = colors.bg },
},
}
diff --git a/.config/nvim/lua/core/lualine/conditions.lua b/.config/nvim/lua/core/lualine/conditions.lua
index 2d2d81e..3ee4fbb 100644
--- a/.config/nvim/lua/core/lualine/conditions.lua
+++ b/.config/nvim/lua/core/lualine/conditions.lua
@@ -7,11 +7,11 @@ local conditions = {
hide_in_width = function()
return vim.fn.winwidth(0) > window_width_limit
end,
- check_git_workspace = function()
- local filepath = vim.fn.expand "%:p:h"
- local gitdir = vim.fn.finddir(".git", filepath .. ";")
- return gitdir and #gitdir > 0 and #gitdir < #filepath
- end,
+ -- check_git_workspace = function()
+ -- local filepath = vim.fn.expand "%:p:h"
+ -- local gitdir = vim.fn.finddir(".git", filepath .. ";")
+ -- return gitdir and #gitdir > 0 and #gitdir < #filepath
+ -- end,
}
return conditions
diff --git a/.config/nvim/lua/core/lualine/styles.lua b/.config/nvim/lua/core/lualine/styles.lua
index 014ba81..e13e214 100644
--- a/.config/nvim/lua/core/lualine/styles.lua
+++ b/.config/nvim/lua/core/lualine/styles.lua
@@ -14,7 +14,7 @@ styles.clean = {
icons_enabled = true,
component_separators = "",
section_separators = "",
- disabled_filetypes = { "dashboard" },
+ disabled_filetypes = { "dashboard", "NvimTree", "Outline" },
},
sections = {
lualine_a = {
@@ -160,14 +160,13 @@ function M.get_style(style)
local style_keys = vim.tbl_keys(styles)
if not vim.tbl_contains(style_keys, style) then
local Log = require "core.log"
- local logger = Log:get_default()
- logger.error(
+ Log:error(
"Invalid lualine style",
string.format('"%s"', style),
"options are: ",
string.format('"%s"', table.concat(style_keys, '", "'))
)
- logger.info '"lvim" style is applied.'
+ Log:debug '"lvim" style is applied.'
style = "lvim"
end