mvllow / modes.nvim

Prismatic line decorations for the adventurous vim user
550 stars 13 forks source link

Incompatibility with neo-tree fuzzy search cursorline highlight #34

Closed Frydac closed 1 year ago

Frydac commented 2 years ago

Hi,

Not sure if I should post it here or on neo-tree issues.

I thought, at least I report it, so it is known.

But when using neo-tree, it has a fuzzy search functionality (default / when tree is open), where it opens a one-line floating window at the bottom of the tree window to type the search term in, it will then filter the tree to only show matching files (in tree form). While the cursor is in the floating window, it should have a cursorline highlight in the tree showing the current selected tree node, which can be altered with <up> and <down>. This highlight should be shown while the cursor remains in insert mode in the floating window with the search term.

When modes.nvim is installed, the described cursorline highlight is not visible.

I tried add the filetype 'neo-tree' to the ignore_filetypes configuration option, but that didn't seem to help.

mvllow commented 2 years ago

This seems similar to https://github.com/mvllow/modes.nvim/issues/28

We'll leave this one open if anyone is able to come up with a solution :)

fitrh commented 2 years ago

@mvllow @Frydac can you guys try these patches branches? I don't know which one is the desired behavior or fits the tree-navigation workflow as I'm not using neo-tree (or NvimTree)

EDIT: Updated V1

Patch V1

diff --git a/lua/modes.lua b/lua/modes.lua
index 91c0caf..8024927 100644
--- a/lua/modes.lua
+++ b/lua/modes.lua
@@ -13,7 +13,7 @@ local default_config = {
    set_cursor = true,
    set_cursorline = true,
    set_number = true,
-   ignore_filetypes = { 'NvimTree', 'TelescopePrompt' },
+   ignore_filetypes = { 'neo-tree', 'NvimTree', 'TelescopePrompt' },
 }
 local winhighlight = {
    default = {
@@ -147,6 +147,10 @@ M.define = function()
 end

 M.enable_managed_ui = function()
+   if vim.tbl_contains(config.ignore_filetypes, vim.bo.filetype) then
+       return
+   end
+
    if config.set_cursor then
        vim.opt.guicursor:append('v-sm:block-ModesVisual')
        vim.opt.guicursor:append('i-ci-ve:ver25-ModesInsert')
@@ -159,6 +163,10 @@ M.enable_managed_ui = function()
 end

 M.disable_managed_ui = function()
+   if vim.tbl_contains(config.ignore_filetypes, vim.bo.filetype) then
+       return
+   end
+
    if config.set_cursor then
        vim.opt.guicursor:remove('v-sm:block-ModesVisual')
        vim.opt.guicursor:remove('i-ci-ve:ver25-ModesInsert')

Patch V2

diff --git a/lua/modes.lua b/lua/modes.lua
index 91c0caf..9a05dbd 100644
--- a/lua/modes.lua
+++ b/lua/modes.lua
@@ -13,7 +13,7 @@ local default_config = {
    set_cursor = true,
    set_cursorline = true,
    set_number = true,
-   ignore_filetypes = { 'NvimTree', 'TelescopePrompt' },
+   ignore_filetypes = { 'neo-tree', 'NvimTree', 'TelescopePrompt' },
 }
 local winhighlight = {
    default = {
@@ -291,7 +291,13 @@ M.setup = function(opts)
    ---Disable managed UI for unfocused windows
    vim.api.nvim_create_autocmd('WinLeave', {
        pattern = '*',
-       callback = M.disable_managed_ui,
+       callback = function()
+           if
+               not vim.tbl_contains(config.ignore_filetypes, vim.bo.filetype)
+           then
+               M.disable_managed_ui()
+           end
+       end,
    })

    ---Disable managed UI for ignored filetypes
fitrh commented 2 years ago

@mvllow I also always disable set_cursorline since I have my own autocmd for that, so maybe I missed something on this bug

mvllow commented 2 years ago

The first method seems more desirable in my opinion. Unable to test with neo-tree at the moment but I think we could pretty safely merge this change, especially if we tag a release before-hand.