diff options
| -rw-r--r-- | lua/lv-autopairs/init.lua | 156 | ||||
| -rw-r--r-- | lua/lv-compe/init.lua | 96 | ||||
| -rw-r--r-- | lua/plugins.lua | 1 | 
3 files changed, 162 insertions, 91 deletions
| diff --git a/lua/lv-autopairs/init.lua b/lua/lv-autopairs/init.lua index 5d0adf85..c3f6a6e0 100644 --- a/lua/lv-autopairs/init.lua +++ b/lua/lv-autopairs/init.lua @@ -1,77 +1,99 @@ -require('nvim-autopairs').setup() -local npairs = require('nvim-autopairs') +-- 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 +-- 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 = {} +-- _G.MUtils = {} --- TEST -vim.g.completion_confirm_key = "" -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("<c-y>") -            return npairs.esc("") -        else -            vim.defer_fn(function() -                vim.fn["compe#confirm"]("<cr>") -            end, 20) -            return npairs.esc("<c-n>") -        end -    else -        return npairs.check_break_line_char() -    end -end --- TEST +-- -- TEST +-- vim.g.completion_confirm_key = "" +-- 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("<c-y>") +--             return npairs.esc("") +--         else +--             vim.defer_fn(function() +--                 vim.fn["compe#confirm"]("<cr>") +--             end, 20) +--             return npairs.esc("<c-n>") +--         end +--     else +--         return npairs.check_break_line_char() +--     end +-- end +-- -- TEST -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.api.nvim_select_popupmenu_item(0, false, false, {}) -            vim.fn["compe#confirm"]() -            return npairs.esc("<c-n>") -        end -    else -        return npairs.check_break_line_char() -    end -end +-- 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.api.nvim_select_popupmenu_item(0, false, false, {}) +--             vim.fn["compe#confirm"]() +--             return npairs.esc("<c-n>") +--         end +--     else +--         return npairs.check_break_line_char() +--     end +-- end -MUtils.tab = function() -    if vim.fn.pumvisible() ~= 0 then -        return npairs.esc("<C-n>") -    else -        if vim.fn["vsnip#available"](1) ~= 0 then -            vim.fn.feedkeys(string.format('%c%c%c(vsnip-expand-or-jump)', 0x80, 253, 83)) -            return npairs.esc("") -        else -            return npairs.esc("<Tab>") -        end -    end -end +-- MUtils.tab = function() +--     if vim.fn.pumvisible() ~= 0 then +--         return npairs.esc("<C-n>") +--     else +--         if vim.fn["vsnip#available"](1) ~= 0 then +--             vim.fn.feedkeys(string.format('%c%c%c(vsnip-expand-or-jump)', 0x80, 253, 83)) +--             return npairs.esc("") +--         else +--             return npairs.esc("<Tab>") +--         end +--     end +-- end + +-- MUtils.s_tab = function() +--     if vim.fn.pumvisible() ~= 0 then +--         return npairs.esc("<C-p>") +--     else +--         if vim.fn["vsnip#jumpable"](-1) ~= 0 then +--             vim.fn.feedkeys(string.format('%c%c%c(vsnip-jump-prev)', 0x80, 253, 83)) +--             return npairs.esc("") +--         else +--             return npairs.esc("<C-h>") +--         end +--     end +-- end -MUtils.s_tab = function() -    if vim.fn.pumvisible() ~= 0 then -        return npairs.esc("<C-p>") +-- -- Autocompletion and snippets +-- vim.api.nvim_set_keymap('i', '<CR>', 'v:lua.MUtils.completion_confirm()', {expr = true, noremap = true}) +-- -- imap("<CR>", "v:lua.MUtils.completion_confirm()", {expr = true, noremap = true}) +-- imap("<Tab>", "v:lua.MUtils.tab()", {expr = true, noremap = true}) +-- imap("<S-Tab>", "v:lua.MUtils.s_tab()", {expr = true, noremap = true}) + +local remap = vim.api.nvim_set_keymap +local npairs = require('nvim-autopairs') + +-- skip it, if you use another global object +_G.MUtils= {} + +vim.g.completion_confirm_key = "" +MUtils.completion_confirm=function() +  if vim.fn.pumvisible() ~= 0  then +    if vim.fn.complete_info()["selected"] ~= -1 then +      return vim.fn["compe#confirm"](npairs.esc("<cr>"))      else -        if vim.fn["vsnip#jumpable"](-1) ~= 0 then -            vim.fn.feedkeys(string.format('%c%c%c(vsnip-jump-prev)', 0x80, 253, 83)) -            return npairs.esc("") -        else -            return npairs.esc("<C-h>") -        end +      return npairs.esc("<cr>")      end +  else +    return npairs.autopairs_cr() +  end  end --- Autocompletion and snippets -vim.api.nvim_set_keymap('i', '<CR>', 'v:lua.MUtils.completion_confirm()', {expr = true, noremap = true}) --- imap("<CR>", "v:lua.MUtils.completion_confirm()", {expr = true, noremap = true}) -imap("<Tab>", "v:lua.MUtils.tab()", {expr = true, noremap = true}) -imap("<S-Tab>", "v:lua.MUtils.s_tab()", {expr = true, noremap = true}) + +remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true}) diff --git a/lua/lv-compe/init.lua b/lua/lv-compe/init.lua index 61270960..d3865058 100644 --- a/lua/lv-compe/init.lua +++ b/lua/lv-compe/init.lua @@ -15,20 +15,20 @@ require'compe'.setup {      documentation = true,      source = { -        path = {kind = "  "}, -        buffer = {kind = "  "}, -        calc = {kind = "  "}, -        vsnip = {kind = "  "}, -        nvim_lsp = {kind = "  "}, +        path = {kind = "   (Path)"}, +        buffer = {kind = "   (Buffer)"}, +        calc = {kind = "   (Calc)"}, +        vsnip = {kind = "   (Snippet)"}, +        nvim_lsp = {kind = "   (LSP)"},          -- nvim_lua = {kind = "  "},  		nvim_lua = false, -        spell = {kind = "  "}, +        spell = {kind = "   (Spell)"},          tags = false,          vim_dadbod_completion = true,          -- snippets_nvim = {kind = "  "},          -- ultisnips = {kind = "  "},          -- treesitter = {kind = "  "}, -        emoji = {kind = " ﲃ ", filetypes={"markdown", "text"}} +        emoji = {kind = " ﲃ  (Emoji)", filetypes={"markdown", "text"}}          -- for emoji press : (idk if that in compe tho)      }  } @@ -59,8 +59,56 @@ require'compe'.setup {  --   --  +-- local t = function(str) +--     return vim.api.nvim_replace_termcodes(str, true, true, true) +-- end + +-- local check_back_space = function() +--     local col = vim.fn.col('.') - 1 +--     if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then +--         return true +--     else +--         return false +--     end +-- end + +-- -- Use (s-)tab to: +-- --- move to prev/next item in completion menuone +-- --- jump to prev/next snippet's placeholder +-- _G.tab_complete = function() +--     if vim.fn.pumvisible() == 1 then +--         return t "<C-n>" +--     elseif vim.fn.call("vsnip#available", {1}) == 1 then +--         return t "<Plug>(vsnip-expand-or-jump)" +--     elseif check_back_space() then +--         return t "<Tab>" +--     else +--         return vim.fn['compe#complete']() +--     end +-- end +-- _G.s_tab_complete = function() +--     if vim.fn.pumvisible() == 1 then +--         return t "<C-p>" +--     elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then +--         return t "<Plug>(vsnip-jump-prev)" +--     else +--         return t "<S-Tab>" +--     end +-- end + +-- vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true}) +-- vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true}) +-- vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) +-- vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) + + + + + + +  local t = function(str) -    return vim.api.nvim_replace_termcodes(str, true, true, true) +  return vim.api.nvim_replace_termcodes(str, true, true, true)  end  local check_back_space = function() @@ -76,24 +124,24 @@ end  --- move to prev/next item in completion menuone  --- jump to prev/next snippet's placeholder  _G.tab_complete = function() -    if vim.fn.pumvisible() == 1 then -        return t "<C-n>" -    elseif vim.fn.call("vsnip#available", {1}) == 1 then -        return t "<Plug>(vsnip-expand-or-jump)" -    elseif check_back_space() then -        return t "<Tab>" -    else -        return vim.fn['compe#complete']() -    end +  if vim.fn.pumvisible() == 1 then +    return t "<C-n>" +  elseif vim.fn.call("vsnip#available", {1}) == 1 then +    return t "<Plug>(vsnip-expand-or-jump)" +  elseif check_back_space() then +    return t "<Tab>" +  else +    return vim.fn['compe#complete']() +  end  end  _G.s_tab_complete = function() -    if vim.fn.pumvisible() == 1 then -        return t "<C-p>" -    elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then -        return t "<Plug>(vsnip-jump-prev)" -    else -        return t "<S-Tab>" -    end +  if vim.fn.pumvisible() == 1 then +    return t "<C-p>" +  elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then +    return t "<Plug>(vsnip-jump-prev)" +  else +    return t "<S-Tab>" +  end  end  vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true}) diff --git a/lua/plugins.lua b/lua/plugins.lua index da33339c..967a9d1d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -83,6 +83,7 @@ return require("packer").startup(          require_plugin("nvim-lspconfig")          require_plugin("lspsaga.nvim")          require_plugin("nvim-lspinstall") +        require_plugin("friendly-snippets")          require_plugin("popup.nvim")          require_plugin("plenary.nvim")          require_plugin("telescope.nvim") | 
