GithubHelp home page GithubHelp logo

Comments (36)

folke avatar folke commented on August 16, 2024 2

@akinsho and done :)
image

See https://github.com/folke/noice.nvim/wiki/Configuration-Recipes#display-the-cmdline-and-popupmenu-together

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024 1

I have checked the latest version.
nvim-cmp seems required...

I want to use ddc.vim with noice.nvim.

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024 1

Thank you! It works.

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024 1

スクリーンショット_2022-10-04_19-56-55

from noice.nvim.

folke avatar folke commented on August 16, 2024

So the way the popupmenu works is probably not as you think :)

We implement ext_popupmenu and get the list of items we should show in a popup together with information if an option is selected.

Right now, for this I use some of the internal views from cmp, but cmp isn't actually doing any completion for this.
cmp-cmdline isn't involved at all with rendering the popupmenu in Noice.

I was just lazy and haven't yet implemetented a simple popup view.

You're right about the cmp popup position durting cmdlline mode, but I fix (hack) that in

function M.fix_cmp()

from noice.nvim.

folke avatar folke commented on August 16, 2024

This can probably also be closed now?

from noice.nvim.

akinsho avatar akinsho commented on August 16, 2024

I'm still seeing the cmp-cmdline window located just above the old cmdline position, e.g.

image

from noice.nvim.

folke avatar folke commented on August 16, 2024

ok, so that is cmp-cmdline anyway. Just for testing, can you disable the cmp-cmdline source and see if it works then?

from noice.nvim.

akinsho avatar akinsho commented on August 16, 2024

Yeah, I think the cmp-cmdline issue here is separate since a solution to that will probably be some sort of mixture of a change to cmp-cmdline to allow changing the position of the window through some sort of API and maybe that being incorporated here, so maybe best to move this issue there at least to raise the request for such an API.

Regarding the other issue of positioning, that still recurs without cmp cmdline enabled seems to be a different window with other sources (e.g. my spell and rg source) where the cursor would otherwise be

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

Hi, ddc-cmdline has the same problem.
It seems screenpos() result is wrong.
I think it is from fake cursor.

https://github.com/folke/noice.nvim#-known-issues

from noice.nvim.

folke avatar folke commented on August 16, 2024

This should be fixed now in the latest version. Things I changed:

  • I made a proper fix to the existing cmp api functions to get the position, screen position and line of the cmdline when Noice is active. Will see to make a PR to cmp that exposes an API to set the cmdline position from other plugins, but this works for now.
  • I implemented a proper cmp source noice_popupmenu that is automatically added when no other cmdline sources have been configured.

With these changes, things should work as expected:

  • cmp popupmenu should always be positioned correctly
  • pmenu items (the ones I get from ui_attach/ext_popupmenu will be used for completion if no other cmp cmdline sources were configured
  • if you're using cmp-cmdline, then that will work as it did before

Let me know if you encounter any more issues!

from noice.nvim.

folke avatar folke commented on August 16, 2024

@Shougo yes, you're correct.

I made some changes so that cmp can properly work with fake cursors.

Once we have a proper Neovim api to work with the cursor, it should work for other usages without these hacks

from noice.nvim.

akinsho avatar akinsho commented on August 16, 2024

As I mentioned in #1 this issue also seems to be resolved in the case of cmp-cmdline, feel free to close this out @folke unless you want to keep it open to track against other plugins like ddc etc. or to convert it to track against a cursor api in nvim 🤷🏿

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

Thanks. I will try it later.

from noice.nvim.

folke avatar folke commented on August 16, 2024

Closing this issue since the fake cursor issue is tracked in the tracking issue.

from noice.nvim.

miversen33 avatar miversen33 commented on August 16, 2024

Ya, it looks like popupmenu.lua has a hard dependency on cmp now. This seems wrong @folke ?

from noice.nvim.

folke avatar folke commented on August 16, 2024

@Shougo @miversen33 I've removed the hard dependency on cmp. In your config you can set popupmenu.enabled = false.

I'll also add a native implementation for regular cmdline completions.

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

Thank you.

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

Well, nvim-cmp is loaded yet.

スクリーンショット_2022-10-04_16-16-16

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

My config

  require'noice'.setup {
    cmdline = {
      enabled = true,
      menu = 'popup',
      icons = {
        ['/'] = { icon = '/', hl_group = 'DiagnosticWarn' },
        ['?'] = { icon = '?', hl_group = 'DiagnosticWarn' },
        [':'] = { icon = ':', hl_group = 'DiagnosticInfo', firstc = false },
      },
    },
    popupmenu = {
      enabled = false,
    },
  }

from noice.nvim.

folke avatar folke commented on August 16, 2024

@Shougo my bad. I use a lazy-require and while I had a pcall to check if cmp exists, it never failed due to the lazy loading. Should be fixed now.

from noice.nvim.

folke avatar folke commented on August 16, 2024

In order to fix the position of the menu for ddc.vim, you'll have to somehow tell it the correct position of the cmdline cursor.

You can retrieve it with

---@type {win: window, buf: buffer, win_cursor:number[], screen_cursor:number[]}?
require("noice.util.cursor").get_cmdline_cursor()

Positions are (1,0) indexed

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

I want to check noice.nvim is installed in vim script...

I get it.

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

I have added noice.nvim support in pum.vim.

from noice.nvim.

folke avatar folke commented on August 16, 2024

@Shougo that's awesome!

from noice.nvim.

akinsho avatar akinsho commented on August 16, 2024

@folke what do you think about allowing the user to position the completion menu themselves, specifically what I'm thinking is that rather than have it overlapping with the bottom of the float it might be nicer to have it appear just below the window.

I'm going for something that looks a bit more like

image

(obvs that's a GUI I just meant the positioning)

But I think rather than you specifically hard coding any values that what you pass to the positioning function be configurable defaulting to how you currently have it but with the user having an option to move it.

Just an idea as always, no pressure if it will make things complex

from noice.nvim.

folke avatar folke commented on August 16, 2024

@akinsho great idea!
I'm almost finished with a nui based popupmenu, which will be native to Noice.
I'll make sure you'll be able to configure it like that

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

I have added offset_row support.

スクリーンショット_2022-10-04_22-06-04

from noice.nvim.

folke avatar folke commented on August 16, 2024

@Shougo great :)

I forgot to mention that I fixed some issues with the cmdline position. There were some off by ones (sometimes) that are now fixed.

from noice.nvim.

akinsho avatar akinsho commented on August 16, 2024

@folke that looks great, very noice 😆.

I'm noticing that using <Tab> in the native popup menu doesn't cycle the options correctly, though. It seems to get stuck after moving to the second item and doesn't continue cycling through them.

Also, I'm wondering if customization regarding positioning would work for cmp as well since I prefer that it autocompletes the cmdline completions versus manually triggering the completion

from noice.nvim.

folke avatar folke commented on August 16, 2024

That;s really odd. Do you maybe have another completion plugin running at the same time?

I'll look into the cmp positioning!

from noice.nvim.

akinsho avatar akinsho commented on August 16, 2024

@folke I have mappings for cmp to use tab but I've removed those and still see the issue, I cross-checked that I'd removed all mappings, and it still doesn't cycle the same way the native wildmenu pum does

from noice.nvim.

folke avatar folke commented on August 16, 2024

@Shougo hi! I just refactored a lot of the code and also the part for the cmdline cursors.

The existing function no longer exists, but you now have require("noice").api.get_cmdline_position() instead.

---@class CmdlinePosition
---@field win number Window containing the cmdline
---@field buf number Buffer containing the cmdline
---@field bufpos {row:number, col:number} (1-0)-indexed position of the cmdline in the buffer
---@field screenpos {row:number, col:number} (1-0)-indexed screen position of the cmdline

This no longer returns the cursor position, but the position where the cmdline starts.

You can then use vim.fn.getcmdpos to get the cursor if needed.

The reason I changed it is because working with the cursor position itself was difficult in situations where completion ran before the cursor was updated. Usingt the actual position of the cmdline makes things much easier.

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

Oh, thanks. I will fix it later.

from noice.nvim.

Shougo avatar Shougo commented on August 16, 2024

Fixed.

from noice.nvim.

AndreM222 avatar AndreM222 commented on August 16, 2024

Is it possible to have this UI running as I'm typing like cmp-cmdline?

from noice.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.