From a221b0e72502e885c0b80d9a064b42d3bee0b2d2 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Fri, 2 Jun 2023 10:23:44 -0400 Subject: [PATCH] Trying to disable autocomplete in comments --- homeConfig/dotfiles/nvim/lua/config/autocmds.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/homeConfig/dotfiles/nvim/lua/config/autocmds.lua b/homeConfig/dotfiles/nvim/lua/config/autocmds.lua index fc2e4d4..8939cb1 100644 --- a/homeConfig/dotfiles/nvim/lua/config/autocmds.lua +++ b/homeConfig/dotfiles/nvim/lua/config/autocmds.lua @@ -59,6 +59,17 @@ end local luasnip = require("luasnip") 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, + mapping = { -- [""] = cmp.mapping(function(fallback) -- if vim.fn.pumvisible() == 1 then @@ -79,7 +90,6 @@ cmp.setup({ -- fallback() -- end -- end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item()