<commit_before>if not pcall(require, 'cmp') then
  return
end

local cmp = require('cmp')
local luasnip = require('luasnip')

local has_words_before = function()
  if vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt' then
    return false
  end
  local line, col = unpack(vim.api.nvim_win_get_cursor(0))
  return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
end

cmp.setup({
  preselect = cmp.PreselectMode.None,
  snippet = {
    expand = function(args)
      require('luasnip').lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<C-k>'] = cmp.mapping.confirm({ select = true }),
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
    ['<C-n>'] = cmp.mapping.select_next_item({ 'i', 'c' }),
    ['<C-p>'] = cmp.mapping.select_prev_item({ 'i', 'c' }),
    ['<Down>'] = cmp.mapping.select_next_item({ 'i', 'c' }),
    ['<Up>'] = cmp.mapping.select_prev_item({ 'i', 'c' }),
    ['<Tab>'] = cmp.mapping(function(fallback)
      if luasnip.expand_or_jumpable() then
        luasnip.expand_or_jump()
      elseif cmp.visible() then
        cmp.select_next_item({ cmp.SelectBehavior.Insert })
      elseif has_words_before() then
        cmp.complete()
      else
        fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
      end
    end, {
      'i',
      's',
    }),
    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if luasnip.jumpable(-1) then
        luasnip.jump(-1)
      elseif cmp.visible() then
        cmp.select_prev_item({ cmp.SelectBehavior.Insert })
      else
        fallback()
      end
    end, {
      'i',
      's',
    }),
  },
  sources = {
    { name = 'nvim_lsp', keyword_length = 2, max_item_count = 25 },
    { name = 'buffer', keyword_length = 2, max_item_count = 25 },
    { name = 'path' },
    { name = 'luasnip' },
  },
  -- experimental = {
  -- native_menu = false,
  -- ghost_text = false,
  -- },
})

vim.cmd([[
  augroup NvimCmp
    au!
    au FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }
  augroup END
]])
<commit_msg>removed binding<commit_after>if not pcall(require, 'cmp') then
  return
end

local cmp = require('cmp')
local luasnip = require('luasnip')

local has_words_before = function()
  if vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt' then
    return false
  end
  local line, col = unpack(vim.api.nvim_win_get_cursor(0))
  return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
end

cmp.setup({
  preselect = cmp.PreselectMode.None,
  snippet = {
    expand = function(args)
      require('luasnip').lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<C-k>'] = cmp.mapping.confirm({ select = true }),
    ['<C-n>'] = cmp.mapping.select_next_item({ 'i', 'c' }),
    ['<C-p>'] = cmp.mapping.select_prev_item({ 'i', 'c' }),
    ['<Down>'] = cmp.mapping.select_next_item({ 'i', 'c' }),
    ['<Up>'] = cmp.mapping.select_prev_item({ 'i', 'c' }),
    ['<Tab>'] = cmp.mapping(function(fallback)
      if luasnip.expand_or_jumpable() then
        luasnip.expand_or_jump()
      elseif cmp.visible() then
        cmp.select_next_item({ cmp.SelectBehavior.Insert })
      elseif has_words_before() then
        cmp.complete()
      else
        fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
      end
    end, {
      'i',
      's',
    }),
    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if luasnip.jumpable(-1) then
        luasnip.jump(-1)
      elseif cmp.visible() then
        cmp.select_prev_item({ cmp.SelectBehavior.Insert })
      else
        fallback()
      end
    end, {
      'i',
      's',
    }),
  },
  sources = {
    { name = 'nvim_lsp', keyword_length = 2, max_item_count = 25 },
    { name = 'buffer', keyword_length = 2, max_item_count = 25 },
    { name = 'path' },
    { name = 'luasnip' },
  },
  -- experimental = {
  -- native_menu = false,
  -- ghost_text = false,
  -- },
})

vim.cmd([[
  augroup NvimCmp
    au!
    au FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }
  augroup END
]])

{'fraction_non_alphanumeric': 0.17333972668424838, 'fraction_numerical': 0.006713018460800768, 'mean_word_length': 2.7892824704813806, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5739230', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1542, 'n_words': 317}