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

[mini.completion] Completion list disappears with existing LSP completion items and reappears using fallback #679

Closed
3 tasks done
JSteitz opened this issue Feb 2, 2024 · 5 comments

Comments

@JSteitz
Copy link

JSteitz commented Feb 2, 2024

Contributing guidelines

Module(s)

mini.completion

Description

Typing a character after the . delimiter, the completion list disappears, and it also loses/forgets the context.
See "Steps to reproduce" for a better understanding of what happens.
In this example, I use typescript with native Object.entries()

I also observed this behavior with PHP.

minimal.lua

-- Run this file as `nvim --clean -u minimal.lua`

for name, url in pairs {
  -- ADD PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE, e.g:
  -- some_plugin = 'https://github.com/author/plugin.nvim'
  lspconfig = "https://github.com/neovim/nvim-lspconfig",
  mini = "https://github.com/echasnovski/mini.nvim",
} do
  local install_path = vim.fn.fnamemodify('nvim_issue/' .. name, ':p')
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.opt.runtimepath:append(install_path)
end

-- ADD INIT.LUA SETTINGS _NECESSARY_ FOR REPRODUCING THE ISSUE
require("lspconfig").tsserver.setup({ })
require("mini.completion").setup({ })
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1702233742

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Neovim version

0.9.5

Steps to reproduce

  1. nvim --clean -u minimal.lua
  2. open a typescript file (can also be empty)
  3. verify typescript lsp is attached :LspInfo
  4. type Object. and see completion list from lsp
  5. type further to Object.e completion list is gone
  6. typing further to Object.en completion list from fallback appears (only when available)

Expected behavior

No response

Actual behavior

Completion list disappears after typing and reappears with fallback

@JSteitz JSteitz added the bug Something isn't working label Feb 2, 2024
@JSteitz JSteitz changed the title Completion list disappears and uses fallback with existing LSP completion items [mini.completion] Completion list disappears with existing LSP completion items and reappears using fallback Feb 2, 2024
@echasnovski echasnovski added mini.completion and removed bug Something isn't working labels Feb 2, 2024
@echasnovski
Copy link
Owner

Thanks for the issue!

Going through the list (with <C-n>) shows that text to be added contains extra . as prefix. So when e is pressed, completion logic infers that there are no candidates that start with e (as they all start with .) and thus ends current completion. You can press <C-Space> (as in config.mappings.force_twostep) to force completion again and it will correctly show entries with proper further completion.

Essentially, this is a duplicate of #306. If you want it to work a bit better, take a look at suggestion from this comment.

That said, as builtin vim.lsp.omnifunc does not have this issue, I'll try to investigate if it is reasonable to update 'mini.completion' to not have this behavior (first results are not really promising).

echasnovski added a commit that referenced this issue Feb 2, 2024
@echasnovski
Copy link
Owner

echasnovski commented Feb 2, 2024

@JSteitz, would you mind testing backlog-completion branch on real world examples?

It seems to fix the tsserver behavior you described. I would be really grateful if you can try whether it fixes the PHP cases you mentioned seeing.

@JSteitz
Copy link
Author

JSteitz commented Feb 3, 2024

Tested and it works in all ts/js/php.

For completeness’s sake, here is the test case for php:

  1. nvim --clean -u minimal.lua
  2. open a php file with any variable
  3. verify php lsp is attached :LspInfo
  4. type $ and see completion list from lsp
  5. type further to $x completion list is gone
  6. typing further to $xyz completion list from fallback appears (only when available)

@echasnovski
Copy link
Owner

Tested and it works in all ts/js/php.

Thanks for the follow up! I'll add some new update related to backlog-completion soon and will test it for about a day before merging into main.

@echasnovski
Copy link
Owner

This now should be resolved on main branch. Thanks for creating this and finally getting me to make some cosmetic updates to 'mini.completion'.

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

No branches or pull requests

2 participants