Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer words not initially available in buffers with an LSP #645

Open
2 tasks done
GNOMES opened this issue Dec 18, 2024 · 3 comments
Open
2 tasks done

Buffer words not initially available in buffers with an LSP #645

GNOMES opened this issue Dec 18, 2024 · 3 comments
Labels
bug Something isn't working sources Specific source provider or the system as a whole

Comments

@GNOMES
Copy link

GNOMES commented Dec 18, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

I am coming from using nvim-cmp + cmp-buffer today, so not sure if this is an intentional difference in the goal of this project.

When an LSP is attached to a buffer, Blink's autocomplete does not seem to match buffer words initially, and instead wants to use LSP recommendations (and friendly-snippets). Continuing autocomplete on a partial string will suggest buffer words. This is not a problem in new files

-- Buffer words in new file (working as expected)

  1. Open a new empty file
  2. Type a test string. Ex. water
  3. Navigate to a different line
  4. Start typing the test string, Blink will suggest auto completing the string. Ex. water will be suggestion after the letter w

-- Buffer words in a file with LSP (not working as expected)

  1. Open a new file with an LSP started (I lazily start nvim-lspconfig on filetype). Ex. nvim test.sh
  2. Type a test string. Ex. water
  3. Navigate to a different line
  4. Start typing the test string, Blink will suggest LSP suggestions. Ex. water will not appear as a suggestion
  5. Stop typing once string is partially entered. Ex. wat
  6. Stop the autocomplete suggestions in one of these two ways:
    a. Use space to "leave" the partial string, and hit backspace back to incomplete word
    b. Hit escape to return to normal mode + A to return to insert mode at the end of incomplete word
  7. Continue to enter the next letters to finish string, Blink will suggest test string as an autocomplete option. Ex. water will be a suggestion after typing e at the end of wat

I tried playing with reordering the Sources thinking the sources might be processed in order or weighted, but this has no impact.

Relevant configuration

return {
    'saghen/blink.cmp',
    event = { "InsertEnter", "CmdLineEnter" },
    dependencies = 'rafamadriz/friendly-snippets',
    version = 'v0.*',
    opts = {
        -- 'default' for mappings similar to built-in completion
        -- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate)
        -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept
        -- see the "default configuration" section below for full documentation on how to define
        -- your own keymap.
        keymap = { preset = 'super-tab' },

        appearance = {
            -- Sets the fallback highlight groups to nvim-cmp's highlight groups
            -- Useful for when your theme doesn't support blink.cmp
            -- will be removed in a future release
            use_nvim_cmp_as_default = true,
            -- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
            -- Adjusts spacing to ensure icons are aligned
            nerd_font_variant = 'mono'
        },

        -- default list of enabled providers defined so that you can extend it
        -- elsewhere in your config, without redefining it, via `opts_extend`
        sources = {
            default = { 'buffer', 'lsp', 'path', 'snippets' },
        },
        completion = {
            menu = {
                border = "single",
                scrollbar = false,
            },
            documentation = {
                auto_show = true,
                window = {
                    border = "single",
                },
            },
        },
        signature = { enabled = true },
    },
    -- allows extending the providers array elsewhere in your config
    -- without having to redefine it
    opts_extend = { "sources.default" }
}

neovim version

NVIM v0.10.2

blink.cmp version: branch, tag, or commit

v0.7.6, commit ae5a4ce

@GNOMES GNOMES added the bug Something isn't working label Dec 18, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 19, 2024

I'm not sure I'm understanding correctly, but you might want to set sources.providers.lsp.fallbacks = {} so that the buffer source always shows, regardless of whether the LSP is showing or not. What LSP are you using?

@Saghen Saghen added the sources Specific source provider or the system as a whole label Dec 19, 2024
@Ask-786
Copy link

Ask-786 commented Dec 19, 2024

While using ts_ls, it seems to be there is an issue mentioned above. But in lua files, there is no such issue found.
I didn't test any other files by the way.

@GNOMES
Copy link
Author

GNOMES commented Dec 19, 2024

What LSP are you using?

Discovered this issue in bash-language-server, but unlike @Ask-786 , I do experience this lua-language-server

I tried adding your suggested fallbacks block:

        sources = {
            default = { 'buffer', 'lsp', 'path', 'snippets' },
            providers = {
                lsp = {
                    fallbacks = { 'buffer' },
                },
            },
        },

short clip of autocomplete working with no lsp, and it not working initially in bash or lua files until trying to complete a partial string (sorry for 480p)

issue_645.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sources Specific source provider or the system as a whole
Projects
None yet
Development

No branches or pull requests

3 participants