aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/nvim
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-08-14 17:05:51 -0500
committerToby Vincent <tobyv13@gmail.com>2022-08-14 17:05:51 -0500
commit753cb493af2a66f8bdb71903156f032dc926a93b (patch)
treed265ab469a1a52d871cf33d071ce39e3d90c97fa /nvim
parentda7d521b40175bc407b5588073136661331669f0 (diff)
feat(nvim): improve lualine config
Diffstat (limited to 'nvim')
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins.lua3
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua38
-rw-r--r--nvim/.config/nvim/lua/tobyvin/utils.lua67
3 files changed, 56 insertions, 52 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins.lua b/nvim/.config/nvim/lua/tobyvin/plugins.lua
index 2d01be2..472a18b 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins.lua
@@ -49,6 +49,9 @@ M.plugins = function(use)
config = function()
require("auto-session").setup({
log_level = "error",
+ cwd_change_handling = {
+ restore_upcoming_session = true,
+ },
})
end,
})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
index a7b223a..41022b0 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
@@ -22,7 +22,8 @@ M.setup = function()
return
end
- local nvim_navic = require("nvim-navic")
+ local navic_ok, navic = pcall(require, "nvim-navic")
+ local auto_session_ok, auto_session_library = pcall(require, "auto-session-library")
local modules = require("lualine_require").lazy_require({
highlight = "lualine.highlight",
@@ -123,9 +124,27 @@ M.setup = function()
},
},
lualine_c = {
- { "filetype", icon_only = true, colored = false },
- "filename",
- { nvim_navic.get_location, cond = nvim_navic.is_available },
+
+ {
+ auto_session_library.current_session_name,
+ cond = function()
+ return auto_session_ok
+ end,
+ separator = ">",
+ },
+ -- { "filetype", icon_only = true, colored = false },
+ {
+ "filename",
+ path = 1,
+ separator = ">",
+ shorting_target = 100,
+ },
+ {
+ navic.get_location,
+ cond = function()
+ return navic_ok and navic.is_available()
+ end,
+ },
},
lualine_x = {
"encoding",
@@ -134,25 +153,18 @@ M.setup = function()
},
},
tabline = {
- -- lualine_b = { { "buffers", buffers_color = { inactive = "StatusLineNC" } } },
lualine_b = {
{
"buffers",
- -- TODO: figure out how to highlight diagnostic signs
fmt = function(name, bufnr)
- return string.format("%s %s", name, utils.diagnostics_str(bufnr))
+ return string.format("%s %s", name, utils.diagnostic_indicator(bufnr))
end,
},
},
- -- lualine_y = { "tabs" },
lualine_y = { { "tabs", mode = 1 } },
},
- extensions = { "quickfix", "man", "fzf", "nvim-dap-ui" },
+ extensions = { "quickfix", "man", "fzf", "nvim-dap-ui", "symbols-outline", "toggleterm" },
})
-
- -- local nmap = utils.create_map_group("n", "<leader>b", { desc = "Buffers" })
- -- nmap("c", M.close_with_pick, { desc = "Close Buffer" })
- -- nmap("b", M.pick_buffer, { desc = "Pick Buffer" })
end
return M
diff --git a/nvim/.config/nvim/lua/tobyvin/utils.lua b/nvim/.config/nvim/lua/tobyvin/utils.lua
index a7705f9..e51b0b3 100644
--- a/nvim/.config/nvim/lua/tobyvin/utils.lua
+++ b/nvim/.config/nvim/lua/tobyvin/utils.lua
@@ -1,29 +1,11 @@
---@diagnostic disable: missing-parameter
local M = {}
-M.diagnostic_signs = {
- hint = { text = " ", texthl = "DiagnosticSignHint" },
- info = { text = " ", texthl = "DiagnosticSignInfo" },
- warn = { text = " ", texthl = "DiagnosticSignWarn" },
- error = { text = " ", texthl = "DiagnosticSignError" },
+M.progress_signs = {
+ complete = { text = " ", texthl = "diffAdded" },
+ spinner = { text = { "⣷", "⣯", "⣟", "⡿", "⢿", "⣻", "⣽", "⣾" }, texthl = "DiagnosticSignInfo" },
}
-setmetatable(M.diagnostic_signs, {
- __index = function(t, k)
- if type(k) == "number" then
- local levels = { "hint", "info", "warn", "error" }
- return levels[k]
- end
-
- local fmt_k = k:gsub("warning", "warn"):lower()
- if t[fmt_k] ~= nil then
- return t[fmt_k]
- end
-
- return t[k]
- end,
-})
-
M.debug_signs = {
breakpoint = { text = " ", texthl = "debugBreakpoint" },
condition = { text = "ﳁ ", texthl = "debugBreakpoint" },
@@ -32,32 +14,39 @@ M.debug_signs = {
stopped = { text = " ", texthl = "debugBreakpoint", linehl = "debugPC", numhl = "debugPC" },
}
-M.progress_signs = {
- complete = { text = " ", texthl = "diffAdded" },
- spinner = { text = { "⣷", "⣯", "⣟", "⡿", "⢿", "⣻", "⣽", "⣾" }, texthl = "DiagnosticSignInfo" },
+M.diagnostic_signs = {
+ HINT = { text = " ", texthl = "DiagnosticSignHint" },
+ INFO = { text = " ", texthl = "DiagnosticSignInfo" },
+ WARN = { text = " ", texthl = "DiagnosticSignWarn" },
+ ERROR = { text = " ", texthl = "DiagnosticSignError" },
}
-M.diagnostics_indicator = function(diagnostics_count)
- local tbl = {}
- for level, count in pairs(diagnostics_count) do
- table.insert(tbl, M.diagnostic_signs[level].text .. count)
- end
- return table.concat(tbl, " ")
-end
+setmetatable(M.diagnostic_signs, {
+ __index = function(t, k)
+ if type(k) == "number" then
+ return t[vim.diagnostic.severity[k]]
+ end
+ return t[k:upper():gsub("WARNING", "WARN")]
+ end,
+})
-M.diagnostics_count = function(bufnr)
+M.diagnostic_count = function(bufnr)
local items = {}
- for i, level in ipairs({ "hint", "info", "warn", "error" }) do
- local count = #vim.diagnostic.get(bufnr, { severity = i })
- if count > 0 then
- items[level] = count
- end
+ for i, level in ipairs(vim.diagnostic.severity) do
+ items[level] = #vim.diagnostic.get(bufnr, { severity = i })
end
return items
end
-M.diagnostics_str = function(bufnr, highlight)
- return M.diagnostics_indicator(M.diagnostics_count(bufnr))
+M.diagnostic_indicator = function(bufnr)
+ local diagnostic_count = M.diagnostic_count(bufnr)
+ local tbl = {}
+ for level, count in pairs(diagnostic_count) do
+ if count > 0 then
+ table.insert(tbl, M.diagnostic_signs[level].text .. count)
+ end
+ end
+ return table.concat(tbl, " ")
end
M.update_spinner = function(client_id, token)