Skip to content

Commit

Permalink
fix: enable cmdline cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
BBboy01 committed Nov 20, 2023
1 parent d757b5f commit 0dfb79e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
1 change: 0 additions & 1 deletion lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
Expand Down
28 changes: 18 additions & 10 deletions lua/plugins/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ return {
event = 'InsertEnter',
dependencies = {
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-nvim-lua',
{ 'hrsh7th/cmp-nvim-lsp', dependencies = 'nvim-lspconfig' }, -- nvim-cmp source for neovim's built-in LSP
{ 'hrsh7th/cmp-path', dependencies = 'nvim-cmp' },
{ 'hrsh7th/cmp-buffer', dependencies = 'nvim-cmp' }, -- nvim-cmp source for buffer words
{ 'saadparwaiz1/cmp_luasnip', dependencies = 'LuaSnip' },
{
'L3MON4D3/LuaSnip',
event = 'InsertCharPre',
},
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',
'hrsh7th/cmp-buffer',
'saadparwaiz1/cmp_luasnip',
},
opts = function()
vim.api.nvim_set_hl(0, 'CmpGhostText', { link = 'Comment', default = true })
local cmp = require('cmp')
local defaults = require('cmp.config.default')()
return {
completion = {
completeopt = 'menu,menuone,noinsert',
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
Expand Down Expand Up @@ -62,9 +61,18 @@ return {
end,
---@param opts cmp.ConfigSchema
config = function(_, opts)
local cmp = require('cmp')
for _, source in ipairs(opts.sources) do
source.group_index = source.group_index or 1
end
require('cmp').setup(opts)
cmp.setup(opts)
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' },
}, {
{ name = 'cmdline' },
}),
})
end,
}
26 changes: 14 additions & 12 deletions lua/plugins/luasnip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ return {
'L3MON4D3/LuaSnip',
build = (not jit.os:find('Windows'))
and "echo 'NOTE: jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp"
or nil,
or nil,
dependencies = {
'rafamadriz/friendly-snippets',
config = function()
Expand All @@ -13,16 +13,18 @@ return {
history = true,
delete_check_events = 'TextChanged',
},
-- stylua: ignore
keys = {
{
"<tab>",
function()
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
end,
expr = true, silent = true, mode = "i",
},
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
-- stylua: ignore
keys = {
{
"<tab>",
function()
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
end,
expr = true,
silent = true,
mode = "i",
},
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
},
}

0 comments on commit 0dfb79e

Please sign in to comment.