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

fix(mini): dodge status line when cmdheight > 0 #685

Closed
wants to merge 1 commit into from

Conversation

Frederick888
Copy link

The cmdheight addition in config/init.lua is to avoid breaking the
default setup, where cmdheight is reduced to 0 after MiniView's
initialisation.


I'm migrating to LazyVim but I still like https://github.com/gelguy/wilder.nvim.
So I disabled noice.nvim's cmdline and messages.

But then I noticed that the LSP progress pop-ups started overlapping
with the status line, so here's a patch I managed to put together.

I'm not quite sure if this is the right fix. Feel free to trump this
with a better PR :)

@Frederick888 Frederick888 marked this pull request as ready for review December 31, 2023 18:43
@Frederick888
Copy link
Author

Hmmm... When my system is slow, sometimes they can still overlap with my status bar but only when they are disappearing. Suggestions?

@@ -262,6 +262,9 @@ function M.setup(options)
end,
})

if M.options.cmdline.enabled then
vim.o.cmdheight = 0
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Author

@Frederick888 Frederick888 Jun 12, 2024

Choose a reason for hiding this comment

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

If I don't apply it here, I guess due to the fact that MiniView's initialisation happens too early, there's a gap between the pop-ups and the status line.

image

PS: repro.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "MunifTanjim/nui.nvim",
  { "https://github.com/Frederick888/noice.nvim.git", branch = 'mini-dodge-status-line' },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

require("noice").setup({
  lsp = {
    -- override markdown rendering so that **cmp** and other plugins use **Treesitter**
    override = {
      ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
      ["vim.lsp.util.stylize_markdown"] = true,
      ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp
    },
  },
  -- you can enable a preset for easier configuration
  presets = {
    bottom_search = true, -- use a classic bottom cmdline for search
    command_palette = true, -- position the cmdline and popupmenu together
    long_message_to_split = true, -- long messages will be sent to a split
    inc_rename = false, -- enables an input dialog for inc-rename.nvim
    lsp_doc_border = false, -- add a border to hover docs and signature help
  },

  cmdline = {
    enabled = true,
  },
  messages = {
    enabled = true,
  }
})

local timer = vim.uv.new_timer()
local counter = 1
vim.uv.timer_start(timer, 1000, 1000, function ()
  vim.notify('hello, world! ' .. counter)
  counter = counter + 1
end)

The cmdheight addition in config/init.lua is to avoid breaking the
default setup, where cmdheight is reduced to 0 after MiniView's
initialisation.
@folke
Copy link
Owner

folke commented Jun 17, 2024

I just pushed an update that probably also fixes this issue. Can you check?

@Frederick888
Copy link
Author

Frederick888 commented Jun 18, 2024

I just pushed an update that probably also fixes this issue. Can you check?

Unfortunately no. I checked out 7ee3649 and the issue still persists in both my minimal repro.lua and full setup.

image

repro.lua:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "MunifTanjim/nui.nvim",
  -- { "https://github.com/Frederick888/noice.nvim.git", branch = 'mini-dodge-status-line' },
  "https://github.com/folke/noice.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

require("noice").setup({
  lsp = {
    -- override markdown rendering so that **cmp** and other plugins use **Treesitter**
    override = {
      ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
      ["vim.lsp.util.stylize_markdown"] = true,
      ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp
    },
  },
  -- you can enable a preset for easier configuration
  presets = {
    bottom_search = true, -- use a classic bottom cmdline for search
    command_palette = true, -- position the cmdline and popupmenu together
    long_message_to_split = true, -- long messages will be sent to a split
    inc_rename = false, -- enables an input dialog for inc-rename.nvim
    lsp_doc_border = false, -- add a border to hover docs and signature help
  },

  cmdline = {
    enabled = false,
  },
  messages = {
    enabled = false,
  }
})

local timer = vim.uv.new_timer()
local counter = 1
vim.uv.timer_start(timer, 1000, 1000, function ()
  vim.notify('hello, world! ' .. counter)
  counter = counter + 1
end)

vim.opt.cmdheight = 2

adoyle-h added a commit to adoyle-h/noice.nvim that referenced this pull request Jun 18, 2024
* up/main: (76 commits)
  fix(mini): update view options of underlying view. See folke#685
  chore(build): auto-generate vimdoc
  fix(scrollbar): fix scrollbar. Fixes folke#759. Fixes folke#727
  chore(main): release 4.2.2 (folke#858)
  chore(build): auto-generate vimdoc
  fix(hover): ignore invalid markup. Fixes folke#819
  fix(msg): clear existing confirm messages. Fixes folke#302
  chore(main): release 4.2.1 (folke#857)
  chore(build): auto-generate vimdoc
  fix(cmdline): only use cmdline_input for short prompts without newline. Fixes folke#856
  chore(main): release 4.2.0 (folke#850)
  chore(build): auto-generate vimdoc
  fix(cmdline): allow overriding title hl
  fix(cmdline): reset title when needed
  chore(build): auto-generate vimdoc
  fix(nui): redo layout when border changes
  fix(cmdline_input): put in same position as cmdline_popup
  feat(cmdline): icon for cmdline input
  fix(fzf): message id
  feat(cmdline): use cmdline prompt as title. Noice is now great for vim.ui.input out of the box
  ...
@folke
Copy link
Owner

folke commented Jun 18, 2024

Finally got some time to look into this. This is honestly not a bug.
You can change opts.views.mini.position = -2.
That will solve it for your use-case

@folke folke closed this Jun 18, 2024
@Frederick888 Frederick888 deleted the mini-dodge-status-line branch June 19, 2024 01:14
@Frederick888
Copy link
Author

@folke Thank you! I didn't know that option existed!

I went through the docs, and for the record, I ended up with

{
  'folke/noice.nvim',
  opts = {
    cmdline = { enabled = false },
    messages = { enabled = false },
    popupmenu = { enabled = false },
    views = {
      mini = {
        position = {
          row = -3,
        },
      },
    },
  },
},

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.

3 participants