jinh0 / eyeliner.nvim

👀 Move faster with unique f/F indicators.
461 stars 15 forks source link

Feature request: Disable eyeliner.nvim in certain filetypes #50

Closed ghost closed 3 months ago

ghost commented 3 months ago

I manually implemented it with the EyelinerEnable and EyelinerDisable commands, but it would be nice to have a simple option to list the excluded filetypes like quick-scope has.

return {
    "jinh0/eyeliner.nvim",
    event = { "BufReadPost", "BufNewFile" },
    config = function()
        require("eyeliner").setup({})
        vim.api.nvim_set_hl(0, "EyelinerPrimary", { bold = true, underline = true })
        vim.api.nvim_set_hl(0, "EyelinerSecondary", { underline = true })
        local excluded = { "neo-tree" }
        vim.api.nvim_create_autocmd("BufEnter", {
            pattern = "*",
            group = vim.api.nvim_create_augroup("eyeliner_enable", {}),
            callback = function()
                if not vim.list_contains(excluded, vim.bo.filetype) then
                    vim.cmd("EyelinerEnable")
                end
            end,
            desc = "Restore eyeliner.nvim",
        })
        vim.api.nvim_create_autocmd("Filetype", {
            pattern = { "neo-tree" },
            group = vim.api.nvim_create_augroup("eyeliner_disable", {}),
            command = "EyelinerDisable",
            desc = "Disable eyeliner.nvim in certain filetypes",
        })
    end,
}
jinh0 commented 3 months ago

Hi @levioneyh , thanks for the feature suggestion!

I have implemented the feature for the always-on mode in this commit 7c482d9b93641c61e1b9c7372a555f8e2953f958 . The feature for the on-key mode is WIP right now. You can now disable certain filetypes and buftypes by providing a list:

require("eyeliner").setup({
      disabled_filetypes = {"NvimTree", "help"},
      disabled_buftypes = {"nofile"}
})

I don't know if it's the same for Neo-tree, but for nvim-tree.lua, I had to add "nofile" as a disabled buftype in order for eyeliner to be disabled on nvim-tree's file explorer.

Let me know if it works!

ghost commented 3 months ago

it works perfectly, thanks!

jinh0 commented 3 months ago

Awesome! I've also just added it to the on-key mode as well in this commit c4afbdd1eb635330200825786916bb699229a60f . We can reopen this issue if there's any problems 😄