nvim-config

Log | Files | Refs | Submodules | README

commit 6ef2e5a9b29570c23e1198b824817bd81824e8a4
parent 85141649924349fd75cf68c05c92808cd8a39f03
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date:   Tue,  5 Jul 2022 10:20:52 +0200

feat: refresh completion on backspace

Diffstat:
Mafter/plugin/mappings.vim | 5++++-
Mlua/mappings.lua | 19+++++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/after/plugin/mappings.vim b/after/plugin/mappings.vim @@ -1,4 +1,4 @@ -" Last Change: 2021 Dec 16 +" Last Change: 2022 Jul 05 vnoremap <silent> < <gv vnoremap <silent> > >gv @@ -12,6 +12,9 @@ inoremap <silent> <CR> <Cmd>lua cr_confirm()<CR> imap <silent> <Tab> <CMD>lua tab_complete()<CR> smap <silent> <Tab> <CMD>lua tab_complete()<CR> +imap <silent> <BS> <CMD>lua backspace()<CR> +smap <silent> <BS> <CMD>lua backspace()<CR> + smap <silent> <C-l> <Plug>luasnip-jump-next imap <silent> <C-l> <Plug>luasnip-jump-next diff --git a/lua/mappings.lua b/lua/mappings.lua @@ -1,7 +1,7 @@ -- Completion and so on -require"completree-config" -local complementree = require'complementree' -local luasnip = require'luasnip' +require "completree-config" +local complementree = require 'complementree' +local luasnip = require 'luasnip' local rt = function(codes) return vim.api.nvim_replace_termcodes(codes, true, true, true) end @@ -14,7 +14,7 @@ local function feed(codes) end local function sjump() - vim.schedule(function () + vim.schedule(function() if luasnip.jumpable(1) and luasnip.in_snippet() then luasnip.jump(1) end @@ -42,3 +42,14 @@ function cr_confirm() feed '<CR>' end end + +function backspace() + local pumvisible = vim.fn.pumvisible() + print(pumvisible) + feed '<BS>' + vim.schedule(function() + if pumvisible == 1 then + complementree.complete(true) + end + end) +end