diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 58a9bd9..12e1184 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -12,7 +12,12 @@ return { lazy = false, -- make sure we load this during startup if it is your main colorscheme priority = 1000, -- make sure to load this before all the other start plugins config = function() - require("user.tokyonight") + local is_transparant = true + if is_transparant then + require("user.tokyonight_transparant") + else + require("user.tokyonight") + end end, }, { @@ -80,7 +85,14 @@ return { dependencies = { "kyazdani42/nvim-web-devicons", opt = true }, event = "BufWinEnter", opts = function() - require("user.lualine") + local model = 0 + if model == 1 then + require("user.lualine1") + elseif model == 2 then + require("user.lualine2") + else + require("user.lualine") + end end, }, { "rafamadriz/friendly-snippets" }, diff --git a/lua/user/lualine.lua b/lua/user/lualine.lua index 038d0a7..f692e7d 100644 --- a/lua/user/lualine.lua +++ b/lua/user/lualine.lua @@ -50,8 +50,9 @@ local diff = { local mode = { "mode", fmt = function(str) + return "--" .. str .. "--" -- return " " .. str - return " " .. str + -- return " " .. str end, } @@ -174,10 +175,10 @@ 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 = "" }, -- component_separators = { left = "", right = "" }, -- section_separators = { left = " ", right = " " }, diff --git a/lua/user/lualine1.lua b/lua/user/lualine1.lua new file mode 100644 index 0000000..b52b1e8 --- /dev/null +++ b/lua/user/lualine1.lua @@ -0,0 +1,218 @@ +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", + }, + 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 = {}, +}) diff --git a/lua/user/lualine2.lua b/lua/user/lualine2.lua new file mode 100644 index 0000000..b2710ec --- /dev/null +++ b/lua/user/lualine2.lua @@ -0,0 +1,218 @@ +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", + }, + 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 = {}, +}) diff --git a/lua/user/tokyonight.lua b/lua/user/tokyonight.lua index 0dd75b1..08e8125 100644 --- a/lua/user/tokyonight.lua +++ b/lua/user/tokyonight.lua @@ -7,7 +7,7 @@ tokyonight.setup({ -- or leave it empty to use the default settings style = "night", -- The theme comes in three styles, `storm`, `moon`, a darker variant `night` and `day` light_style = "day", -- The theme is used when the background is set to light - transparent = true, -- Enable this to disable setting the background color + transparent = false, -- Enable this to disable setting the background color terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim styles = { -- Style to be applied to different syntax groups @@ -18,8 +18,8 @@ tokyonight.setup({ functions = {}, variables = {}, -- Background styles. Can be "dark", "transparent" or "normal" - sidebars = "transparent", -- style for sidebars, see below - floats = "transparent", -- style for floating windows + sidebars = "dark", -- style for sidebars, see below + floats = "dark", -- style for floating windows }, sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` day_brightness = 0.2, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors diff --git a/lua/user/tokyonight_transparant.lua b/lua/user/tokyonight_transparant.lua new file mode 100644 index 0000000..a6ad281 --- /dev/null +++ b/lua/user/tokyonight_transparant.lua @@ -0,0 +1,40 @@ +local status_ok, tokyonight = pcall(require, "tokyonight") +if not status_ok then + return +end +tokyonight.setup({ + -- your configuration comes here + -- or leave it empty to use the default settings + style = "night", -- The theme comes in three styles, `storm`, `moon`, a darker variant `night` and `day` + light_style = "day", -- The theme is used when the background is set to light + transparent = true, -- Enable this to disable setting the background color + terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim + styles = { + -- Style to be applied to different syntax groups + -- Value is any valid attr-list value for `:help nvim_set_hl` + -- comments = { italic = true }, + comments = { italic = true }, + keywords = { italic = true }, + functions = {}, + variables = {}, + -- Background styles. Can be "dark", "transparent" or "normal" + sidebars = "transparent", -- style for sidebars, see below + floats = "transparent", -- style for floating windows + }, + sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` + day_brightness = 0.2, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors + hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. + dim_inactive = false, -- dims inactive windows + lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold + + --- You can override specific color groups to use other groups or a hex color + --- function will be called with a ColorScheme table + --@param colors ColorScheme + --on_colors = function(colors) end, + + --- You can override specific highlights to use other groups or a hex color + --- function will be called with a Highlights and ColorScheme table + --@param highlights Highlights + --@param colors ColorScheme + --on_highlights = function(highlights, colors) end, +})