From 680e5f69c129559e0641bf04581551fa0a18785a Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Mon, 22 Apr 2024 07:57:15 +0200 Subject: [PATCH] disable cmp in comments --- lua/kickstart/plugins/cmp.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/kickstart/plugins/cmp.lua b/lua/kickstart/plugins/cmp.lua index d2050f3..6c1f3cb 100644 --- a/lua/kickstart/plugins/cmp.lua +++ b/lua/kickstart/plugins/cmp.lua @@ -38,6 +38,16 @@ return { luasnip.config.setup {} cmp.setup { + enabled = function() + -- disable completion in comments + local context = require 'cmp.config.context' + -- keep command mode completion enabled when cursor is in a comment + if vim.api.nvim_get_mode().mode == 'c' then + return true + else + return not context.in_treesitter_capture 'comment' and not context.in_syntax_group 'Comment' + end + end, snippet = { expand = function(args) luasnip.lsp_expand(args.body)