From 5eb695beaaa6d468ce0fb85a8076012c441e1a3c Mon Sep 17 00:00:00 2001 From: zach Date: Fri, 29 May 2026 14:52:27 +0200 Subject: [PATCH] cmp and autopairs --- colors/zshell.lua | 116 +++++++++++++++++----------------- lua/config/autopairs.lua | 27 +++++++- lua/config/cmp.lua | 40 ------------ lua/config/lspconfig.lua | 21 +++++- lua/lualine/themes/zshell.lua | 20 +++--- lua/mappings.lua | 8 +-- lua/plugins/init.lua | 16 ++--- 7 files changed, 123 insertions(+), 125 deletions(-) delete mode 100644 lua/config/cmp.lua diff --git a/colors/zshell.lua b/colors/zshell.lua index 6dfe3bf..1aa5c65 100644 --- a/colors/zshell.lua +++ b/colors/zshell.lua @@ -27,82 +27,82 @@ local function pick(light, dark) end local c = { - bg = "#161219", - bg_alt = "#1E1A21", - bg_float = "#221E25", - bg_popup = "#2D2830", - bg_cursorline = pick("#2D2830", "#38333B"), - bg_fold = "#1E1A21", - bg_visual = "#543D68", - bg_search = pick("#B2417A", "#543D68"), - bg_incsearch = "#894FBF", - bg_selection = "#894FBF", - bg_statusline = pick("#2D2830", "#221E25"), - bg_statusline_nc = "#1E1A21", - bg_tabline = "#1E1A21", - bg_tabsel = "#2D2830", + bg = "#15130F", + bg_alt = "#1D1B17", + bg_float = "#221F1A", + bg_popup = "#2C2A25", + bg_cursorline = pick("#2C2A25", "#37342F"), + bg_fold = "#1D1B17", + bg_visual = "#51482F", + bg_search = pick("#35491F", "#51482F"), + bg_incsearch = "#514209", + bg_selection = "#514209", + bg_statusline = pick("#2C2A25", "#221F1A"), + bg_statusline_nc = "#1D1B17", + bg_tabline = "#1D1B17", + bg_tabsel = "#2C2A25", - fg = "#E9E0EA", - fg_muted = "#CEC3D3", - fg_subtle = "#978D9D", - fg_comment = pick("#978D9D", "#4C4451"), + fg = "#E8E2DA", + fg_muted = "#CEC6B5", + fg_subtle = "#979081", + fg_comment = pick("#979081", "#4B463A"), fg_strong = pick("#1A1B1F", "#F2F2F7"), fg_on_soft = pick("#17181C", "#F4F4F8"), - border = "#4C4451", - accent = "#DEB7FF", - accent_container = "#894FBF", - accent_fg = "#F7E7FF", - accent_solid_fg = "#4A007F", + border = "#4B463A", + accent = "#DCC580", + accent_container = "#514209", + accent_fg = "#C5AF6D", + accent_solid_fg = "#3C2F00", - secondary = "#D8BCEF", - secondary_container = "#543D68", - secondary_fg = "#C6AADD", - secondary_solid_fg = "#3C2750", + secondary = "#D2C6A5", + secondary_container = "#51482F", + secondary_fg = "#C4B897", + secondary_solid_fg = "#373019", - tertiary = "#FFB0D0", - tertiary_container = "#B2417A", - tertiary_fg = "#FFE7EE", - tertiary_solid_fg = "#63003C", + tertiary = "#B6CF98", + tertiary_container = "#35491F", + tertiary_fg = "#A0B883", + tertiary_solid_fg = "#23360E", error = "#FFB4AB", error_container = "#93000A", error_fg = "#FFDAD6", error_solid_fg = "#690005", - ok = "#FFBAC2", - warn = "#FFDCF2", - info = "#A9A5D8", - hint = "#9DCEFF", - add = "#FFBAC2", - change = "#A9A5D8", - delete = "#DE4FFD", + ok = "#E8CB46", + warn = "#FFE39D", + info = "#AAAF6E", + hint = "#D6CC72", + add = "#E8CB46", + change = "#AAAF6E", + delete = "#BE8700", - cursor_fg = "#4A007F", - cursor_bg = "#DEB7FF", - match_bg = "#B2417A", - match_fg = "#FFE7EE", - todo_bg = "#B2417A", - todo_fg = "#FFE7EE", + cursor_fg = "#3C2F00", + cursor_bg = "#DCC580", + match_bg = "#35491F", + match_fg = "#A0B883", + todo_bg = "#35491F", + todo_fg = "#A0B883", -- Syntax accents must stay dynamic. These come from your generated palette -- instead of fixed hex values, so foregrounds change with the wallpaper too. - code_keyword = "#CA98DE", - code_func = "#9DCEFF", - code_string = "#FFBAC2", - code_number = "#FFDCF2", - code_const = "#DE4FFD", - code_type = "#DEB7FF", - code_special = "#FFB0D0", - code_preproc = "#D8BCEF", - code_builtin = "#DEB7FF", - code_param = "#FFDCF2", - code_field = "#D8BCEF", - code_namespace = "#FFB0D0", - code_operator = pick("#DEB7FF", "#D8BCEF"), + code_keyword = "#DB9F46", + code_func = "#D6CC72", + code_string = "#E8CB46", + code_number = "#FFE39D", + code_const = "#BE8700", + code_type = "#DCC580", + code_special = "#B6CF98", + code_preproc = "#D2C6A5", + code_builtin = "#DCC580", + code_param = "#FFE39D", + code_field = "#D2C6A5", + code_namespace = "#B6CF98", + code_operator = pick("#DCC580", "#D2C6A5"), line_current = pick("#232428", "#E7E7EC"), - ref_bg = pick("#38333B", "#2D2830"), + ref_bg = pick("#37342F", "#2C2A25"), } -- Core UI ------------------------------------------------------------------- diff --git a/lua/config/autopairs.lua b/lua/config/autopairs.lua index 7d73a0a..eb6f876 100644 --- a/lua/config/autopairs.lua +++ b/lua/config/autopairs.lua @@ -1,3 +1,26 @@ -local npairs = require('nvim-autopairs') +local M = {} -npairs.setup({}) +M = { + disable_filetype = { + "TelescopePrompt", + "spectre_panel", + "snacks_picker_input", + }, + disable_in_macro = true, + disable_in_visualblock = false, + disable_in_replace_mode = true, + ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=], + enable_moveright = true, + enable_afterquote = true, + enable_check_bracket_line = true, + enable_bracket_in_quote = true, + enable_abbr = false, + break_undo = true, + check_ts = false, + map_cr = true, + map_bs = true, + map_c_h = false, + map_c_w = false, +} + +return M diff --git a/lua/config/cmp.lua b/lua/config/cmp.lua deleted file mode 100644 index 92924b5..0000000 --- a/lua/config/cmp.lua +++ /dev/null @@ -1,40 +0,0 @@ -local cmp_kinds = { - Text = ' ', - Method = ' ', - Function = ' ', - Constructor = ' ', - Field = ' ', - Variable = ' ', - Class = ' ', - Interface = ' ', - Module = ' ', - Property = ' ', - Unit = ' ', - Value = ' ', - Enum = ' ', - Keyword = ' ', - Snippet = ' ', - Color = ' ', - File = ' ', - Reference = ' ', - Folder = ' ', - EnumMember = ' ', - Constant = ' ', - Struct = ' ', - Event = ' ', - Operator = ' ', - TypeParameter = ' ', -} - -local cmp = require('cmp') - -cmp.setup({ - preselect = 'None', - formatting = { - fields = { 'kind', 'abbr' }, - format = function(_, vim_item) - vim_item.kind = cmp_kinds[vim_item.kind] or '' - return vim_item - end, - } -}) diff --git a/lua/config/lspconfig.lua b/lua/config/lspconfig.lua index f26ecc3..fc68cf2 100644 --- a/lua/config/lspconfig.lua +++ b/lua/config/lspconfig.lua @@ -1,6 +1,7 @@ local cmp = require "cmp" local cmp_lsp = require "cmp_nvim_lsp" local cmp_kinds = require("assets.icons").icons.kinds +local cmp_autopairs = require "nvim-autopairs.completion.cmp" local function flatten_to_array(t) local res = {} @@ -133,9 +134,22 @@ cmp.setup { [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Insert, - select = true, + [""] = cmp.mapping { + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + } + else + fallback() + end + end, + s = cmp.mapping.confirm { select = true }, + c = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, }, [""] = cmp.mapping(function(fallback) if cmp.visible() then @@ -165,6 +179,7 @@ cmp.setup { { name = "nvim_lua" }, }, } +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) vim.diagnostic.config { virtual_text = false, diff --git a/lua/lualine/themes/zshell.lua b/lua/lualine/themes/zshell.lua index dd4f22a..eb83b64 100644 --- a/lua/lualine/themes/zshell.lua +++ b/lua/lualine/themes/zshell.lua @@ -6,19 +6,19 @@ local function pick(light, dark) end local c = { - bg = "#161219", - bg_alt = "#1E1A21", - bg_mid = pick("#2D2830", "#221E25"), - fg = "#E9E0EA", - fg_muted = "#CEC3D3", + bg = "#15130F", + bg_alt = "#1D1B17", + bg_mid = pick("#2C2A25", "#221F1A"), + fg = "#E8E2DA", + fg_muted = "#CEC6B5", fg_strong = pick("#15161A", "#F4F4F8"), - normal = "#894FBF", - insert = "#543D68", - visual = "#B2417A", + normal = "#514209", + insert = "#51482F", + visual = "#35491F", replace = "#93000A", - command = pick("#FFDCF2", "#A9A5D8"), - inactive = "#1E1A21", + command = pick("#FFE39D", "#AAAF6E"), + inactive = "#1D1B17", normal_fg = pick("#15161A", "#F4F4F8"), insert_fg = pick("#15161A", "#F4F4F8"), diff --git a/lua/mappings.lua b/lua/mappings.lua index 18f80df..b52bc03 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -19,10 +19,10 @@ vim.keymap.set("n", "", require("smart-splits").resize_left) vim.keymap.set("n", "", require("smart-splits").resize_down) vim.keymap.set("n", "", require("smart-splits").resize_up) vim.keymap.set("n", "", require("smart-splits").resize_right) -vim.keymap.set("n", "", require("smart-splits").move_cursor_left) -vim.keymap.set("n", "", require("smart-splits").move_cursor_down) -vim.keymap.set("n", "", require("smart-splits").move_cursor_up) -vim.keymap.set("n", "", require("smart-splits").move_cursor_right) +-- vim.keymap.set("n", "", require("smart-splits").move_cursor_left) +-- vim.keymap.set("n", "", require("smart-splits").move_cursor_down) +-- vim.keymap.set("n", "", require("smart-splits").move_cursor_up) +-- vim.keymap.set("n", "", require("smart-splits").move_cursor_right) -- Explorer and Undotree map("n", "e", function() diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index a31a62f..81c2f14 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -70,13 +70,6 @@ return { "hiphish/rainbow-delimiters.nvim", enabled = false, }, - { - "windwp/nvim-autopairs", - event = "InsertEnter", - config = function() - require "config.autopairs" - end, - }, { "tpope/vim-fugitive", }, @@ -116,6 +109,13 @@ return { require "config.lazydev" end, }, + { + "windwp/nvim-autopairs", + enabled = true, + event = "InsertEnter", + config = true, + opts = require "config.autopairs", + }, { "neovim/nvim-lspconfig", enabled = true, @@ -131,6 +131,7 @@ return { "saadparwaiz1/cmp_luasnip", "j-hui/fidget.nvim", "b0o/schemastore.nvim", + "windwp/nvim-autopairs", }, config = function() require "config.lspconfig" @@ -288,7 +289,6 @@ return { }, { "Zacharias-Brohn/zterm-navigator.nvim", - enabled = false, config = function() require "config.zterm-navigator" end,