Disabling autocompletion on comments

This commit is contained in:
Zoe Roux
2022-03-30 23:23:27 +02:00
parent 8f5ff78739
commit 4e7bfd6866
2 changed files with 18 additions and 2 deletions
+6 -1
View File
@@ -16,7 +16,12 @@ neogen.setup({
local wk = require("which-key")
wk.register({
n = { "<cmd>Neogen any<cr>", "Generate documentation" },
n = {
name = "Generate documentation",
f = { "<cmd>Neogen func<CR>", "Function" },
c = { "<cmd>Neogen class<CR>", "Class" },
t = { "<cmd>Neogen type<CR>", "Type" },
},
}, {
prefix = "<leader>",
})
+12 -1
View File
@@ -47,6 +47,17 @@ cmp.setup({
require('luasnip').lsp_expand(args.body)
end,
},
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 = {
["<Up>"] = cmp.mapping.select_prev_item(),
["<Down>"] = cmp.mapping.select_next_item(),
@@ -69,7 +80,7 @@ cmp.setup({
else
fallback()
end
end, { "i", "s" }),
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then