From 4eaaee898e0277434c7431cbad2ba7e06f04d1f1 Mon Sep 17 00:00:00 2001 From: dlond Date: Fri, 2 May 2025 19:48:44 +1200 Subject: [PATCH] added that too --- lua/custom/toggle-path-cmp.lua | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lua/custom/toggle-path-cmp.lua diff --git a/lua/custom/toggle-path-cmp.lua b/lua/custom/toggle-path-cmp.lua new file mode 100644 index 00000000..71e90ebd --- /dev/null +++ b/lua/custom/toggle-path-cmp.lua @@ -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