boltlessengineer / NativeVim

Neovim config WITHOUT plugins
MIT License
189 stars 3 forks source link

`autotrigger` option in `vim.lsp.completion.enable` is not working #3

Closed bpingris closed 2 weeks ago

bpingris commented 2 weeks ago

Hi!

it's not an issue with your configuration but maybe you have some extra knowledge to help me add autocompletion!

I've set up the completion like in your config, only setting the autotrigger option to true

vim.api.nvim_create_autocmd("LspAttach", {
        group = vim.api.nvim_create_augroup("UserLspAttach", { clear = false }),
        callback = function(ev)
                vim.lsp.completion.enable(true, ev.data.client_id, ev.buf, { autotrigger = true })
        end
})

unfortunately I don't have the completion showing up when editing files, if I call the vim.lsp.completion.trigger function the autocomplete works

do you know by any chance if I need to set up something else to have the autocompletion working automatically while writing in the buffer? this [documentation](https://neovim.io/doc/user/lsp.html#vim.lsp.completion.enable()) from neovim does not mention anything else, I think

boltlessengineer commented 2 weeks ago

tbh I have no idea why that option doesn’t work. I’m not sure if autotrigger is meant to be used for enabling autocompletion.

You can create an issue in neovim repo and if so, can you mention this issue so I can follow that?

bpingris commented 2 weeks ago

I didnt take the time to fill an issue on the nvim repo, however I think the way nvim lsp completion works is with the . in my case when writing inside ts or lua files autocomplete only shows up automatically after the ., I guess this is based on the lsp specifications for when it should pop.

it even triggers with <space> in lua file, making editing in lua impossible without being harassed by the completion menu ☹️ I had a wrongcompleteopt setting

interesting, we can modify the trigger characters, for instance here are the ones for lua:

{ "\t", "\n", ".", ":", "(", "'", '"', "[", ",", "#", "*", "@", "|", "=", "-", "{", " ", "+", "?" }

and how to update them:

        local client = vim.lsp.get_client_by_id(ev.data.client_id)
        if client then
                vim.print(client.server_capabilities.completionProvider.triggerCharacters)
                client.server_capabilities.completionProvider.triggerCharacters = {':', '.'}
        end
boltlessengineer commented 2 weeks ago

If the document is still lack in v0.11 release, I’ll make a issue in Neovim repo