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: Show intro message #1980

Merged
merged 3 commits into from Aug 18, 2023

Conversation

fredizzimo
Copy link
Member

@fredizzimo fredizzimo commented Aug 15, 2023

What kind of change does this PR introduce

This emulates the standard Neovim :intro message at startup. It's shown if the current buffer is empty and not backed by a file. The message is always centered and does not close when the window is resized, unlike the standard message. Another difference is that this message closes directly on any mode chance except changes from/to cmd mode, while the standard message stays visible if you go into insert mode, until you type something.

NOTE: That this is not a maintainable solution, so the goal is to get this or something similar implemented in Neovim itself, but for now I think this is good enough for us.

Fixes: #620

For the corresponding Neovim issue see neovim/neovim#24705

Did this PR introduce a breaking change?

A breaking change includes anything that breaks backwards compatibility either at compile or run time.

  • No

@fredizzimo
Copy link
Member Author

I have only done some basic testing myself, so this needs a bit more testing before merging. We need to test at least for compatibility with plugin managers like lazy vim. It should not show there, since they have their own startup screen.

@@ -30,6 +30,8 @@ const REGISTER_CLIPBOARD_PROVIDER_LUA: &str = r"
cache_enabled = 0
}";

const INTRO_MESSAGE: &str = include_str!("../../lua/intro.lua");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe call this INTRO_MESSAGE_LUA. As is the variable could be construed as the message itself

Copy link
Member Author

Choose a reason for hiding this comment

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

This is fixed now

@rosingrind
Copy link

rosingrind commented Aug 15, 2023

this needs a bit more testing before merging

Startup message

I can confirm that it's showing an intro message on my system with --clean:

Screenshot 2023-08-16 at 12 33 24 AM

And with my config (lazy.nvim, lualine, etc.):

Screenshot 2023-08-16 at 12 34 00 AM

Invoking :intro

But, behavior of invoking :intro command haven't changed, neither on --clean:

Screenshot 2023-08-16 at 12 38 13 AM

Nor on my config:

Screenshot 2023-08-16 at 12 38 32 AM

It's an invisible buffer, and the cursor still moves to bottom-right of this buffer (regardless of having a startup message on screen or not, it's the same):

Screenshot 2023-08-16 at 12 41 48 AM

@fredizzimo
Copy link
Member Author

But, behavior of invoking :intro command haven't changed,

Yes, I did not want to override that command and I'm not sure if it's even possible. It works without multi-grid, but when using multigrid it gets rendered behind the main window.

@rosingrind
Copy link

Oh, I have multigrid enabled indeed. Then I think the goals are achieved 👍

By the way, startup intro obviously closes when you enter insert mode, so I think it's good to go. I didn't mention that, but it may be important :)

@fredizzimo
Copy link
Member Author

By the way, startup intro obviously closes when you enter insert mode, so I think it's good to go. I didn't mention that, but it may be important :)

That's actually slightly different from the original behaviour, but I think it's better. With standard terminal Neovim, entering insert mode does not close the message, it only closes when you start to type.

The message here also closes when switching to other modes. on movement, on buffer switching, on modifications and so on. Basically, anything else than going into the command mode, so you can see the message when typing :help iccf, once you press enter it disappears and the help is shown instead.

One thing that still needs testing is compatibility with LazyVim for example, which has its own startup screen.

@rosingrind
Copy link

With standard terminal Neovim, entering insert mode does not close the message, it only closes when you start to type

You're right, I forgot that it's behaving like that in a terminal nvim :)

compatibility with LazyVim

That's how it is on a fresh start with pre-install (intro message haven't showed up):

Screenshot 2023-08-16 at 1 25 14 AM

This is a restarted instance (same):

Screenshot 2023-08-16 at 1 26 27 AM

Invoking :intro changes absolutely nothing (there's no changes in a cursor position, or anything else)

@rosingrind
Copy link

It could be nice if someone from a linked issue may verify that for integrity on their machines by the way, but years have passed. So, if you need anything else - feel free to ask/post a checklist

@fredizzimo
Copy link
Member Author

fredizzimo commented Aug 16, 2023

I have tested passing both directories and files on the commandline, and everything seems to be consistent with the default intro screen, it's not shown when you do that.

It even works correctly with neo-tree which is opened instead of the built-in netrw when passing directories.

Edit: To clarify, by working correctly I mean not showing the message in these cases.

lua/intro.lua Show resolved Hide resolved
lua/intro.lua Show resolved Hide resolved
@MultisampledNight MultisampledNight merged commit de64b8c into neovide:main Aug 18, 2023
2 checks passed
@9mm
Copy link
Contributor

9mm commented Aug 18, 2023

Is there something special to getting shortmess = 'I' to work?

vim.opt.shortmess = 'I'

It doesnt appear to skip it

@MultisampledNight
Copy link
Contributor

At the moment it's ignored. Chances are the logic here will be reworked sooner or later for listening to Neovim itself. A quick workaround for Neovide (and not the TUI) would be this in init.vim though, since entering insert mode removes the message in Neovide:

startinsert
stopinsert

@9mm
Copy link
Contributor

9mm commented Aug 19, 2023

Is there a way to get it to work with init.lua instead of init.vim? this doesnt appear to do anything:

vim.cmd('startinsert')
vim.cmd('stopinsert')

@fredizzimo
Copy link
Member Author

Yes, this was an oversight, I did not know about the shortmes option. But I think the workaround does not work because it happens too early. So you probably need something like this, but I haven't tested it

local autogroup = vim.api.nvim_create_augroup("disable_intro", { clear = true })
vim.api.nvim_create_autocmd({ "VimEnter" }, {
    pattern = "*",
    group = autogroup,
    callback = function()
        vim.cmd('startinsert')
        vim.cmd('stopinsert')
    end
})

@9mm
Copy link
Contributor

9mm commented Aug 19, 2023

Hmm yeah that doesnt appear to work for me either, I'll have to play around with it later.

@asharkhan3101
Copy link

asharkhan3101 commented Aug 23, 2023

vim.opt.shortmess:append({I = true}) seems to be getting ignored.
I also don't know how to get rid of this message since its not going away.

I am downgrading but thought to post it here.
Screenshot 2023-08-23 at 10 22 41 PM

EDIT: Using --multigrid and --maximized

@ghost
Copy link

ghost commented Aug 26, 2023

Anyone have a way of fixing the stuck message? Ive tried a few different methods and none seem to work.

@fredizzimo
Copy link
Member Author

@casrass
I'm looking into it, but meanwhile you can use #1985, which let you disable the message with the shortmess+=I option.

@fredizzimo
Copy link
Member Author

I don't know why that's the cause, but I found out that using packer to lazy load dashboard-nvim causes the VimEnter autocommand to fire twice.

A workaround is to remve event = 'VimEnter' and change

use {
  'glepnir/dashboard-nvim',
  event = 'VimEnter',
  config = function()
    require('dashboard').setup {
      -- config
    }
  end,
  requires = {'nvim-tree/nvim-web-devicons'}
}

to

use {
  'glepnir/dashboard-nvim',
  config = function()
    require('dashboard').setup {
      -- config
    }
  end,
  requires = {'nvim-tree/nvim-web-devicons'}
}

I don't use lazy.nvim, but the cause is probably the same with that as well.

I can fix it in Neovide by ignoring the second VimEnter, but I don't know why the package manager causes the off-spec behaviour of firing the event twice in the first place.

@fredizzimo
Copy link
Member Author

Hm. packer does indeed seem to fire the event again
https://github.com/wbthomason/packer.nvim/blob/ea0cc3c59f67c440c5ff0bbe4fb9420f4350b9a3/lua/packer/load.lua#L118

I still have no idea why, but there's probably a good reason.

I also don't have any idea why startup-nvim recommends to lazy load on VimEnter, rather than just loading it normally during the startup, to me there doesn't seem to be any benefits at all, since both are done before anything is shown.

Anyway, I will fix the issue by only listening for VimEnter once

@9mm
Copy link
Contributor

9mm commented Aug 26, 2023

I don't know if it matters but I don't use any dashboard at all, nothing fancy, and I still tried multiple ways to get it working without much luck. Heres the current way i have commented out that also doesnt work:

local autogroup = vim.api.nvim_create_augroup("disable_intro", { clear = true })
vim.api.nvim_create_autocmd({ "VimEnter" }, {
    pattern = "*",
    group = autogroup,
    callback = function()
        vim.cmd('startinsert')
        vim.cmd('stopinsert')
    end
})

@fredizzimo
Copy link
Member Author

fredizzimo commented Aug 27, 2023

@9mm If you are talking abou tthe issue of not being able to close it at all, then you probably have some other lazy loaded plug that causes VimEnter to be called multiple times. This is fixed in #1985.

That PR also fixes the shortmess+=I option not working, so you should be able to completely turn it off.

Pre-built binaries for that can be found here https://github.com/fredizzimo/neovide/actions/runs/5991961622

@9mm
Copy link
Contributor

9mm commented Aug 27, 2023

It closes OK, I was just also trying to find a way to not have it open to start with. Im considering switching to master soon though as all the good fixes I want are there :D

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.

How to get neovim's default buffer?
6 participants