m4xshen / hardtime.nvim

Establish good command workflow and quit bad habit
MIT License
1.35k stars 27 forks source link

When Installed, I get errors when using telescope #84

Closed Minjares closed 4 months ago

Minjares commented 4 months ago

Describe the bug When the plugin is installed I get this error when trying to open telescope E5108: Error executing lua: .../share/nvim/lazy/plenary.nvim/lua/plenary/popup/init.lua:172: Failed to save undo information stack traceback: [C]: in function 'nvim_buf_set_lines' .../share/nvim/lazy/plenary.nvim/lua/plenary/popup/init.lua:172: in function 'create' ...share/nvim/lazy/telescope.nvim/lua/telescope/pickers.lua:331: in function '_create_window' ...share/nvim/lazy/telescope.nvim/lua/telescope/pickers.lua:382: in function 'find' ...im/lazy/telescope.nvim/lua/telescope/builtin/files.lua:350: in function 'v' ...im/lazy/telescope.nvim/lua/telescope/builtin/files.lua:595: in function 'v' .../nvim/lazy/telescope.nvim/lua/telescope/builtin/init.lua:542: in function <.../nvim/lazy/telescope.nvim/lua/telescope/builtin/init.lua :501>

Config options { "m4xshen/hardtime.nvim", dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" }, opts = {} },

To Reproduce Steps to reproduce the behavior: Have this config for telescope:

{
    "nvim-telescope/telescope.nvim",
    dependencies = { "nvim-lua/plenary.nvim" },
    tag = "0.1.6",
    config = function()
        local builtin = require("telescope.builtin")
        vim.keymap.set("n", "<C-p>", builtin.find_files, {})
        vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
    end,
},
{
    "nvim-telescope/telescope-ui-select.nvim",
    config = function()
        require("telescope").setup({
            extensions = {
                ["ui-select"] = {
                    require("telescope.themes").get_dropdown({}),
                },
            },
        })
        require("telescope").load_extension("ui-select")
    end,
},

Add this plugin: { "m4xshen/hardtime.nvim", dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" }, opts = {} },

Expected behavior When I try to open telescope find_files I get this error: E5108: Error executing lua: .../share/nvim/lazy/plenary.nvim/lua/plenary/popup/init.lua:172: Failed to save undo information stack traceback: [C]: in function 'nvim_buf_set_lines' .../share/nvim/lazy/plenary.nvim/lua/plenary/popup/init.lua:172: in function 'create' ...share/nvim/lazy/telescope.nvim/lua/telescope/pickers.lua:331: in function '_create_window' ...share/nvim/lazy/telescope.nvim/lua/telescope/pickers.lua:382: in function 'find' ...im/lazy/telescope.nvim/lua/telescope/builtin/files.lua:350: in function 'v' ...im/lazy/telescope.nvim/lua/telescope/builtin/files.lua:595: in function 'v' .../nvim/lazy/telescope.nvim/lua/telescope/builtin/init.lua:542: in function <.../nvim/lazy/telescope.nvim/lua/telescope/builtin/init.lua :501>

HudsonMC16 commented 4 months ago

This is likely related to issue #33. I am also running into this in my config, even after mapping the keys as mentioned in that issue (within the lazy config).

m4xshen commented 4 months ago

@Minjares thanks for the bug report. I'm trying to reproduce it. Could you please explain this line of your config:

vim.keymap.set("n", "", builtin.find_files, {})

Why the left hand side key is an empty string? Is this a typo?

Minjares commented 4 months ago

@Minjares thanks for the bug report. I'm trying to reproduce it. Could you please explain this line of your config:

vim.keymap.set("n", "", builtin.find_files, {})

Why the left hand side key is an empty string? Is this a typo?

Sorry, I didn't knew Markdown erases <> I already corrected it, it is <C-p>

HudsonMC16 commented 4 months ago

@Minjares you might also just remove that key from the restricted_keys section since it seems like you're not using it for it's original mapping anyway. Hardtime doesn't really have any reason to restrict its use in your case. You can add the following to your config function:

local hardtime = require("hardtime")
local config = require("hardtime.config").config
config.restricted_keys["<C-P>"] = nil
hardtime.setup(config)
m4xshen commented 4 months ago

@HudsonMC16 @Minjares The issue is fixed! Now you don't need to remove the key from restricted_key config. Your key config will overwrite it.

Please try out by updating to the lastest version and if you still encounter any bugs feel free to tell me!