Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update lualine config #288

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 47 additions & 17 deletions lua/config/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ end

local virtual_env = function()
-- only show virtual env for Python
if vim.bo.filetype ~= 'python' then
if vim.bo.filetype ~= "python" then
return ""
end

local conda_env = os.getenv('CONDA_DEFAULT_ENV')
local venv_path = os.getenv('VIRTUAL_ENV')
local conda_env = os.getenv("CONDA_DEFAULT_ENV")
local venv_path = os.getenv("VIRTUAL_ENV")

if venv_path == nil then
if conda_env == nil then
Expand All @@ -113,17 +113,32 @@ local virtual_env = function()
return string.format(" %s (conda)", conda_env)
end
else
local venv_name = vim.fn.fnamemodify(venv_path, ':t')
local venv_name = vim.fn.fnamemodify(venv_path, ":t")
return string.format(" %s (venv)", venv_name)
end
end

local get_active_lsp = function()
local msg = "No Active Lsp"
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
local clients = vim.lsp.get_clients { bufnr = 0 }
if next(clients) == nil then
return msg
end

for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end

require("lualine").setup {
options = {
icons_enabled = true,
theme = "auto",
-- component_separators = { left = "", right = "" },
-- section_separators = { left = "", right = "" },
section_separators = "",
component_separators = "",
disabled_filetypes = {},
Expand All @@ -132,18 +147,29 @@ require("lualine").setup {
sections = {
lualine_a = { "mode" },
lualine_b = {
"branch",
{
"diff",
source = diff,
"branch",
fmt = function(name, context)
-- truncate branch name in case the name is too long
return string.sub(name, 1, 20)
end,
},
{
virtual_env,
color = { fg = 'black', bg = "#F1CA81" }
}
color = { fg = "black", bg = "#F1CA81" },
},
},
lualine_c = {
"filename",
{
"filename",
symbols = {
readonly = "[🔒]",
},
},
{
"diff",
source = diff,
},
{
ime_state,
color = { fg = "black", bg = "#f46868" },
Expand All @@ -152,13 +178,19 @@ require("lualine").setup {
spell,
color = { fg = "black", bg = "#a7c080" },
},
},
lualine_x = {
{
get_active_lsp,
icon = " LSP:",
},
{
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = {error = '🆇 ', warn = '⚠️ ', info = 'ℹ️ ', hint = ' '},
symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
},
},
lualine_x = {
lualine_y = {
"encoding",
{
"fileformat",
Expand All @@ -170,9 +202,6 @@ require("lualine").setup {
},
"filetype",
},
lualine_y = {
"location",
},
lualine_z = {
{
trailing_space,
Expand All @@ -182,6 +211,7 @@ require("lualine").setup {
mixed_indent,
color = "WarningMsg",
},
"progress"
},
},
inactive_sections = {
Expand Down