From d3465ff5cd4763fb0264c9374ecb04588cbd9187 Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Sat, 15 Feb 2025 17:20:09 +0100 Subject: [PATCH] lots of changes --- coc-settings.json | 5 +- init.lua | 11 +++- lazy-lock.json | 14 ++--- lua/config/barbar.lua | 76 +++++++++--------------- lua/config/lualine.lua | 119 ++++++++------------------------------ lua/config/themelight.lua | 40 +------------ lua/globals.lua | 12 +--- lua/mappings.lua | 9 +-- lua/plugins/init.lua | 81 +++++++++++++++++++++----- 9 files changed, 144 insertions(+), 223 deletions(-) diff --git a/coc-settings.json b/coc-settings.json index 53f915a..c7b7285 100644 --- a/coc-settings.json +++ b/coc-settings.json @@ -4,5 +4,8 @@ "command": "hyprls", "filetypes": ["hyprlang"] } - } + }, + "git.addedSign.hlGroup": "GitGutterAdd", + "git.changedSign.hlGroup": "GitGutterChange", + "git.removedSign.hlGroup": "GitGutterDelete", } diff --git a/init.lua b/init.lua index d832c00..b27f93e 100644 --- a/init.lua +++ b/init.lua @@ -12,11 +12,16 @@ vim.filetype.add({ } }) -if time >= 10 and time < 20 then +if time >= 10 and time < 16 then vim.o.background = "light" - vim.cmd[[colorscheme onedark]] + vim.cmd[[colorscheme one_light]] else vim.o.background = "dark" - vim.cmd[[colorscheme gruvbox-material]] + vim.cmd[[colorscheme gruvbox]] end +local bg_color = vim.api.nvim_get_hl_by_name('Normal', true).background + +vim.api.nvim_set_hl(0, 'WinSeparator', { fg = vim.api.nvim_get_hl_by_name('NvimTreeEndOfBuffer', true).foreground, bg = 'NONE' }) +vim.api.nvim_set_hl(0, 'NvimTreeWinSeparator', { fg = bg_color, bg = 'NONE' }) +vim.api.nvim_set_hl(0, 'NvimTreeCursorLine', { bg = vim.api.nvim_get_hl_by_name('CursorLine', true).background }) diff --git a/lazy-lock.json b/lazy-lock.json index c38c8a1..c00d0bb 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,23 +1,23 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "804d9067d1eef0ee21dc39b5bbc86ab9f52287b7" }, + "CopilotChat.nvim": { "branch": "main", "commit": "7e6583c75f1231ea1eac70e06995dd3f97a58478" }, "auto-session": { "branch": "main", "commit": "9c3f977aafb56bd73ba0d082c4dcbdba5666faf3" }, - "barbar.nvim": { "branch": "master", "commit": "807bede7ef1d8e2ac5f108e9ac8123b1e2d321e3" }, + "base46-colors": { "branch": "main", "commit": "131ca742f6e8d1eb4c938a2519a94840ba129c2f" }, + "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "coc.nvim": { "branch": "release", "commit": "408e2506338a137b607a00dffe3bad56518a6686" }, "copilot.lua": { "branch": "master", "commit": "30321e33b03cb924fdcd6a806a0dc6fa0b0eafb9" }, - "gruvbox-material": { "branch": "master", "commit": "1aa1842d80a8845842b9340df2d93683d667247b" }, - "indent-blankline.nvim": { "branch": "master", "commit": "e10626f7fcd51ccd56d7ffc00883ba7e0aa28f78" }, - "lazy.nvim": { "branch": "main", "commit": "f15a93907ddad3d9139aea465ae18336d87f5ce6" }, + "lazy.nvim": { "branch": "main", "commit": "ac21a639c7ecfc8b822dcc9455deceea3778f839" }, "lightline-gruvbox.vim": { "branch": "master", "commit": "d233416d566e61f879bd19d9d498b01b1b7e336c" }, "lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" }, "nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" }, "nvim-dap": { "branch": "master", "commit": "52302f02fea3a490e55475de52fa4deb8af2eb11" }, "nvim-notify": { "branch": "master", "commit": "22f29093eae7785773ee9d543f8750348b1a195c" }, "nvim-tree.lua": { "branch": "master", "commit": "80523101f0ae48b7f1990e907b685a3d79776c01" }, - "nvim-treesitter": { "branch": "master", "commit": "80e6de9d24eec68d82d5f4e6feae94c9c753ebd6" }, + "nvim-treesitter": { "branch": "master", "commit": "00a513f87ee3c339c2024b08db3eb63ba7736ed6" }, "nvim-web-devicons": { "branch": "master", "commit": "1020869742ecb191f260818234517f4a1515cfe8" }, - "onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, + "onedarkpro.nvim": { "branch": "main", "commit": "992780fb5b28abcef125271c8c2c41e302c2df26" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "011d98eaa3a73b5a51d82ce5bc6b1397dde95562" }, + "snacks.nvim": { "branch": "main", "commit": "57445057395fd1f5b315defa367c57651ea2e5f2" }, "telescope.nvim": { "branch": "master", "commit": "78857db9e8d819d3cc1a9a7bdc1d39d127a36495" }, "undotree": { "branch": "main", "commit": "eab459ab87dd249617b5f7187bb69e614a083047" }, "vim-fugitive": { "branch": "master", "commit": "b068eaf1e6cbe35d1ac100d435cd7f7b74a5c87d" }, diff --git a/lua/config/barbar.lua b/lua/config/barbar.lua index 25f0d68..2082713 100644 --- a/lua/config/barbar.lua +++ b/lua/config/barbar.lua @@ -1,52 +1,30 @@ -require("barbar").setup ({ - animation = true, - auto_hide = false, - tabpages = true, - clickable = true, - exclude_ft = { "NvimTree" }, - focus_on_close = 'left', - highlight_alternate = false, - highlight_inactive_file_icons = true, - highlight_visible = true, - icons = { - buffer_index = false, - buffer_number = false, - button = '', - diagnostics = { - [vim.diagnostic.severity.ERROR] = {enabled = true, icon = 'ff'}, - [vim.diagnostic.severity.WARN] = {enabled = false}, - [vim.diagnostic.severity.INFO] = {enabled = false}, - [vim.diagnostic.severity.HINT] = {enabled = true}, - }, - gitsigns = { - added = {enabled = true, icon = '+'}, - changed = {enabled = true, icon = '~'}, - deleted = {enabled = true, icon = '-'}, - }, - filetype = { - custom_colors = false, - enabled = true, - }, - separator = {left = '▏', right = ''}, - separator_at_end = true, - modified = {button = '●'}, - pinned = {button = '', filename = true}, - preset = 'default', - alternate = {filetype = {enabled = true}}, - current = {buffer_index = false}, - inactive = {button = '×', filetype = {enabled = true}, separator = {left = '▏', right = ''} }, - visible = {modified = {buffer_number = false}}, - }, - insert_at_end = true, - maximum_padding = 1, - minimum_padding = 1, - maximum_length = 15, - minimum_length = 15, - sidebar_filetypes = { - NvimTree = true, - undotree = { - text = "undotree", - align = "center", +require("bufferline").setup ({ + options = { + diagnostics = "nvim_lsp", + always_show_bufferline = true, + diagnostics_indicator = function(_, _, diag) + local icons = LazyVim.config.icons.diagnostics + local ret = (diag.error and icons.Error .. diag.error .. " " or "") + .. (diag.warning and icons.Warn .. diag.warning or "") + return vim.trim(ret) + end, + offsets = { + { + filetype = "neo-tree", + text = "Neo-tree", + highlight = "Directory", + text_align = "left", + }, + { + filetype = "snacks_layout_box", + }, }, + vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete" }, { + callback = function() + vim.schedule(function() + pcall(nvim_bufferline) + end) + end, + }) }, }) diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua index c8d4a18..bc27c7c 100644 --- a/lua/config/lualine.lua +++ b/lua/config/lualine.lua @@ -1,5 +1,18 @@ local fn = vim.fn +local function get_coc_lsp_client() + local clients = vim.g.coc_service_initialized and vim.fn['CocAction']('services') or {} + for _, client in pairs(clients) do + if client['state'] == 'running' then + local client_name = client['id'] + -- Remove 'languageserver.' prefix if it exists + client_name = client_name:gsub('^languageserver%.', '') + return client_name + end + end + return '' +end + local function spell() if vim.o.spell then return string.format("[SPELL]") @@ -11,12 +24,7 @@ end --- show indicator for Chinese IME local function ime_state() if vim.g.is_mac then - -- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11 local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "") - - -- We can use `xkbswitch -g` on the command line to get current mode. - -- mode for macOS builtin pinyin IME: com.apple.inputmethod.SCIM.ITABC - -- mode for Rime: im.rime.inputmethod.Squirrel.Rime local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]]) if res ~= -1 then return "[CN]" @@ -26,62 +34,6 @@ local function ime_state() return "" end -local function trailing_space() - if not vim.o.modifiable then - return "" - end - - local line_num = nil - - for i = 1, fn.line("$") do - local linetext = fn.getline(i) - -- To prevent invalid escape error, we wrap the regex string with `[[]]`. - local idx = fn.match(linetext, [[\v\s+$]]) - - if idx ~= -1 then - line_num = i - break - end - end - - local msg = "" - if line_num ~= nil then - msg = string.format("[%d]trailing", line_num) - end - - return msg -end - -local function mixed_indent() - if not vim.o.modifiable then - return "" - end - - local space_pat = [[\v^ +]] - local tab_pat = [[\v^\t+]] - local space_indent = fn.search(space_pat, "nwc") - local tab_indent = fn.search(tab_pat, "nwc") - local mixed = (space_indent > 0 and tab_indent > 0) - local mixed_same_line - if not mixed then - mixed_same_line = fn.search([[\v^(\t+ | +\t)]], "nwc") - mixed = mixed_same_line > 0 - end - if not mixed then - return "" - end - if mixed_same_line ~= nil and mixed_same_line > 0 then - return "MI:" .. mixed_same_line - end - local space_indent_cnt = fn.searchcount({ pattern = space_pat, max_count = 1e3 }).total - local tab_indent_cnt = fn.searchcount({ pattern = tab_pat, max_count = 1e3 }).total - if space_indent_cnt > tab_indent_cnt then - return "MI:" .. tab_indent - else - return "MI:" .. space_indent - end -end - local diff = function() local git_status = vim.b.gitsigns_status_dict if git_status == nil then @@ -118,36 +70,21 @@ local virtual_env = function() 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 - ---@diagnostic disable-next-line: undefined-field - 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 = "", + globalstatus = true, + component_separators = '', + section_separators = { left = '', right = '' }, disabled_filetypes = {}, always_divide_middle = true, }, sections = { lualine_a = { - "mode", + { + "mode", + }, }, lualine_b = { { @@ -157,6 +94,7 @@ require("lualine").setup { return string.sub(name, 1, 20) end, color = { gui = "italic,bold" }, + separator = { right = "" }, }, { virtual_env, @@ -189,7 +127,7 @@ require("lualine").setup { color = { fg = "black", bg = "#f46868" }, }, { - get_active_lsp, + get_coc_lsp_client, icon = " LSP:", }, { @@ -203,23 +141,14 @@ require("lualine").setup { { "fileformat", symbols = { - unix = "unix", - dos = "win", - mac = "mac", + unix = "", + dos = "", + mac = "", }, }, "filetype", }, lualine_z = { - { - trailing_space, - color = "WarningMsg", - }, - { - mixed_indent, - color = "WarningMsg", - }, - "location", "progress", }, }, diff --git a/lua/config/themelight.lua b/lua/config/themelight.lua index fdc2ba4..23e7764 100644 --- a/lua/config/themelight.lua +++ b/lua/config/themelight.lua @@ -1,40 +1,2 @@ -- Lua -require('onedark').setup { - -- Main options -- - style = 'light', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light' - transparent = false, -- Show/hide background - term_colors = true, -- Change terminal color as per the selected theme style - ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden - cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu - - -- toggle theme style --- - toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "ts" - toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}, -- List of styles to toggle between - - -- Change code style --- - -- Options are italic, bold, underline, none - -- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold' - code_style = { - comments = 'italic', - keywords = 'none', - functions = 'none', - strings = 'none', - variables = 'none' - }, - - -- Lualine options -- - lualine = { - transparent = false, -- lualine center bar transparency - }, - - -- Custom Highlights -- - colors = {}, -- Override default colors - highlights = {}, -- Override highlight groups - - -- Plugins Config -- - diagnostics = { - darker = true, -- darker colors for diagnostic - undercurl = true, -- use undercurl instead of underline for diagnostics - background = true, -- use background color for virtual text - }, -} +require('onedarkpro').setup({}) diff --git a/lua/globals.lua b/lua/globals.lua index ceee7b5..c44b861 100644 --- a/lua/globals.lua +++ b/lua/globals.lua @@ -6,12 +6,6 @@ vim.g.mapleader = " " vim.g.gruvbox_material_background = "medium" vim.g.coq_settings = { keymap = { recommended = false } } vim.g.gruvbox_material_foreground = "original" --- if time >= 10 and time < 20 then --- vim.g.lightline = { --- colorscheme = "one", --- } --- else --- vim.g.lightline = { --- colorscheme = "gruvbox", --- } --- end +vim.api.nvim_set_hl(0, 'GitGutterAdd', { fg = '#009900', ctermfg = 2 }) +vim.api.nvim_set_hl(0, 'GitGutterChange', { fg = '#bbbb00', ctermfg = 3 }) +vim.api.nvim_set_hl(0, 'GitGutterDelete', { fg = '#ff2222', ctermfg = 1 }) diff --git a/lua/mappings.lua b/lua/mappings.lua index 17690d1..319d722 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -1,7 +1,7 @@ local map = vim.keymap.set -map("n", "", ":BufferNext") -map("n", "", ":BufferPrevious") +map("n", "", "BufferLineCycleNext") +map("n", "", "BufferLineCyclePrev") map("n", ";", ":", { desc = "CMD enter command mode" }) @@ -21,10 +21,11 @@ map("i", "", vim.cmd.CopilotChatToggle) map("v", "", vim.cmd.CopilotChatToggle) map('n', 'e', vim.cmd.NvimTreeToggle) +-- map('n', 'e', function() Snacks.explorer() end) map('n', 'u', require('undotree').toggle, { noremap = true, silent = true }) -map("n", "", ":BufferClose") -map("n", "", ":BufferRestore") +map("n", "", ":bdelete") +-- map("n", "", ":BufferRestore") map("n", "", "ggVG", { noremap = true, silent = true }) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index afd4ef3..2638daa 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -16,11 +16,11 @@ return { "neoclide/coc.nvim", branch = 'release', }, + -- { + -- "sainnhe/gruvbox-material", + -- }, { - "sainnhe/gruvbox-material", - }, - { - "navarasu/onedark.nvim", + "olimorris/onedarkpro.nvim", config = function() require("config.themelight") end, @@ -48,8 +48,8 @@ return { end, }, { - "romgrk/barbar.nvim", - init = function() vim.g.barbar_auto_setup = false end, + "akinsho/bufferline.nvim", + event = "VeryLazy", config = function() require("config.barbar") end, @@ -73,15 +73,15 @@ return { require("config.undotree") end, }, - { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", - ---@module "ibl" - ---@type ibl.config - config = function() - require("config.indent-blankline") - end, - }, + -- { + -- "lukas-reineke/indent-blankline.nvim", + -- main = "ibl", + -- ---@module "ibl" + -- ---@type ibl.config + -- config = function() + -- require("config.indent-blankline") + -- end, + -- }, { "hiphish/rainbow-delimiters.nvim", }, @@ -124,7 +124,56 @@ return { { "mfussenegger/nvim-dap", config = function() - require "config.dap" + require("config.dap") end, }, + { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + animate = { + enabled = true, + fps = 144, + easing = "inExpo", + duration = 20, + }, + bigfile = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + dashboard = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + explorer = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + indent = { + enabled = true, + scope = { + enabled = false, + underline = true, + }, + chunk = { + enabled = true, + char = { + corner_top = "╭", + corner_bottom = "╰", + + vertical = "│", + arrow = "╼", + }, + }, + animate = { + easing = "linear", + duration = 10, + } + }, + input = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + picker = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + notifier = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + quickfile = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + scope = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + scroll = { enabled = true, animate = { easing = "linear", duration = 5 } }, + statuscolumn = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + words = { enabled = true, animate = { easing = "inExpo", duration = 20 } }, + }, + }, + { + "notken12/base46-colors", + }, }