folke / noice.nvim

💥 Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature: Put the cmdline at the center of the screen

srgsanky opened this issue · comments

Did you check the docs?

  • I have read all the noice.nvim docs

Is your feature request related to a problem? Please describe.

I want to put the cmdline at the center of screen both vertically and horizontally similar to the example shown in the readme - https://github.com/folke/noice.nvim

I tried using the two available options for cmdline, but it didn't help.

      require('noice').setup {
        cmdline = {
          view = 'cmdline_popup', -- cmdline_popup, cmdline

Describe the solution you'd like

Ability to put the cmdline and search at the center of the screen.

Describe alternatives you've considered

I am currently using https://github.com/jonarrien/telescope-cmdline.nvim to get this feature.

Additional context

There is a similar question in reddit without a good answer https://www.reddit.com/r/neovim/comments/10j82ot/q_noicenvim_how_to_change_the_position_of_the/

After I asked this question, I stumbled upon https://github.com/folke/noice.nvim/wiki/Configuration-Recipes#display-the-cmdline-and-popupmenu-together

Together with https://github.com/folke/noice.nvim/blob/0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12/lua/noice/types/nui.lua I was able to center the cmdline.

Here is my config

      require('noice').setup {
        -- Position the command popup at the center of the screen
        -- See https://github.com/folke/noice.nvim/blob/0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12/lua/noice/types/nui.lua#L6
        -- See https://github.com/folke/noice.nvim/wiki/Configuration-Recipes
        ---@type NoiceConfigViews
        views = {
          cmdline_popup = {
            backend = 'popup',
            relative = 'editor',
            zindex = 200,
            position = {
              row = '40%', -- 40% from top of the screen. This will position it almost at the center.
              col = '50%',
            },
            size = {
              width = 120,
              height = 'auto',
            },
            win_options = {
              winhighlight = {
                Normal = 'NoiceCmdlinePopup',
                FloatTitle = 'NoiceCmdlinePopupTitle',
                FloatBorder = 'NoiceCmdlinePopupBorder',
                IncSearch = '',
                CurSearch = '',
                Search = '',
              },
              winbar = '',
              foldenable = false,
              cursorline = false,
            },
          },
          popupmenu = {
            -- relative = 'editor', -- "'cursor'"|"'editor'"|"'win'"
            position = {
              row = 'auto', -- Popup will show up below the cmdline automatically
              col = 'auto',
            },
            size = {
              width = 120, -- Making this as wide as the cmdline_popup
              height = 'auto',
            },
            border = {
              ---@type _.NuiBorderStyle
              style = 'double', -- 'double'"|"'none'"|"'rounded'"|"'shadow'"|"'single'"|"'solid'
              ---@type _.NuiBorderPadding
              padding = { 0, 1 },
            },
            win_options = {
              winhighlight = {
                Normal = 'NoicePopupmenu', -- Normal | NoicePopupmenu
                FloatBorder = 'NoicePopupmenuBorder', -- DiagnosticInfo | NoicePopupmenuBorder
                CursorLine = 'NoicePopupmenuSelected',
                PmenuMatch = 'NoicePopupmenuMatch',
              },
            },
          },
        },
        cmdline = {
          view = 'cmdline_popup', -- cmdline_popup, cmdline