diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 9601b9a..71044ae 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -46,6 +46,8 @@ return require('packer').startup(function() end } + + -- cmp use { 'hrsh7th/nvim-cmp', requires = { @@ -57,104 +59,9 @@ return require('packer').startup(function() 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', }, - config = function() - local cmp = require'cmp' - local luasnip = require'luasnip' - - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil - end - - cmp.setup({ - - formatting = { - format = require('lspkind').cmp_format({ - with_text = true, - menu = { - buffer = "[Buffer]", - tmux = "[Tmux]", - luasnip = "[LuaSnip]", - nvim_lsp = "[LSP]", - nvim_lua = "[Lua]", - path = "[Path]", - }, - }), - }, - - documentation = { - border = 'rounded' - }, - - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - - mapping = { - [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }, - - sources = cmp.config.sources({ - { - name = 'buffer', - priority = 1, - - }, - { - name = 'luasnip', - priority = 4, - }, - { - name = 'tmux', - priority = 2, - option = { - all_panes = true, - trigger_characters = {}, - } - }, - { - name = 'nvim_lsp', - priority = 3, - }, - }) - }) - - end + config = function() require("plugins/nvim-cmp") end, } - use { 'lewis6991/gitsigns.nvim', requires = { diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..cb86e19 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,98 @@ +local cmp = require'cmp' +local luasnip = require'luasnip' + +local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil +end + +cmp.setup({ + formatting = { + format = require('lspkind').cmp_format({ + with_text = true, + menu = { + buffer = "[Buffer]", + tmux = "[Tmux]", + luasnip = "[LuaSnip]", + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + path = "[Path]", + }, + }), + }, + + window = { + completion = cmp.config.window.bordered({ + winhighlight = 'Normal:PMenu,FloatBorder:PMenuBorder,CursorLine:PMenuSel,Search:None', + }), + documentation = cmp.config.window.bordered({ + winhighlight = 'Normal:PMenu,FloatBorder:PMenu,CursorLine:PMenuSel,Search:None', + }), + }, + + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + + mapping = { + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, + + sources = cmp.config.sources({ + { + name = 'buffer', + priority = 1, + + }, + { + name = 'luasnip', + priority = 4, + }, + { + name = 'tmux', + priority = 2, + option = { + all_panes = true, + trigger_characters = {}, + } + }, + { + name = 'nvim_lsp', + priority = 3, + }, + }) +}) diff --git a/.config/nvim/lua/plugins/zenbones.lua b/.config/nvim/lua/plugins/zenbones.lua index 27ef678..c23b149 100644 --- a/.config/nvim/lua/plugins/zenbones.lua +++ b/.config/nvim/lua/plugins/zenbones.lua @@ -39,7 +39,9 @@ local specs = lush.parse(function() GitSignsDeleteNr { fg = "#FFCDD2" }, GitSignsChange { fg = "#FFA726" }, GitSignsChangeNr { fg = "#FFE0B2" }, - PMenu { bg = "#BBDEFB" }, + + PMenu { bg = "#F7F5F0" }, + PMenuBorder { bg = "#F7F5F0", fg = "#886622" }, PMenuSel { fg = "#FFFFFF", bg = "#1976D2" }, PMenuSbar { bg = "#90CAF9" }, PMenuThumb { bg = "#64B5F6" },