OOKNET                             [ /  search the index  ]  
──────────────────────────────────────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════════════════════════
OOKNET   [ /  search  ]  
────────────────────────────────────────────────
════════════════════════════════════════════════
 
 
main @ 56 LINES
 
[ HISTORY ]  [ UP ]
 

{
  config,
  lib,
  inputs,
  ...
}: let
  inherit (lib) mkIf mkOption;
  inherit (lib.types) bool;
  inherit (inputs.nvf.lib.nvim.dag) entryAfter;
  cfg = config.vim.telescope;
in {
  options.vim.telescope = {
    autostart = mkOption {
      type = bool;
      default = false;
      description = "Auto start telescope when opening neovim unless opening a fil
e";
    };
  };
  config = mkIf cfg.autostart {
    vim.luaConfigRC.telescope-autostart =
      entryAfter ["pluginConfigs"]
      #lua
      ''
        local find_files_hijack_netrw = vim.api.nvim_create_augroup("find_files_hi
jack_netrw", { clear = true })
        -- clear FileExplorer appropriately to prevent netrw from launching on fol
ders
        -- netrw may or may not be loaded before telescope-find-files
        -- conceptual credits to nvim-tree and telescope-file-browser
        vim.api.nvim_create_autocmd("VimEnter", {
            pattern = "*",
            once = true,
            callback = function()
                pcall(vim.api.nvim_clear_autocmds, { group = "FileExplorer" })
            end,
        })
        vim.api.nvim_create_autocmd("BufEnter", {
            group = find_files_hijack_netrw,
            pattern = "*",
            callback = function()
                vim.schedule(function()
                    -- Early return if netrw or not a directory
                    if vim.bo[0].filetype == "netrw" or vim.fn.isdirectory(vim.fn.
expand("%:p")) == 0 then
                        return
                    end

                    vim.api.nvim_buf_set_option(0, "bufhidden", "wipe")

                    require("telescope.builtin").find_files({
                        cwd = vim.fn.expand("%:p:h"),
                    })
                end)
            end,
        })
      '';
  };
}

{
  config,
  lib,
  inputs,
  ...
}: let
  inherit (lib) mkIf mkOption;
  inherit (lib.types) bool;
  inherit (inputs.nvf.lib.nvim.dag) entryAft
er;
  cfg = config.vim.telescope;
in {
  options.vim.telescope = {
    autostart = mkOption {
      type = bool;
      default = false;
      description = "Auto start telescope wh
en opening neovim unless opening a file";
    };
  };
  config = mkIf cfg.autostart {
    vim.luaConfigRC.telescope-autostart =
      entryAfter ["pluginConfigs"]
      #lua
      ''
        local find_files_hijack_netrw = vim.
api.nvim_create_augroup("find_files_hijack_n
etrw", { clear = true })
        -- clear FileExplorer appropriately 
to prevent netrw from launching on folders
        -- netrw may or may not be loaded be
fore telescope-find-files
        -- conceptual credits to nvim-tree a
nd telescope-file-browser
        vim.api.nvim_create_autocmd("VimEnte
r", {
            pattern = "*",
            once = true,
            callback = function()
                pcall(vim.api.nvim_clear_aut
ocmds, { group = "FileExplorer" })
            end,
        })
        vim.api.nvim_create_autocmd("BufEnte
r", {
            group = find_files_hijack_netrw,
            pattern = "*",
            callback = function()
                vim.schedule(function()
                    -- Early return if netrw
 or not a directory
                    if vim.bo[0].filetype ==
 "netrw" or vim.fn.isdirectory(vim.fn.expand
("%:p")) == 0 then
                        return
                    end

                    vim.api.nvim_buf_set_opt
ion(0, "bufhidden", "wipe")

                    require("telescope.built
in").find_files({
                        cwd = vim.fn.expand(
"%:p:h"),
                    })
                end)
            end,
        })
      '';
  };
}
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET