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

Ignore_filetypes fails for mode changes inside ignored file #28

Closed
PriceHiller opened this issue May 8, 2022 · 9 comments · Fixed by #39
Closed

Ignore_filetypes fails for mode changes inside ignored file #28

PriceHiller opened this issue May 8, 2022 · 9 comments · Fixed by #39
Assignees

Comments

@PriceHiller
Copy link
Contributor

PriceHiller commented May 8, 2022

Description

I use neo-tree for my file browser and recently noticed that the fuzzy_search functionality in it, when combined with modes.nvim, leaves my cursorline invisible in insert mode. The cursorline works as expected when I disable modes.nvim. My config has neo-tree & the neo-tree-popup in the ignore_filetypes and I still am getting an invisible cursorline in the fuzzy_search mode.

My relevant modes config:

local modes = require('modes')
modes.setup({
    colors = {
        visual = '#F959FF',
    },
    ignore_filetypes = {
        'neo-tree',
        'neo-tree-popup',
        'TelescopePrompt',
    },
})

Here's a gif of the bug in action:
NTInvisible

Here's a gif with modes removed & neo-tree working as expected:
NTCorrect

Potential Fix

It's 100% related to this single nvim_autocmd, when I remove it, the plugin works mostly as expected:

vim.api.nvim_create_autocmd('WinLeave', {
	pattern = '*',
	callback = M.disable_managed_ui,
})

Solution One

A fix would be to change the pattern to only act on non-excluded filetypes, or just live with the fact that it's going to highlight the other windows. I'm not sure what a proper fix to this is, but it makes it very difficult to use neo-tree.

The reason this occurs is because when a switch happens to the fuzzy finder, it invokes a WinLeave event which this then catches and disables the cursorline for, disabling the ability to actively browse the file tree with the search window up.

When I state mostly, there is also an issue with the insertenter not respecting the filetype beneath because it's setting the cursorline green when really it's just a picker.

Solution Two

The other way to fix this is to remove this single section in disable_managed_ui:

if config.set_cursorline then
	vim.opt.cursorline = false
end

When the above is removed it also works mostly as expected.

A potential way to "fix" this is to make a note of it in the docs and mention setting the cursorline to false in the setup and setting vim.opt.cursorline = true elsewhere by the user.

Solution Three

In the modes.nvim setup function, passing set_cursorline = false then setting vim.opt.cursorline = true elsewhere in the configuration works, but exited windows still keep their cursorlines as modes is no longer managing the WinLeave events to disable the cursorline.

@mvllow
Copy link
Owner

mvllow commented May 8, 2022

I'm not sure if this is possible – we disable the cursorline for inactive windows so that they are not highlighted by modes. In the linked PR, I tried using just highlights instead of toggling vim.opt.cursorline but in plugins like NvimTree, if you are changing text in a buffer the cursorline in NvimTree will change colours to match (not desirable).

I'm curious if removing any combination of neo-tree/neo-tree-popup from ignored filetypes would give you a better experience?

@PriceHiller
Copy link
Contributor Author

The only way I see this as being possible with desirable behavior is if there is a way we can see what window the WinLeave event is heading to. For instance, I begin the fuzzy search and the WinLeave event function can check if the window being left to is neo-tree-popup and then keep the cursorline, if not then remove it.

Imo – I think I can live with having the cursorline managed and on-screen in multiple windows for now, I don't know a great fix to this that keeps the same behavior and keeps it simple to set up modes from a user perspective.

I'm curious if removing any combination of neo-tree/neo-tree-popup from ignored filetypes would give you a better experience?

No luck I'm afraid. Tried a bunch of combos and played around with ftplugin, but I still don't get desirable behavior 😔. Primary core of the problem for it is detecting what window is being left to, that would be the best way to resolve this.

@mvllow
Copy link
Owner

mvllow commented May 9, 2022

On another note, maybe neo-tree has a way to change search match highlights?

@PriceHiller
Copy link
Contributor Author

Neo-tree does not unfortunately, I have a working solution for myself currently, but I do get cursorlines in windows I'm not in. This is a more fundamental problem to my eyes, not something that can be trivially solved and still maintain all desired functionality across all use cases.

@mvllow
Copy link
Owner

mvllow commented May 12, 2022

This is interesting neovim/neovim#18500

@mvllow
Copy link
Owner

mvllow commented May 17, 2022

Closing as I don't have a good solution for this. PR's are welcome 😌

@mvllow mvllow closed this as completed May 17, 2022
@fitrh
Copy link
Collaborator

fitrh commented Jun 13, 2022

@treatybreaker can you try the latest version of modes.nvim to confirm if this issue still exists ? with and without ignore_filetypes

@PriceHiller
Copy link
Contributor Author

@fitrh Only just saw this now, it still does not work unfortunately. I gave it a shot myself previously to resolve this, but the problem is more fundamental and has to do with how neo-tree handles its own cursor highlights and missing features in the neovim api. At least, that's my understanding.

@fitrh
Copy link
Collaborator

fitrh commented Jun 16, 2022

@treatybreaker how to reproduce your issue ? I never use neo-tree

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 a pull request may close this issue.

3 participants