blink.cmp icon indicating copy to clipboard operation
blink.cmp copied to clipboard

lua implementation - better support of diacritics

Open vinoff opened this issue 4 months ago • 4 comments

It seems like words with accents (such as, "amanhã", which means "tomorrow" in Portuguese), are not suggested in the auto-complete popup.

Is this something on my end only? What is happening? Another example:

"ááááá" is not suggested. "aaaa" is suggested.

vinoff avatar Aug 14 '25 10:08 vinoff

Could you be a bit more specific?

What's your blink and neovim version? Can you provide your current blink config? The buffer source should be responsible to suggest these words as you type.

soifou avatar Aug 14 '25 11:08 soifou

~ ❱ nvim --version
NVIM v0.11.3
Build type: RelWithDebInfo
LuaJIT 2.1.1753364724
Run "nvim -V1 -v" for more info

My blink config:

return {
  { -- Autocompletion
    'saghen/blink.cmp',
    event = 'VimEnter',
    version = '1.*',
    dependencies = {
      -- Snippet Engine
      {
        'L3MON4D3/LuaSnip',
        version = '2.*',
        build = (function()
          -- Build Step is needed for regex support in snippets.
          -- This step is not supported in many windows environments.
          -- Remove the below condition to re-enable on windows.
          if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
            return
          end
          return 'make install_jsregexp'
        end)(),
        dependencies = {
          -- `friendly-snippets` contains a variety of premade snippets.
          --    See the README about individual language/framework/plugin snippets:
          --    https://github.com/rafamadriz/friendly-snippets
          {
            'rafamadriz/friendly-snippets',
            config = function()
              require('luasnip.loaders.from_vscode').lazy_load()
              -- loads custom snippets
              require('luasnip.loaders.from_vscode').lazy_load { paths = { vim.fn.stdpath 'config' .. '/snippets' } }
            end,
          },
        },
        opts = {},
      },
      'folke/lazydev.nvim',
      'xieyonn/blink-cmp-dat-word',
    },
    --- @module 'blink.cmp'
    --- @type blink.cmp.Config
    opts = {
      keymap = {
        -- 'default' (recommended) for mappings similar to built-in completions
        --   <c-y> to accept ([y]es) the completion.
        --    This will auto-import if your LSP supports it.
        --    This will expand snippets if the LSP sent a snippet.
        -- 'super-tab' for tab to accept
        -- 'enter' for enter to accept
        -- 'none' for no mappings
        --
        -- For an understanding of why the 'default' preset is recommended,
        -- you will need to read `:help ins-completion`
        --
        -- No, but seriously. Please read `:help ins-completion`, it is really good!
        --
        -- All presets have the following mappings:
        -- <tab>/<s-tab>: move to right/left of your snippet expansion
        -- <c-space>: Open menu or open docs if already open
        -- <c-n>/<c-p> or <up>/<down>: Select next/previous item
        -- <c-e>: Hide menu
        -- <c-k>: Toggle signature help
        --
        -- See :h blink-cmp-config-keymap for defining your own keymap
        -- preset = 'default',
        preset = 'super-tab',

        -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
        --    https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
      },

      appearance = {
        -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
        -- Adjusts spacing to ensure icons are aligned
        nerd_font_variant = 'mono',
      },

      completion = {
        -- By default, you may press `<c-space>` to show the documentation.
        -- Optionally, set `auto_show = true` to show the documentation after a delay.
        documentation = { auto_show = false, auto_show_delay_ms = 500 },

        menu = {
          draw = {
            columns = {
              { 'label', 'label_description', gap = 1 },
              { 'kind' },
            },
          },
        },
      },

      sources = {
        default = { 'lsp', 'path', 'snippets', 'lazydev', 'buffer', 'datword' },
        -- default = { 'lsp', 'path', 'snippets', 'lazydev' },
        providers = {
          lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
          lsp = {
            name = 'LSP',
            module = 'blink.cmp.sources.lsp',
            transform_items = function(_, items)
              return vim.tbl_filter(function(item)
                return item.kind ~= require('blink.cmp.types').CompletionItemKind.Keyword
              end, items)
            end,
          },

          datword = {
            name = 'DatWord',
            score_offset = -5,
            module = 'blink-cmp-dat-word',
            opts = {
              paths = {
                -- "path_to_your_words.txt", -- add your owned word files before dictionary.
                '/usr/share/dict/words', -- This file is included by default on Linux/macOS.
              },
            },
          },
        },
        min_keyword_length = 2,
      },

      snippets = { preset = 'luasnip' },

      -- Blink.cmp includes an optional, recommended rust fuzzy matcher,
      -- which automatically downloads a prebuilt binary when enabled.
      --
      -- By default, we use the Lua implementation instead, but you may enable
      -- the rust implementation via `'prefer_rust_with_warning'`
      --
      -- See :h blink-cmp-config-fuzzy for more information
      fuzzy = { implementation = 'lua' },

      -- Shows a signature help window while you type arguments for a function
      signature = { enabled = false },
    },
  },
}
-- vim: ts=2 sts=2 sw=2 et

How to reproduce:

What I do is, just open a test.md file, start typing away. "áááá" is not suggested while "aaaa" is. This seems to happen with every accentuated word.

vinoff avatar Aug 14 '25 12:08 vinoff

Ah I see. You are using the lua implementation which is currently fragile with diacritics because it explicitly set only few of them. I'll keep this issue opened until we found a good solution.

In the meantime, if you can, switch to the recommended rust implementation (see why).

soifou avatar Aug 14 '25 12:08 soifou

Yes, thank you! For people searching: changing

fuzzy = { implementation = 'lua' },

to

fuzzy = { implementation = 'prefer_rust_with_warning' },

Fixed the issue for me.

vinoff avatar Aug 15 '25 08:08 vinoff