From 7d74781eada41bc2777ddd1bd5dbdf53db12ef9f Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 29 Mar 2021 10:54:03 -0400 Subject: back to autopairs --- lua/nv-autopairs/init.lua | 72 ++++++++++++++++++++++++++++++++++++++++------ lua/nv-treesitter/init.lua | 1 + lua/plugins.lua | 4 +-- 3 files changed, 66 insertions(+), 11 deletions(-) (limited to 'lua') diff --git a/lua/nv-autopairs/init.lua b/lua/nv-autopairs/init.lua index 7fa067be..0578786d 100644 --- a/lua/nv-autopairs/init.lua +++ b/lua/nv-autopairs/init.lua @@ -40,12 +40,66 @@ -- -- remap('i' , '','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true}) -- TODO switch to lua plugin when possible -vim.cmd([[ -let g:lexima_no_default_rules = v:true -call lexima#set_default_rules() -inoremap compe#complete() -inoremap compe#confirm(lexima#expand('CR>', 'i')) -inoremap compe#close('') -inoremap compe#scroll({ 'delta': +4 }) -inoremap compe#scroll({ 'delta': -4 }) - ]]) +-- vim.cmd([[ +-- let g:lexima_no_default_rules = v:true +-- call lexima#set_default_rules() +-- inoremap compe#complete() +-- inoremap compe#confirm(lexima#expand('CR>', 'i')) +-- inoremap compe#close('') +-- inoremap compe#scroll({ 'delta': +4 }) +-- inoremap compe#scroll({ 'delta': -4 }) +-- ]]) +require('nvim-autopairs').setup() +local npairs = require('nvim-autopairs') + +local function imap(lhs, rhs, opts) + local options = {noremap = false} + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap('i', lhs, rhs, options) +end + +_G.MUtils = {} + +MUtils.completion_confirm = function() + if vim.fn.pumvisible() ~= 0 then + if vim.fn.complete_info()["selected"] ~= -1 then + vim.fn["compe#confirm"]() + return npairs.esc("") + else + vim.fn.nvim_select_popupmenu_item(0, false, false, {}) + vim.fn["compe#confirm"]() + return npairs.esc("") + end + else + return npairs.check_break_line_char() + end +end + +MUtils.tab = function() + if vim.fn.pumvisible() ~= 0 then + return npairs.esc("") + else + if vim.fn["vsnip#available"](1) ~= 0 then + return vim.fn.feedkeys(string.format('%c%c%c(vsnip-expand-or-jump)', 0x80, 253, 83)) + else + return npairs.esc("") + end + end +end + +MUtils.s_tab = function() + if vim.fn.pumvisible() ~= 0 then + return npairs.esc("") + else + if vim.fn["vsnip#jumpable"](-1) ~= 0 then + return vim.fn.feedkeys(string.format('%c%c%c(vsnip-jump-prev)', 0x80, 253, 83)) + else + return npairs.esc("") + end + end +end + +-- Autocompletion and snippets +imap("", "v:lua.MUtils.completion_confirm()", {expr = true, noremap = true}) +imap("", "v:lua.MUtils.tab()", {expr = true, noremap = true}) +imap("", "v:lua.MUtils.s_tab()", {expr = true, noremap = true}) diff --git a/lua/nv-treesitter/init.lua b/lua/nv-treesitter/init.lua index 0d08d04d..dfba7eb6 100644 --- a/lua/nv-treesitter/init.lua +++ b/lua/nv-treesitter/init.lua @@ -6,6 +6,7 @@ require'nvim-treesitter.configs'.setup { enable = true -- false will disable the whole extension }, indent = {enable = true, disable = {"python"}}, + -- indent = {enable = {"javascriptreact"}}, playground = { enable = true, disable = {}, diff --git a/lua/plugins.lua b/lua/plugins.lua index 86b14621..2f18fe35 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -112,12 +112,12 @@ return require('packer').startup(function(use) use 'monaqa/dial.nvim' use 'junegunn/goyo.vim' use 'andymass/vim-matchup' - use 'cohama/lexima.vim' + -- use 'cohama/lexima.vim' use 'MattesGroeger/vim-bookmarks' -- use 'kshenoy/vim-signature' -- use 'nelstrom/vim-visual-star-search' -- TODO switch back when config support snips - -- use 'windwp/nvim-autopairs' + use 'windwp/nvim-autopairs' -- TODO put this back when stable for indent lines -- vim.g.indent_blankline_space_char = '' -- cgit v1.2.3