fixed hidden files display
This commit is contained in:
Executable → Regular
+45
-31
@@ -3,7 +3,7 @@
|
|||||||
install_neovim.py
|
install_neovim.py
|
||||||
|
|
||||||
Install Neovim from the latest official GitHub binary release, then install
|
Install Neovim from the latest official GitHub binary release, then install
|
||||||
LazyVim and patch the Telescope config to show hidden files.
|
LazyVim and patch the snacks.nvim picker config to show hidden files.
|
||||||
|
|
||||||
Targets:
|
Targets:
|
||||||
Windows 10/11 (x86_64), macOS (arm64 / x86_64), Linux (x86_64 / arm64).
|
Windows 10/11 (x86_64), macOS (arm64 / x86_64), Linux (x86_64 / arm64).
|
||||||
@@ -559,56 +559,70 @@ def install_lazyvim(target: Target) -> Path:
|
|||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Telescope override
|
# snacks.nvim override
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
TELESCOPE_OVERRIDE_LUA = '''-- Generated by install_neovim.py
|
SNACKS_OVERRIDE_LUA = '''-- Generated by install_neovim.py
|
||||||
-- Show hidden files in Telescope's find_files and live_grep pickers.
|
-- Override LazyVim's bundled snacks.nvim config to show hidden files
|
||||||
-- (.git/ is still excluded; remove the --glob/!.git line below to include it.)
|
-- in the picker (files, grep) and the explorer.
|
||||||
|
--
|
||||||
|
-- Notes:
|
||||||
|
-- * `hidden = true` shows dotfiles (e.g. .env.example, .eslintrc).
|
||||||
|
-- * `ignored` is left at its default (false), so files matched by
|
||||||
|
-- .gitignore stay hidden. Flip to `true` if you want to see them.
|
||||||
|
-- * lazy.nvim deep-merges these `opts` into LazyVim's existing snacks
|
||||||
|
-- config; everything else (dashboard, notifier, indent, etc.) is
|
||||||
|
-- preserved untouched.
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"nvim-telescope/telescope.nvim",
|
"folke/snacks.nvim",
|
||||||
opts = {
|
opts = {
|
||||||
defaults = {
|
picker = {
|
||||||
vimgrep_arguments = {
|
hidden = true,
|
||||||
"rg",
|
sources = {
|
||||||
"--color=never",
|
files = {
|
||||||
"--no-heading",
|
|
||||||
"--with-filename",
|
|
||||||
"--line-number",
|
|
||||||
"--column",
|
|
||||||
"--smart-case",
|
|
||||||
"--hidden",
|
|
||||||
"--glob=!.git/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
pickers = {
|
|
||||||
find_files = {
|
|
||||||
hidden = true,
|
hidden = true,
|
||||||
},
|
},
|
||||||
|
grep = {
|
||||||
|
hidden = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
explorer = {
|
||||||
|
hidden = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
# Marker used to detect files this script has previously written, so we can
|
||||||
|
# distinguish our own generated config from a user-authored file with the
|
||||||
|
# same name and avoid clobbering the latter.
|
||||||
|
GENERATED_MARKER = "-- Generated by install_neovim.py"
|
||||||
|
|
||||||
def configure_telescope_hidden(config_dir: Path) -> Path:
|
|
||||||
|
def configure_snacks_hidden(config_dir: Path) -> Path:
|
||||||
plugins_dir = config_dir / "lua" / "plugins"
|
plugins_dir = config_dir / "lua" / "plugins"
|
||||||
plugins_dir.mkdir(parents=True, exist_ok=True)
|
plugins_dir.mkdir(parents=True, exist_ok=True)
|
||||||
out = plugins_dir / "telescope.lua"
|
|
||||||
|
out = plugins_dir / "snacks.lua"
|
||||||
if out.is_file():
|
if out.is_file():
|
||||||
try:
|
try:
|
||||||
current = out.read_text(encoding="utf-8")
|
current = out.read_text(encoding="utf-8")
|
||||||
except OSError:
|
except OSError:
|
||||||
current = None
|
current = None
|
||||||
if current == TELESCOPE_OVERRIDE_LUA:
|
if current == SNACKS_OVERRIDE_LUA:
|
||||||
LOG.info("Telescope override already present at %s; no changes needed.",
|
LOG.info("Snacks override already present at %s; no changes needed.",
|
||||||
out)
|
out)
|
||||||
return out
|
return out
|
||||||
|
if current is not None and not current.startswith(GENERATED_MARKER):
|
||||||
|
LOG.warning("Existing %s is user-authored (no generated marker); "
|
||||||
|
"refusing to overwrite. Skipping snacks config.", out)
|
||||||
|
return out
|
||||||
LOG.info("Existing %s differs from generated content; overwriting.", out)
|
LOG.info("Existing %s differs from generated content; overwriting.", out)
|
||||||
out.write_text(TELESCOPE_OVERRIDE_LUA, encoding="utf-8")
|
out.write_text(SNACKS_OVERRIDE_LUA, encoding="utf-8")
|
||||||
LOG.info("Wrote Telescope override to %s", out)
|
LOG.info("Wrote snacks.nvim override to %s", out)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
@@ -637,18 +651,18 @@ def print_followup(target: Target, bin_dir: Path, *, lazyvim_skipped: bool) -> N
|
|||||||
if not lazyvim_skipped:
|
if not lazyvim_skipped:
|
||||||
print()
|
print()
|
||||||
print("On first launch, LazyVim will bootstrap lazy.nvim and install plugins.")
|
print("On first launch, LazyVim will bootstrap lazy.nvim and install plugins.")
|
||||||
print("Telescope is configured to show hidden files (find_files & live_grep).")
|
print("snacks.picker is configured to show hidden files (find_files, grep, explorer).")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Install Neovim + LazyVim with Telescope hidden-files enabled.",
|
description="Install Neovim + LazyVim with snacks.picker hidden-files enabled.",
|
||||||
)
|
)
|
||||||
parser.add_argument("-v", "--verbose", action="store_true",
|
parser.add_argument("-v", "--verbose", action="store_true",
|
||||||
help="Enable debug logging.")
|
help="Enable debug logging.")
|
||||||
parser.add_argument("--skip-lazyvim", action="store_true",
|
parser.add_argument("--skip-lazyvim", action="store_true",
|
||||||
help="Install only the Neovim binary; skip LazyVim and Telescope steps.")
|
help="Install only the Neovim binary; skip LazyVim and snacks steps.")
|
||||||
# Internal: set by the script itself when relaunching with UAC elevation
|
# Internal: set by the script itself when relaunching with UAC elevation
|
||||||
# on Windows. Prevents an infinite elevation loop.
|
# on Windows. Prevents an infinite elevation loop.
|
||||||
parser.add_argument("--elevated-relaunch", action="store_true",
|
parser.add_argument("--elevated-relaunch", action="store_true",
|
||||||
@@ -745,7 +759,7 @@ def main() -> int:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
config_dir = install_lazyvim(target)
|
config_dir = install_lazyvim(target)
|
||||||
configure_telescope_hidden(config_dir)
|
configure_snacks_hidden(config_dir)
|
||||||
except InstallError as e:
|
except InstallError as e:
|
||||||
LOG.error(str(e))
|
LOG.error(str(e))
|
||||||
LOG.error("Neovim is installed but LazyVim setup failed. "
|
LOG.error("Neovim is installed but LazyVim setup failed. "
|
||||||
|
|||||||
Reference in New Issue
Block a user