fitur baru config color scheme

This commit is contained in:
asep komarudin 2023-03-04 11:53:44 +07:00
parent 06995762e0
commit 1a7a0a9ba0
10 changed files with 159 additions and 690 deletions

View file

@ -14,6 +14,7 @@
"dressing.nvim": { "branch": "master", "commit": "5f44f829481640be0f96759c965ae22a3bcaf7ce" }, "dressing.nvim": { "branch": "master", "commit": "5f44f829481640be0f96759c965ae22a3bcaf7ce" },
"friendly-snippets": { "branch": "main", "commit": "009887b76f15d16f69ae1341f86a7862f61cf2a1" }, "friendly-snippets": { "branch": "main", "commit": "009887b76f15d16f69ae1341f86a7862f61cf2a1" },
"gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" }, "gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" },
"gruvbox-baby": { "branch": "main", "commit": "ea71b4225d0140103d99748ca4a33ecf22c03f62" },
"impatient.nvim": { "branch": "main", "commit": "969f2c5c90457612c09cf2a13fee1adaa986d350" }, "impatient.nvim": { "branch": "main", "commit": "969f2c5c90457612c09cf2a13fee1adaa986d350" },
"indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" }, "indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" },
"jaq-nvim": { "branch": "master", "commit": "236296aae555657487d1bb4d066cbde9d79d8cd4" }, "jaq-nvim": { "branch": "master", "commit": "236296aae555657487d1bb4d066cbde9d79d8cd4" },
@ -21,7 +22,6 @@
"live-server": { "branch": "main", "commit": "ecd7c1418823b65dd2bca710587c80afe42c973e" }, "live-server": { "branch": "main", "commit": "ecd7c1418823b65dd2bca710587c80afe42c973e" },
"lsp-progress.nvim": { "branch": "main", "commit": "9c0cf47587ee3cf2c9267ff2296876f214e631e5" }, "lsp-progress.nvim": { "branch": "main", "commit": "9c0cf47587ee3cf2c9267ff2296876f214e631e5" },
"lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" }, "lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" },
"lunar.nvim": { "branch": "master", "commit": "29eedf78c430ad9acebdcba814d77619edbe2bac" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "e4badf7984f7a5f0ac7dc10657dbedbd99a82f94" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "e4badf7984f7a5f0ac7dc10657dbedbd99a82f94" },
"mason-null-ls.nvim": { "branch": "main", "commit": "29ce60f9a16fef3de682a9365ef635f24ae92bf9" }, "mason-null-ls.nvim": { "branch": "main", "commit": "29ce60f9a16fef3de682a9365ef635f24ae92bf9" },
"mason.nvim": { "branch": "main", "commit": "7175340eee0b1b4a86b38794d8c21fdcfa01376b" }, "mason.nvim": { "branch": "main", "commit": "7175340eee0b1b4a86b38794d8c21fdcfa01376b" },
@ -40,7 +40,7 @@
"nvim-navic": { "branch": "master", "commit": "7e9d2b2b601149fecdccd11b516acb721e571fe6" }, "nvim-navic": { "branch": "master", "commit": "7e9d2b2b601149fecdccd11b516acb721e571fe6" },
"nvim-notify": { "branch": "master", "commit": "bdd647f61a05c9b8a57c83b78341a0690e9c29d7" }, "nvim-notify": { "branch": "master", "commit": "bdd647f61a05c9b8a57c83b78341a0690e9c29d7" },
"nvim-scrollview": { "branch": "main", "commit": "ba6c48bf7919dd48a371e7b9c683b8858053e885" }, "nvim-scrollview": { "branch": "main", "commit": "ba6c48bf7919dd48a371e7b9c683b8858053e885" },
"nvim-tree.lua": { "branch": "master", "commit": "362ecbeed69fae91a287004619decadcb6f7c113" }, "nvim-tree.lua": { "branch": "master", "commit": "1b453441f4b1a501a6251db4138cf67172d0d5d2" },
"nvim-treesitter": { "branch": "master", "commit": "c38646edf2bdfac157ca619697ecad9ea87fd469" }, "nvim-treesitter": { "branch": "master", "commit": "c38646edf2bdfac157ca619697ecad9ea87fd469" },
"nvim-ts-autotag": { "branch": "main", "commit": "fdefe46c6807441460f11f11a167a2baf8e4534b" }, "nvim-ts-autotag": { "branch": "main", "commit": "fdefe46c6807441460f11f11a167a2baf8e4534b" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "a0f89563ba36b3bacd62cf967b46beb4c2c29e52" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "a0f89563ba36b3bacd62cf967b46beb4c2c29e52" },
@ -53,7 +53,6 @@
"todo-comments.nvim": { "branch": "main", "commit": "077c59586d9d0726b0696dc5680eb863f4e04bc5" }, "todo-comments.nvim": { "branch": "main", "commit": "077c59586d9d0726b0696dc5680eb863f4e04bc5" },
"toggleterm.nvim": { "branch": "main", "commit": "a5638b2206c3930a16a24e5c184dddd572f8cd34" }, "toggleterm.nvim": { "branch": "main", "commit": "a5638b2206c3930a16a24e5c184dddd572f8cd34" },
"trouble.nvim": { "branch": "main", "commit": "67337644e38144b444d026b0df2dc5fa0038930f" }, "trouble.nvim": { "branch": "main", "commit": "67337644e38144b444d026b0df2dc5fa0038930f" },
"vim": { "branch": "master", "commit": "a4f6b0abe6cad85330867a54893864e0d5c59359" },
"vim-bbye": { "branch": "master", "commit": "903f5eb17f72ebf7b0b1524bbb792c0b36761af6" }, "vim-bbye": { "branch": "master", "commit": "903f5eb17f72ebf7b0b1524bbb792c0b36761af6" },
"vim-illuminate": { "branch": "master", "commit": "49062ab1dd8fec91833a69f0a1344223dd59d643" }, "vim-illuminate": { "branch": "master", "commit": "49062ab1dd8fec91833a69f0a1344223dd59d643" },
"vim-startuptime": { "branch": "master", "commit": "5f52ed26e0296a3e1d1453935f417e5808eefab8" }, "vim-startuptime": { "branch": "master", "commit": "5f52ed26e0296a3e1d1453935f417e5808eefab8" },

View file

@ -1,6 +1,7 @@
require("config.lazy") require("config.lazy")
require("user.colorscheme") require("user.colorscheme")
require("user.keymaps") require("user.keymaps")
require("user.snip")
-- require("user.options") -- require("user.options")
-- require("user.keymaps") -- require("user.keymaps")
-- require("user.autocommands") -- require("user.autocommands")
@ -8,8 +9,3 @@ require("user.keymaps")
-- require("user.snip") -- require("user.snip")
-- require("user.bufferline") -- require("user.bufferline")
-- require("user.chat_gpt") -- require("user.chat_gpt")
-- vim.cmd("colorscheme onedark")
-- vim.cmd("colorscheme dracula")
-- vim.cmd("colorscheme material")
require("user.snip")
vim.cmd("colorscheme lunar")

View file

@ -1,6 +1,6 @@
return { return {
{ "dracula/vim" }, { "dracula/vim" },
{ "luisiacc/gruvbox-baby", enabled = false }, { "luisiacc/gruvbox-baby" },
-- { "folke/tokyonight.nvim" }, -- { "folke/tokyonight.nvim" },
-- { "arcticicestudio/nord-vim" }, -- { "arcticicestudio/nord-vim" },
-- { "sainnhe/sonokai" }, -- { "sainnhe/sonokai" },

View file

@ -14,4 +14,22 @@ m.lualine_style = 0
-- 1 = vim icon " " -- 1 = vim icon " "
-- 2 = vim icon " " -- 2 = vim icon " "
m.status_icon = 0 m.status_icon = 0
-- custom colorscheme
-- colorscheme ready :
-- tokyonight
-- tokyonight-night
-- tokyonight-storm
-- tokyonight-day
-- tokyonight-moon
-- gruvbox-baby (default)
-- sonokai
-- material
-- onedark
-- lunar
-- nord
-- catppuccin
-- dracula
m.colorscheme = "gruvbox-baby"
return m return m

121
lua/plugins/colorscheme.lua Normal file
View file

@ -0,0 +1,121 @@
local gruvbox = true
local dracula = false
local tokyonight = false
local nord = false
local sonokai = false
local lunar = false
local material = false
local onedark = false
local catppuccin = false
_G.switch = function(param, case_table)
local case = case_table[param]
if case then
return case()
end
local def = case_table["default"]
return def and def() or nil
end
local data_exists, custom_ui = pcall(require, "custom.ui")
if data_exists then
if type(custom_ui) == "table" then
local color = custom_ui.colorscheme
switch(color, {
["tokyonight"] = function()
gruvbox = false
tokyonight = true
end,
["tokyonight-night"] = function()
gruvbox = false
tokyonight = true
end,
["tokyonight-storm"] = function()
gruvbox = false
tokyonight = true
end,
["tokyonight-day"] = function()
gruvbox = false
tokyonight = true
end,
["tokyonight-moon"] = function()
gruvbox = false
tokyonight = true
end,
["sonokai"] = function()
gruvbox = false
sonokai = true
end,
["material"] = function()
gruvbox = false
material = true
end,
["onedark"] = function()
gruvbox = false
onedark = true
end,
["lunar"] = function()
gruvbox = false
lunar = true
end,
["nord"] = function()
gruvbox = false
nord = true
end,
["catppuccin"] = function()
gruvbox = false
catppuccin = true
end,
["dracula"] = function()
gruvbox = false
dracula = true
end,
["gruvbox-baby"] = function()
gruvbox = true
end,
default = function()
gruvbox = true
end,
})
end
end
return {
-- color scheme
{ "luisiacc/gruvbox-baby", lazy = true, enabled = gruvbox },
{ "dracula/vim", enabled = dracula },
{ "folke/tokyonight.nvim", enabled = tokyonight },
{ "arcticicestudio/nord-vim", enabled = nord },
{ "sainnhe/sonokai", enabled = sonokai },
{ "lunarvim/lunar.nvim", enabled = lunar },
{
"marko-cerovac/material.nvim",
enabled = material,
config = function()
vim.g.material_style = "palenight"
require("material").setup({
lualine_style = "stealth",
})
end,
},
{
"navarasu/onedark.nvim",
enabled = onedark,
priority = 1000,
config = function()
-- Lua
require("onedark").setup({
style = "darker",
})
require("onedark").load()
end,
},
{
"catppuccin/nvim",
enabled = catppuccin,
name = "catppuccin",
init = function()
require("user.catppuccin")
end,
},
}

View file

@ -1,6 +1,4 @@
return { return {
-- color scheme
{ "luisiacc/gruvbox-baby", lazy = true },
-- dashboard -- dashboard
{ {
"goolord/alpha-nvim", "goolord/alpha-nvim",
@ -16,14 +14,7 @@ return {
-- dependencies = { "kyazdani42/nvim-web-devicons", opt = true }, -- dependencies = { "kyazdani42/nvim-web-devicons", opt = true },
event = "BufWinEnter", event = "BufWinEnter",
config = function() config = function()
local model = 0
if model == 1 then
require("user.lualine1")
elseif model == 2 then
require("user.lualine2")
else
require("user.lualine") require("user.lualine")
end
end, end,
}, },
-- for show icon -- for show icon

View file

@ -1,15 +1,19 @@
-- local colorscheme = "tokyonight"
-- local colorscheme = "gruvbox"
local colorscheme = "gruvbox-baby" local colorscheme = "gruvbox-baby"
-- local colorscheme = "sonokai" local data_exists, custom_ui = pcall(require, "custom.ui")
-- local colorscheme = "nordfox" if data_exists then
-- local colorscheme = "material" if type(custom_ui) == "table" then
-- local colorscheme = "onedark" local color = custom_ui.colorscheme
-- local colorscheme = "lunar" if color ~= nil then
-- local colorscheme = "nord" colorscheme = color
-- local colorscheme = "catppuccin" else
colorscheme = "gruvbox-baby"
end
end
end
local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not status_ok then if not status_ok then
local ok, _ = pcall(vim.cmd, "colorscheme " .. "gruvbox-baby")
if not ok then
return return
end end
end

View file

@ -1,219 +0,0 @@
local status_ok, lualine = pcall(require, "lualine")
if not status_ok then
return
end
local icons = require("user.icons")
local hide_in_width = function()
return vim.fn.winwidth(0) > 80
end
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
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,
}
local diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
-- symbols = { error = " ", warn = " " },
symbols = {
error = icons.diagnostics.BoldError .. " ",
warn = icons.diagnostics.BoldWarning .. " ",
},
colored = true,
update_in_insert = false,
always_visible = false,
}
local diff = {
"diff",
colored = true,
-- symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols
symbols = {
added = icons.git.LineAdded .. " ",
modified = icons.git.LineModified .. " ",
removed = icons.git.LineRemoved .. " ",
}, -- changes diff symbols
cond = hide_in_width,
}
local mode = {
"mode",
fmt = function(str)
-- return " " .. str
return "" .. str
end,
}
local filetype = {
"filetype",
icons_enabled = true,
icon = nil,
}
local branch = {
"branch",
icons_enabled = true,
--icon = "",
icon = icons.git.Branch,
}
local location = {
"location",
padding = 0,
}
-- cool function for progress
local progress = function()
local current_line = vim.fn.line(".")
local total_lines = vim.fn.line("$")
local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" }
local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars)
return chars[index]
end
local spaces = function()
-- return "->| " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
return icons.ui.Tab .. " " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
end
local file_name = {
"filename",
cond = conditions.buffer_not_empty,
}
-- start for lsp
local list_registered_providers_names = function(filetype)
local s = require("null-ls.sources")
local available_sources = s.get_available(filetype)
local registered = {}
for _, source in ipairs(available_sources) do
for method in pairs(source.methods) do
registered[method] = registered[method] or {}
table.insert(registered[method], source.name)
end
end
return registered
end
local null_ls = require("null-ls")
-- for formatter
local list_registered = function(filetype)
local method = null_ls.methods.FORMATTING
local registered_providers = list_registered_providers_names(filetype)
return registered_providers[method] or {}
end
--- for linter
local alternative_methods = {
null_ls.methods.DIAGNOSTICS,
null_ls.methods.DIAGNOSTICS_ON_OPEN,
null_ls.methods.DIAGNOSTICS_ON_SAVE,
}
local linter_list_registered = function(filetype)
local registered_providers = list_registered_providers_names(filetype)
local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m)
return registered_providers[m] or {}
end, alternative_methods))
return providers_for_methods
end
-- end for lsp
local lsp_info = {
function()
--local msg = "No Active Lsp"
local msg = "LS Inactive"
-- local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
local buf_ft = vim.bo.filetype
local clients = vim.lsp.get_active_clients()
-- start register
local buf_clients = vim.lsp.buf_get_clients()
local buf_client_names = {}
if next(buf_clients) == nil then
-- TODO: clean up this if statement
if type(msg) == "boolean" or #msg == 0 then
return "LS Inactive"
end
return msg
end
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
end
-- add formatter
local supported_formatters = list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local supported_linters = linter_list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
-- decomple
local unique_client_names = vim.fn.uniq(buf_client_names)
local msg = table.concat(unique_client_names, ", ")
return msg
end,
--icon = " ",
icon = icons.ui.Gear .. "",
}
lualine.setup({
options = {
icons_enabled = true,
theme = "auto",
--component_separators = { left = "", right = "" },
--section_separators = { left = "", right = "" },
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
-- component_separators = { left = "", right = "" },
-- section_separators = { left = " ", right = " " },
disabled_filetypes = {
"TelescopePrompt",
"packer",
"alpha",
"dashboard",
"NvimTree",
"Outline",
"DressingInput",
"toggleterm",
"lazy",
"mason",
"neo-tree",
},
always_divide_middle = true,
},
sections = {
lualine_a = { branch },
lualine_b = { mode },
lualine_c = { diagnostics, lsp_info },
-- lualine_c = { file_name, lsp_info },
-- lualine_x = { "encoding", "fileformat", "filetype" },
lualine_x = { diff, spaces, "encoding", filetype },
lualine_y = { location },
lualine_z = { progress },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
})

View file

@ -1,219 +0,0 @@
local status_ok, lualine = pcall(require, "lualine")
if not status_ok then
return
end
local icons = require("user.icons")
local hide_in_width = function()
return vim.fn.winwidth(0) > 80
end
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
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,
}
local diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
-- symbols = { error = " ", warn = " " },
symbols = {
error = icons.diagnostics.BoldError .. " ",
warn = icons.diagnostics.BoldWarning .. " ",
},
colored = true,
update_in_insert = false,
always_visible = false,
}
local diff = {
"diff",
colored = true,
-- symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols
symbols = {
added = icons.git.LineAdded .. " ",
modified = icons.git.LineModified .. " ",
removed = icons.git.LineRemoved .. " ",
}, -- changes diff symbols
cond = hide_in_width,
}
local mode = {
"mode",
fmt = function(str)
return "" .. str
-- return " " .. str
end,
}
local filetype = {
"filetype",
icons_enabled = true,
icon = nil,
}
local branch = {
"branch",
icons_enabled = true,
--icon = "",
icon = icons.git.Branch,
}
local location = {
"location",
padding = 0,
}
-- cool function for progress
local progress = function()
local current_line = vim.fn.line(".")
local total_lines = vim.fn.line("$")
local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" }
local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars)
return chars[index]
end
local spaces = function()
-- return "->| " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
return icons.ui.Tab .. " " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
end
local file_name = {
"filename",
cond = conditions.buffer_not_empty,
}
-- start for lsp
local list_registered_providers_names = function(filetype)
local s = require("null-ls.sources")
local available_sources = s.get_available(filetype)
local registered = {}
for _, source in ipairs(available_sources) do
for method in pairs(source.methods) do
registered[method] = registered[method] or {}
table.insert(registered[method], source.name)
end
end
return registered
end
local null_ls = require("null-ls")
-- for formatter
local list_registered = function(filetype)
local method = null_ls.methods.FORMATTING
local registered_providers = list_registered_providers_names(filetype)
return registered_providers[method] or {}
end
--- for linter
local alternative_methods = {
null_ls.methods.DIAGNOSTICS,
null_ls.methods.DIAGNOSTICS_ON_OPEN,
null_ls.methods.DIAGNOSTICS_ON_SAVE,
}
local linter_list_registered = function(filetype)
local registered_providers = list_registered_providers_names(filetype)
local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m)
return registered_providers[m] or {}
end, alternative_methods))
return providers_for_methods
end
-- end for lsp
local lsp_info = {
function()
--local msg = "No Active Lsp"
local msg = "LS Inactive"
-- local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
local buf_ft = vim.bo.filetype
local clients = vim.lsp.get_active_clients()
-- start register
local buf_clients = vim.lsp.buf_get_clients()
local buf_client_names = {}
if next(buf_clients) == nil then
-- TODO: clean up this if statement
if type(msg) == "boolean" or #msg == 0 then
return "LS Inactive"
end
return msg
end
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
end
-- add formatter
local supported_formatters = list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local supported_linters = linter_list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
-- decomple
local unique_client_names = vim.fn.uniq(buf_client_names)
local msg = table.concat(unique_client_names, ", ")
return msg
end,
--icon = " ",
icon = icons.ui.Gear .. "",
}
lualine.setup({
options = {
icons_enabled = true,
theme = "auto",
--component_separators = { left = "", right = "" },
--section_separators = { left = "", right = "" },
-- component_separators = { left = "", right = "" },
-- section_separators = { left = "", right = "" },
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
"TelescopePrompt",
"packer",
"alpha",
"dashboard",
"NvimTree",
"Outline",
"DressingInput",
"toggleterm",
"lazy",
"mason",
"neo-tree",
},
always_divide_middle = true,
},
sections = {
lualine_a = { branch },
lualine_b = { mode },
lualine_c = { diagnostics, lsp_info },
-- lualine_c = { file_name, lsp_info },
-- lualine_x = { "encoding", "fileformat", "filetype" },
lualine_x = { diff, spaces, "encoding", filetype },
lualine_y = { location },
lualine_z = { progress },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
})

View file

@ -1,222 +0,0 @@
local status_ok, lualine = pcall(require, "lualine")
if not status_ok then
return
end
local icons = require("user.icons")
local hide_in_width = function()
return vim.fn.winwidth(0) > 80
end
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
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,
}
local diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
-- symbols = { error = " ", warn = " " },
symbols = {
error = icons.diagnostics.BoldError .. " ",
warn = icons.diagnostics.BoldWarning .. " ",
},
colored = true,
update_in_insert = false,
always_visible = false,
}
local diff = {
"diff",
colored = true,
-- symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols
symbols = {
added = icons.git.LineAdded .. " ",
modified = icons.git.LineModified .. " ",
removed = icons.git.LineRemoved .. " ",
}, -- changes diff symbols
cond = hide_in_width,
}
local mode = {
"mode",
fmt = function(str)
return "--" .. str .. "--"
-- return " " .. str
-- return " " .. str
end,
}
local filetype = {
"filetype",
icons_enabled = true,
icon = nil,
}
local branch = {
"branch",
icons_enabled = true,
--icon = "",
icon = icons.git.Branch,
}
local location = {
"location",
padding = 0,
}
-- cool function for progress
local progress = function()
local current_line = vim.fn.line(".")
local total_lines = vim.fn.line("$")
local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" }
local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars)
return chars[index]
end
local spaces = function()
-- return "->| " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
return icons.ui.Tab .. " " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
end
local file_name = {
"filename",
cond = conditions.buffer_not_empty,
}
-- start for lsp
local list_registered_providers_names = function(filetype)
local s = require("null-ls.sources")
local available_sources = s.get_available(filetype)
local registered = {}
for _, source in ipairs(available_sources) do
for method in pairs(source.methods) do
registered[method] = registered[method] or {}
table.insert(registered[method], source.name)
end
end
return registered
end
local null_ls = require("null-ls")
-- for formatter
local list_registered = function(filetype)
local method = null_ls.methods.FORMATTING
local registered_providers = list_registered_providers_names(filetype)
return registered_providers[method] or {}
end
--- for linter
local alternative_methods = {
null_ls.methods.DIAGNOSTICS,
null_ls.methods.DIAGNOSTICS_ON_OPEN,
null_ls.methods.DIAGNOSTICS_ON_SAVE,
}
local linter_list_registered = function(filetype)
local registered_providers = list_registered_providers_names(filetype)
local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m)
return registered_providers[m] or {}
end, alternative_methods))
return providers_for_methods
end
-- end for lsp
local lsp_info = {
function()
--local msg = "No Active Lsp"
local msg = "LS Inactive"
-- local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
local buf_ft = vim.bo.filetype
local clients = vim.lsp.get_active_clients()
-- start register
local buf_clients = vim.lsp.buf_get_clients()
local buf_client_names = {}
if next(buf_clients) == nil then
-- TODO: clean up this if statement
if type(msg) == "boolean" or #msg == 0 then
return "LS Inactive"
end
return msg
end
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
end
-- add formatter
local supported_formatters = list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local supported_linters = linter_list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
-- decomple
local unique_client_names = vim.fn.uniq(buf_client_names)
local msg = table.concat(unique_client_names, ", ")
return msg
end,
--icon = " ",
icon = icons.ui.Gear .. "",
}
lualine.setup({
options = {
icons_enabled = true,
theme = "auto",
-- component_separators = { left = "", right = "" },
-- section_separators = { left = "", right = "" },
-- component_separators = { left = "", right = "" },
-- section_separators = { left = "", right = "" },
-- component_separators = { left = "", right = "" },
-- section_separators = { left = " ", right = " " },
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
"TelescopePrompt",
"packer",
"alpha",
"dashboard",
"NvimTree",
"Outline",
"DressingInput",
"toggleterm",
"lazy",
"mason",
"neo-tree",
},
always_divide_middle = true,
},
sections = {
lualine_a = { branch },
lualine_b = { mode },
lualine_c = { diagnostics, lsp_info },
-- lualine_c = { file_name, lsp_info },
-- lualine_x = { "encoding", "fileformat", "filetype" },
lualine_x = { diff, spaces, "encoding", filetype },
lualine_y = { location },
lualine_z = { progress },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
})