From e190194068b85ddeea633fde02f70456c33a8ae1 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 15 Jul 2023 15:38:26 +0800 Subject: [PATCH] feat(ui)!: improve user experience wrt transparent bg As per #864. Using the alternative method. --- lua/core/event.lua | 2 +- lua/core/options.lua | 4 ++-- lua/modules/configs/ui/bufferline.lua | 2 +- lua/modules/configs/ui/catppuccin.lua | 1 + lua/modules/configs/ui/lualine.lua | 6 +++--- lua/modules/configs/ui/notify.lua | 12 ++++++++---- lua/modules/configs/ui/scrollview.lua | 2 +- lua/modules/configs/ui/specs.lua | 2 +- lua/modules/utils/icons.lua | 1 - 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index 747dd7026..b1d8dd9ca 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -29,7 +29,7 @@ vim.api.nvim_create_autocmd("BufEnter", { local layout = vim.api.nvim_call_function("winlayout", {}) if layout[1] == "leaf" - and vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(layout[2]), "filetype") == "NvimTree" + and vim.api.nvim_get_option_value("filetype", { buf = vim.api.nvim_win_get_buf(layout[2]) }) == "NvimTree" and layout[3] == nil then vim.api.nvim_command([[confirm quit]]) diff --git a/lua/core/options.lua b/lua/core/options.lua index 0e11db13b..47ca19e72 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -4,10 +4,8 @@ local function load_options() local global_local = { -- backupdir = global.cache_dir .. "backup/", -- directory = global.cache_dir .. "swap/", - -- pumblend = 10, -- spellfile = global.cache_dir .. "spell/en.uft-8.add", -- viewdir = global.cache_dir .. "view/", - -- winblend = 10, autoindent = true, autoread = true, autowrite = true, @@ -53,6 +51,7 @@ local function load_options() mousescroll = "ver:3,hor:6", number = true, previewheight = 12, + pumblend = 10, pumheight = 15, redrawtime = 1500, relativenumber = true, @@ -95,6 +94,7 @@ local function load_options() whichwrap = "h,l,<,>,[,],~", wildignore = ".git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**,**/bower_modules/**", wildignorecase = true, + winblend = 10, winminwidth = 10, winwidth = 30, wrap = false, diff --git a/lua/modules/configs/ui/bufferline.lua b/lua/modules/configs/ui/bufferline.lua index 7ceabab57..41dc9b0ff 100644 --- a/lua/modules/configs/ui/bufferline.lua +++ b/lua/modules/configs/ui/bufferline.lua @@ -51,7 +51,7 @@ return function() highlights = require("catppuccin.groups.integrations.bufferline").get({ styles = { "italic", "bold" }, custom = { - mocha = { + all = { -- Hint hint = { fg = cp.rosewater }, hint_visible = { fg = cp.rosewater }, diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index 2513c4304..940e16f78 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -141,6 +141,7 @@ return function() TroubleNormal = { bg = transparent_background and cp.none or cp.base }, -- For telescope.nvim + TelescopeMatching = { fg = cp.lavender }, TelescopeResultsDiffAdd = { fg = cp.green }, TelescopeResultsDiffChange = { fg = cp.yellow }, TelescopeResultsDiffDelete = { fg = cp.red }, diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index 6de3d6890..ea09ef778 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -168,7 +168,7 @@ return function() lsp = { function() - local buf_ft = vim.api.nvim_buf_get_option(0, "filetype") + local buf_ft = vim.api.nvim_get_option_value("filetype", { scope = "local" }) local clients = vim.lsp.get_active_clients() local lsp_lists = {} local available_servers = {} @@ -206,7 +206,7 @@ return function() return venv end - if vim.api.nvim_buf_get_option(0, "filetype") == "python" then + if vim.api.nvim_get_option_value("filetype", { scope = "local" }) == "python" then local venv = os.getenv("CONDA_DEFAULT_ENV") if venv then return string.format("%s", env_cleanup(venv)) @@ -224,7 +224,7 @@ return function() tabwidth = { function() - return icons.ui.Tab .. vim.api.nvim_buf_get_option(0, "shiftwidth") + return icons.ui.Tab .. vim.api.nvim_get_option_value("shiftwidth", { scope = "local" }) end, padding = 1, }, diff --git a/lua/modules/configs/ui/notify.lua b/lua/modules/configs/ui/notify.lua index dce23e9fe..21f6168e9 100644 --- a/lua/modules/configs/ui/notify.lua +++ b/lua/modules/configs/ui/notify.lua @@ -1,5 +1,6 @@ return function() local notify = require("notify") + local colors = require("modules.utils").get_palette() local icons = { diagnostics = require("modules.utils.icons").get("diagnostics"), ui = require("modules.utils.icons").get("ui"), @@ -7,19 +8,22 @@ return function() notify.setup({ ---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" } - stages = "slide", + stages = "fade", ---@usage Function called when a new window is opened, use for changing win settings/config - on_open = nil, + on_open = function(win) + vim.api.nvim_set_option_value("winblend", 0, { scope = "local", win = win }) + vim.api.nvim_win_set_config(win, { zindex = 90 }) + end, ---@usage Function called when a window is closed on_close = nil, ---@usage timeout for notifications in ms, default 5000 timeout = 2000, -- @usage User render fps value - fps = 30, + fps = 20, -- Render function for notifications. See notify-render() render = "default", ---@usage highlight behind the window for stages that change opacity - background_colour = "Normal", + background_colour = colors.base, ---@usage minimum width for notification windows minimum_width = 50, ---@usage notifications with level lower than this would be ignored. [ERROR > WARN > INFO > DEBUG > TRACE] diff --git a/lua/modules/configs/ui/scrollview.lua b/lua/modules/configs/ui/scrollview.lua index b99232731..69a81fd83 100644 --- a/lua/modules/configs/ui/scrollview.lua +++ b/lua/modules/configs/ui/scrollview.lua @@ -4,7 +4,7 @@ return function() require("scrollview").setup({ scrollview_mode = "virtual", excluded_filetypes = { "NvimTree", "terminal", "nofile" }, - winblend = 55, + winblend = 0, signs_on_startup = { "diagnostics", "folds", "marks", "search", "spell" }, diagnostics_error_symbol = icons.diagnostics.Error, diagnostics_warn_symbol = icons.diagnostics.Warning, diff --git a/lua/modules/configs/ui/specs.lua b/lua/modules/configs/ui/specs.lua index 5626c2213..e32382b1b 100644 --- a/lua/modules/configs/ui/specs.lua +++ b/lua/modules/configs/ui/specs.lua @@ -7,7 +7,7 @@ return function() inc_ms = 10, -- time increments used for fade/resize effects blend = 10, -- starting blend, between 0-100 (fully transparent), see :h winblend width = 10, - winhl = "PMenu", + winhl = "PmenuSbar", fader = require("specs").pulse_fader, resizer = require("specs").shrink_resizer, }, diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index c2bf8fb8d..91671d06c 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -147,7 +147,6 @@ local data = { misc = { Campass = "󰀹", Code = "", - EscapeST = "", Gavel = "", Glass = "󰂖", NoActiveLsp = "󱚧",