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

feat: add option for view to follow cursor #1727

Merged
merged 2 commits into from
Mar 31, 2024
Merged

feat: add option for view to follow cursor #1727

merged 2 commits into from
Mar 31, 2024

Conversation

mcauley-penney
Copy link
Contributor

@mcauley-penney mcauley-penney commented Oct 15, 2023

Creates an option to allow the custom entries
view to follow the user's cursor as they type.

To enable, set

require("cmp").setup({
  view = {
    entries = {
      follow_cursor = true
    }
  }
})

Original custom view source at lvimuser@7569056

Closes #1660

@mcauley-penney mcauley-penney changed the title feat: add option for custom entry view to follow cursor feat: add option for view to follow cursor Oct 17, 2023
@Shougo
Copy link

Shougo commented Oct 17, 2023

CI seems failed.

@mcauley-penney
Copy link
Contributor Author

CI seems failed.

If I'm reading the commit history correctly, that test has been failing since August 10th, so over two months. That gives me the impression that the error doesn't come from these two commits. If you believe it does and not from earlier commits, I'd like some help identifying where they come from.

@Shougo
Copy link

Shougo commented Oct 17, 2023

If I'm reading the commit history correctly, that test has been failing since August 10th, so over two months. That gives me the impression that the error doesn't come from these two commits. If you believe it does and not from earlier commits, I'd like some help identifying where they come from.

Oh....

So CI fix commit is needed.

@mcauley-penney
Copy link
Contributor Author

Just to be clear, you'd like a CI fix in this PR? I'd argue that that's outside of the scope of this particular PR, but I'm open to trying to fix it.

@Shougo
Copy link

Shougo commented Oct 17, 2023

Just to be clear, you'd like a CI fix in this PR? I'd argue that that's outside of the scope of this particular PR, but I'm open to trying to fix it.

I think it should be another PR.

@mcauley-penney
Copy link
Contributor Author

mcauley-penney commented Oct 17, 2023

Okay, I can try. I am new to this code base, but I'd be open to trying to fix it and contributing to other things too. I am busy until Thursday morning. After that, I can take a look at that CI problem.

Edit: I'm working on this in #1729

@Shougo
Copy link

Shougo commented Oct 18, 2023

can you rebase the PR?
The CI seems fixed.

Creates an option to allow the custom entries
view to follow the user's cursor as they type.

To enable, set
```lua
require("cmp").setup({
  view = {
    entries = {
      follow_cursor = true
    }
  }
})
```

Original source at lvimuser@7569056

Closes #1660

Co-authored-by: lvimuser <109605931+lvimuser@users.noreply.github.com>
@mcauley-penney
Copy link
Contributor Author

mcauley-penney commented Oct 18, 2023

@Shougo done. Thank you for orchestrating this

Edit: if this is set to be merged, I will produce documentation for it.

njhoffman added a commit to njhoffman/nvim-cmp that referenced this pull request Nov 28, 2023
@mcauley-penney
Copy link
Contributor Author

@hrsh7th I've seen comments saying that you are feeling cautious about integrating new features because it will increase your maintenance burden, and you are busy. I would be happy to take ownership of this feature and its resulting issues if this PR were merged, similar to how Neovim itself has owners for new features.

@Shougo
Copy link

Shougo commented Mar 31, 2024

The screenshot may help to understand the feature works.

@mcauley-penney
Copy link
Contributor Author

No problem at all, I'd be happy to provide some GIFs. To recap, the purpose of this PR is to allow the pmenu to follow the cursor as the user types. This feature is opt-in, and the current behavior remains the default.

Current Behavior

Normally, the pmenu does not follow the user:

cmp-nocursor-customwin

Additional Behavior

Using the custom window:
cmp-cursor-customwin

Using the native window:
cmp-cursor-nativewin

I have been using this since I made this PR, and I personally like it a lot. Some users may like this feature because it is like VSCode's autocomplete. Again, it is opt-in, so no one has to use it if they don't want to but it gives people another option.

@hrsh7th
Copy link
Owner

hrsh7th commented Mar 31, 2024

IMO, it should be custom_entries_view only feature.

The native menu is a bit complicated, so I would like to exclude it from the list and annotate docs.

@mcauley-penney
Copy link
Contributor Author

@hrsh7th I have updated the PR so that the native menu is excluded and the docs do not mention it. Please let me know if there are any other changes you would like me to make.

@hrsh7th
Copy link
Owner

hrsh7th commented Mar 31, 2024

LGTM. Thank you.

@hrsh7th hrsh7th merged commit 7aa3f71 into hrsh7th:main Mar 31, 2024
2 checks passed
@@ -679,6 +679,13 @@ view.docs.auto_open~

Specify whether to show the docs_view when selecting an item.

*cmp-config.view.follow_cursor*
view.follow_cursor*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, reading the rest of the final change it seems the help tags here are wrong, they should use view.entries.follow_cursor since the option is under entries 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, thanks! I'll submit a fix today

@mcauley-penney
Copy link
Contributor Author

I've addressed my docs error as well as some other issues in the view docs in #1868

@nyngwang
Copy link

nyngwang commented Apr 4, 2024

IMO, it should be custom_entries_view only feature.

What does this mean? Say I want to try the new option by this PR, then what should I do to ensure that it's only used with custom_entries_view?


OK, I found the answer. I should keep the name = 'custom' here and avoid the pointed out entries = 'native' when using with this new option:

view = {
entries = {
name = 'custom',
selection_order = 'top_down',
follow_cursor = false,
},
docs = {
auto_open = true,
},
},

@mcauley-penney
Copy link
Contributor Author

mcauley-penney commented Apr 4, 2024

This option will not do anything when used with name = 'native'. You don't necessarily have to avoid it because it just won't do anything.

That comment was left for me and was instructing me to make it so that the native view cannot use this option.

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

Successfully merging this pull request may close these issues.

[Question] Completition window popup following the cursor
5 participants