Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Force preselect to be false #52

Closed
elianiva opened this issue Dec 15, 2020 · 3 comments
Closed

Force preselect to be false #52

elianiva opened this issue Dec 15, 2020 · 3 comments

Comments

@elianiva
Copy link
Contributor

I have a slight issue with nvim-compe when using it against gopls. I think the LSP is forcing nvim-compe to preselect the first match, the other sources doesn't have this issue. Is it possible to force it not to preselect the first item? Or is it have to be done in the lsp level? I can't find any lsp setting for gopls that can disable this behaviour. Here's a video to make it clearer..

https://streamable.com/9wtp5r

..and here's a minimal vimrc to reproduce. Thanks in advance!

call plug#begin("~/.local/share/nvim/plugged")
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-compe'
call plug#end()

lua << EOF
require"lspconfig".gopls.setup{
  root_dir = function() return vim.loop.cwd() end,
  settings = {
    gopls = {
      analyses = {
        unusedparams = true,
      },
      staticcheck = true,
      usePlaceholders = true,
    },
  }
}

local remap = vim.api.nvim_set_keymap

require'compe'.setup {
  enabled = true;
  debug = false;
  min_length = 2;
  auto_preselect = false;
  source_timeout = 200;
  incomplete_delay = 400;
  allow_prefix_unmatch = false;
  source = {
    path = true;
    buffer = true;
    vsnip = true;
    nvim_lsp = true;
  };
}

remap(
  'i', '<Tab>',
  'pumvisible() ? "<C-n>" : v:lua.Util.check_backspace() ? "<Tab>" : compe#confirm(lexima#expand("<LT>CR>", "i"))',
  { silent = true, noremap = true, expr = true }
)
EOF
@elianiva
Copy link
Contributor Author

update: I think this is due to a bug on neovim side when using complete(). I don't know if this is the cause of this issue, but if it is then we'll just have to wait until it gets fixed.

image

@hrsh7th
Copy link
Owner

hrsh7th commented Dec 15, 2020

The preselect is LSP's spec so nvim-compe will preselect it if the server returns it.
But your opinion is reasonable to me. I will add the option for it.

@hrsh7th
Copy link
Owner

hrsh7th commented Dec 15, 2020

Fixed fd87cd6

You can specify preselect = 'disable'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants