neovim: changes to how we access nvf.lib
This commit is contained in:
parent
7868ac1529
commit
8d9c2a0ed2
39 changed files with 30 additions and 28 deletions
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
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 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_netrw", { clear = true })
|
||||
-- clear FileExplorer appropriately to prevent netrw from launching on folders
|
||||
-- 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,
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue