fix: open more text file types in editor (nvim)

Expand textExtensions with many missing common text file extensions
(.lua, .rb, .vue, .svelte, .dart, .tex, .scala, .lisp, and many more).

Add textFilenames list for well-known text files without a meaningful
extension (Makefile, Dockerfile, README, LICENSE, .gitignore, etc.)
so they open in the editor via handleEdit() instead of falling back
to xdg-open via handleOpenExternal().
This commit is contained in:
vrubelroman 2026-04-27 14:23:29 +03:00
parent ce2f488c89
commit 22af43acd7

View file

@ -14,15 +14,51 @@ var (
}
textExtensions = map[string]struct{}{
"txt": {}, "md": {}, "rst": {}, "go": {}, "rs": {}, "c": {}, "h": {}, "cpp": {}, "hpp": {},
"py": {}, "js": {}, "ts": {}, "tsx": {}, "jsx": {}, "java": {}, "kt": {}, "swift": {},
"html": {}, "css": {}, "scss": {}, "sh": {}, "bash": {}, "zsh": {}, "fish": {}, "sql": {},
"log": {}, "csv": {},
"py": {}, "js": {}, "ts": {}, "tsx": {}, "jsx": {}, "java": {}, "kt": {}, "kts": {}, "swift": {},
"html": {}, "css": {}, "scss": {}, "sass": {}, "less": {}, "styl": {},
"sh": {}, "bash": {}, "zsh": {}, "fish": {}, "sql": {},
"log": {}, "csv": {}, "tsv": {},
"lua": {}, "rb": {}, "pl": {}, "pm": {}, "t": {}, "ps1": {}, "bat": {}, "cmd": {},
"vue": {}, "svelte": {}, "astro": {}, "ejs": {}, "hbs": {}, "pug": {}, "haml": {}, "php": {}, "twig": {},
"scala": {}, "groovy": {}, "clj": {}, "ex": {}, "exs": {}, "elm": {}, "hs": {}, "lisp": {}, "cl": {}, "rkt": {}, "scm": {}, "dart": {},
"tex": {}, "bib": {}, "sty": {}, "cls": {},
"gradle": {}, "cmake": {}, "mk": {}, "mak": {},
"asm": {}, "s": {}, "inc": {},
"patch": {}, "diff": {},
"proto": {}, "graphql": {}, "gql": {},
"tf": {}, "hcl": {},
"r": {}, "m": {}, "mm": {},
"nim": {}, "zig": {}, "odin": {}, "v": {},
"cr": {}, "jl": {},
"erl": {}, "hrl": {},
}
// textFilenames lists common text files without a meaningful extension
// (like Makefile, Dockerfile, etc.) so they open in the editor.
textFilenames = map[string]struct{}{
"makefile": {}, "dockerfile": {}, "containerfile": {},
"readme": {}, "license": {}, "licence": {}, "copying": {}, "changelog": {}, "changes": {},
"todo": {}, "notes": {}, "authors": {}, "contributors": {}, "maintainers": {},
"procfile": {}, "gemfile": {}, "rakefile": {}, "snapfile": {}, "fastfile": {},
"cmakelists": {}, "justfile": {}, "taskfile": {},
"gitignore": {}, "gitattributes": {}, "gitmodules": {}, "gitkeep": {},
"gitconfig": {}, "git-blame-ignore-revs": {},
"editorconfig": {}, "envrc": {}, "hushlogin": {},
"xsession": {}, "xresources": {}, "xinitrc": {},
"bashrc": {}, "bash_profile": {}, "bash_logout": {},
"zshrc": {}, "zprofile": {}, "zlogin": {}, "zlogout": {},
"profile": {}, "inputrc": {}, "tmux.conf": {},
"npmrc": {}, "yarnrc": {}, "pnpmrc": {},
"eslintrc": {}, "prettierrc": {}, "babelrc": {},
"stylelintrc": {}, "commitlintrc": {},
"htaccess": {}, "htpasswd": {},
}
imageExtensions = map[string]struct{}{
"png": {}, "jpg": {}, "jpeg": {}, "gif": {}, "webp": {}, "bmp": {}, "svg": {}, "ico": {},
"avif": {}, "heic": {}, "heif": {}, "tiff": {}, "tif": {},
}
archiveExtensions = map[string]struct{}{
"zip": {}, "tar": {}, "gz": {}, "tgz": {}, "xz": {}, "bz2": {}, "7z": {}, "rar": {},
"zst": {}, "lz": {}, "lz4": {}, "lzma": {},
}
)
@ -79,6 +115,8 @@ func (e Entry) Category() string {
return "text"
case hasExt(archiveExtensions, e.Extension):
return "archive"
case hasExt(textFilenames, strings.ToLower(e.Name)):
return "text"
default:
return "binary"
}