1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-12-22 23:08:01 +00:00

Revert "[neovim] Remove unused lua plugins"

This reverts commit bc0ff82244.
This commit is contained in:
Daniel Carrillo 2022-10-08 18:46:33 +02:00
parent b8a07a3eba
commit e946d6a14b
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
2 changed files with 25 additions and 0 deletions

View File

@ -3,6 +3,13 @@ if not cmp_status_ok then
return return
end end
local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then
return
end
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function() local check_backspace = function()
local col = vim.fn.col(".") - 1 local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
@ -37,6 +44,12 @@ local kind_icons = {
} }
cmp.setup({ cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), ["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(), ["<C-j>"] = cmp.mapping.select_next_item(),
@ -53,6 +66,10 @@ cmp.setup({
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then elseif check_backspace() then
fallback() fallback()
else else
@ -65,6 +82,8 @@ cmp.setup({
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else else
fallback() fallback()
end end
@ -79,6 +98,8 @@ cmp.setup({
vim_item.kind = kind_icons[vim_item.kind] vim_item.kind = kind_icons[vim_item.kind]
vim_item.menu = ({ vim_item.menu = ({
nvim_lsp = "", nvim_lsp = "",
nvim_lua = "",
luasnip = "",
buffer = "", buffer = "",
path = "", path = "",
emoji = "", emoji = "",
@ -88,6 +109,8 @@ cmp.setup({
}, },
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "luasnip" },
{ name = "buffer" }, { name = "buffer" },
{ name = "path" }, { name = "path" },
}, },

View File

@ -71,7 +71,9 @@ return packer.startup(function(use)
use({ "hrsh7th/nvim-cmp", commit = "0e436ee23abc6c3fe5f3600145d2a413703e7272" }) use({ "hrsh7th/nvim-cmp", commit = "0e436ee23abc6c3fe5f3600145d2a413703e7272" })
use({ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" }) use({ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" })
use({ "hrsh7th/cmp-path", commit = "91ff86cd9c29299a64f968ebb45846c485725f23" }) use({ "hrsh7th/cmp-path", commit = "91ff86cd9c29299a64f968ebb45846c485725f23" })
use({ "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" })
use({ "hrsh7th/cmp-nvim-lsp", commit = "affe808a5c56b71630f17aa7c38e15c59fd648a8" }) use({ "hrsh7th/cmp-nvim-lsp", commit = "affe808a5c56b71630f17aa7c38e15c59fd648a8" })
use({ "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" })
-- snippets -- snippets
use({ "L3MON4D3/LuaSnip", tag = "v1.*" }) use({ "L3MON4D3/LuaSnip", tag = "v1.*" })