finish josean martinez tutorial

This commit is contained in:
2025-04-24 10:17:46 -05:00
parent 88efb97344
commit 3d26eee4d5
17 changed files with 586 additions and 70 deletions

View File

@@ -1,84 +1,86 @@
return {
'hrsh7th/nvim-cmp',
"hrsh7th/nvim-cmp",
dependencies = {
-- Core completion sources
'hrsh7th/cmp-nvim-lsp',
-- 'hrsh7th/cmp-treesitter', -- Uncomment if you have a cmp-treesitter source
-- Cmdline support
'hrsh7th/cmp-cmdline',
-- Icons
'onsails/lspkind-nvim',
-- basic sources
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
-- cmdline completion for `:` and `/`
"hrsh7th/cmp-cmdline", -- :contentReference[oaicite:0]{index=0}
-- LSP
"hrsh7th/cmp-nvim-lsp", -- :contentReference[oaicite:1]{index=1}
-- Treesitter source
"ray-x/cmp-treesitter", -- :contentReference[oaicite:2]{index=2}
-- Extras you can enable later:
-- 'windwp/nvim-autopairs', -- autopairs integration
-- 'lukas-reineke/cmp-under-comparator', -- fuzzy sorting
-- snippet engine & integration (optional)
{
"L3MON4D3/LuaSnip",
version = "v2.*",
build = "make install_jsregexp",
},
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
-- icons
"onsails/lspkind.nvim",
},
config = function()
local cmp = require('cmp')
local lspkind = require('lspkind')
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
-- load friendly-snippets
require("luasnip.loaders.from_vscode").lazy_load()
-- nicer completions menu
vim.opt.completeopt = "menu,menuone,preview,noselect"
cmp.setup({
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text", -- or "symbol" for just icons, "text" for just text
maxwidth = 50,
}),
},
snippet = {
expand = function(args)
-- no-op, snippet engine not installed
luasnip.lsp_expand(args.body)
end,
},
mapping = {
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-e>'] = cmp.mapping.abort(),
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = false }),
}),
sources = cmp.config.sources({
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "treesitter" },
{ name = "buffer" },
{ name = "path" },
}),
formatting = {
format = lspkind.cmp_format({
maxwidth = 50,
ellipsis_char = "...",
}),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
-- { name = 'treesitter' }, -- Uncomment if you actually have cmp-treesitter
}),
-- Extras you can enable later:
-- window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
-- },
-- experimental = {
-- ghost_text = true,
-- },
})
-- Cmdline completion for : (commands & paths)
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' },
{ name = 'cmdline' },
}),
})
-- Search completion for / (buffer)
cmp.setup.cmdline('/', {
-- Commandline “:” → cmdline + path
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' },
{ name = "path" },
{ name = "cmdline" },
},
})
-- Autopairs integration (uncomment when you install nvim-autopairs)
-- require('nvim-autopairs').setup{}
-- local cmp_autopairs = require('nvim-autopairs.completion.cmp')
-- cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
-- Fuzzy sorting (uncomment when you install cmp-under-comparator)
-- table.insert(cmp.config.sorting.comparators, require('cmp-under-comparator').under)
-- Search “/” → buffer
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
end,
}