From eaebce583c086dbbc44d842beb75da7864920e6a Mon Sep 17 00:00:00 2001 From: MFlossmann Date: Tue, 2 Jul 2024 17:59:36 +0200 Subject: [PATCH] fix cmp bug --- plugins/cmp.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/cmp.nix b/plugins/cmp.nix index d9b700f..9789277 100644 --- a/plugins/cmp.nix +++ b/plugins/cmp.nix @@ -38,7 +38,12 @@ _: "" = "cmp.config.disable"; "" = "cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close() }"; "" = "cmp.mapping.confirm { select = false }"; - "" = "cmp.mapping(function(fallback) + "" = ''cmp.mapping(function(fallback) + local function has_words_before() + local line, col = (unpack or table.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 + if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then cmp.select_next_item() elseif vim.snippet and vim.snippet.active { direction = 1 } then @@ -48,7 +53,7 @@ _: else fallback() end - end, { 'i', 's' })"; + end, { 'i', 's' })''; "" = "cmp.mapping(function(fallback) if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then cmp.select_prev_item()