added that too

This commit is contained in:
dlond 2025-05-02 19:48:44 +12:00
parent 79d20cd623
commit 4eaaee898e
1 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,47 @@
local cmp = require 'cmp'
local M = {}
function M.toggle_path_completion()
local snippet = cmp.get_config().snippet
local completion = cmp.get_config().completion
local mapping = cmp.get_config().mapping
local sources = cmp.get_config().sources
local path_enabled = false
for _, source in ipairs(sources) do
if source.name == 'path' then
path_enabled = true
break
end
end
if path_enabled then
cmp.setup {
snippet,
completion,
mapping,
sources = {
{ name = 'lazydev', group_index = 0 },
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}
print 'Path completion disabled'
else
cmp.setup {
snippet,
completion,
mapping,
sources = {
{ name = 'lazydev', group_index = 0 },
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
},
}
print 'Path completion enabled'
end
end
return M