natecraddock / workspaces.nvim

a simple plugin to manage workspace directories in neovim
MIT License
309 stars 15 forks source link

Keep_insert not working #6

Closed danymat closed 2 years ago

danymat commented 2 years ago

Hello, I use now your plugin as primary workspace jumping, and it works very well, congrats, and thanks !

It seems that keep_insert is not working, this is my telescope config and my workspace one:

        use({
            "nvim-telescope/telescope.nvim",
            config = function()
                local actions = require("telescope.actions")
                require("telescope").setup({
                    defaults = require("telescope.themes").get_ivy({
                        winblend = 10,
                        mappings = {
                            i = {
                                ["<C-j>"] = actions.move_selection_next,
                                ["<C-k>"] = actions.move_selection_previous,

                                ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
                                ["<C-a>"] = actions.send_to_qflist + actions.open_qflist,
                            },
                            n = {
                                ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
                                ["<C-a>"] = actions.send_to_qflist + actions.open_qflist,
                            },
                        },
                    }),
                    extensions = {
                        ["ui-select"] = require("telescope.themes").get_cursor(),
                        workspaces = {
                            keep_insert = true,
                        },
                    },
                })

                require("telescope").load_extension("ui-select")
                require("telescope").load_extension("fzf")
                require("telescope").load_extension("workspaces")
            end,
            requires = {
                "nvim-lua/popup.nvim",
                "nvim-telescope/telescope-ui-select.nvim",
                "nvim-telescope/telescope-fzf-native.nvim",
                "natecraddock/workspaces.nvim",
            },
        })

        use({
            "natecraddock/workspaces.nvim",
            config = function()
                require("workspaces").setup({
                    hooks = {
                        open = { "Telescope find_files" },
                    },
                })
            end,
        })

PS: not related to this issue, but I don't feel like creating an other issue for this: Would it be possible to provide vim.notify messages after a WorkspaceAdd, WorkspaceRemove, WorkspaceList (if no workspaces) ?

natecraddock commented 2 years ago

Thank you for reporting and sharing so much details! That will help me debug. I won't have time to look closer until tomorrow, but I've also seen some issues with keep_insert lately so I'm interested in getting this resolved quickly. I'll keep you updated!

Would it be possible to provide vim.notify messages after a WorkspaceAdd, WorkspaceRemove, WorkspaceList (if no workspaces) ?

I think this is fine, let me make sure I understand. After a WorkspacesAdd or WorkspacesRemove a notification indicating success, and after WorkspacesList a notification warning if there are no workspaces? I'll probably put this behind a configuration boolean.

I use now your plugin as primary workspace jumping, and it works very well, congrats, and thanks !

I'm glad you find it useful :)

natecraddock commented 2 years ago

Other than installing ui-select and fzf extensions, I replicated your setup and cannot reproduce. I open a workspace and the find_files picker opens in insert mode. When you say keep_insert isn't working, do you mean that the picker opens in normal mode after using the extension :Telescope workspaces when it should be insert, right?

Based on the behavior of startinsert and stopinsert, I'm thinking this might be a timing/race condition bug. My open hook first tries to load a saved session, and if that fails it tries to open a find_files picker. In that case the picker opens in normal mode for me instead of insert mode. I have a few ideas and I'll try those to see if I can resolve anything.

danymat commented 2 years ago

Other than installing ui-select and fzf extensions, I replicated your setup and cannot reproduce. I open a workspace and the find_files picker opens in insert mode. When you say keep_insert isn't working, do you mean that the picker opens in normal mode after using the extension :Telescope workspaces when it should be insert, right?

:Telescope workspaces opens in insert mode, but after <CR>, the hook is back on normal mode

danymat commented 2 years ago

I think this is fine, let me make sure I understand. After a WorkspacesAdd or WorkspacesRemove a notification indicating success, and after WorkspacesList a notification warning if there are no workspaces? I'll probably put this behind a configuration boolean.

Exactly !

natecraddock commented 2 years ago

I just made the fix-6-keep-insert branch which hopefully resolves this issue. When you get a chance, could you test it and let me know if everything works?

danymat commented 2 years ago

It works well !

natecraddock commented 2 years ago

Great to hear! Merged to master

natecraddock commented 2 years ago

Going to leave this as a note here: https://github.com/nvim-telescope/telescope.nvim/pull/1600/files Seems like this was introduced in nvim 0.6.1, and it may be fixed in 0.7.0?