smjonas / snippet-converter.nvim

Bundle snippets from multiple sources and convert them to your format of choice.
Mozilla Public License 2.0
170 stars 4 forks source link

feat: add support for Emac's YASnippet #11

Closed smjonas closed 1 year ago

smjonas commented 1 year ago

Hey @IllustratedMan-code, I have added support for YASnippet :) I did not test with YASnippet as a source format yet but exporting to YASnippet already works (at least the tests say so ^^). If you want you can already test this PR by checking out the yasnippet branch and setting yasnippet as the source snippet engine.

Feedback welcome.

Closes #10.

IllustratedMan-code commented 1 year ago

I'll give this a try today or tomorrow!

smjonas commented 1 year ago

Everything should be good to merge now. Will wait for your feedback after you've had time to try it out though :)

IllustratedMan-code commented 1 year ago

This is unrelated to the feature, but you have duplicate tags here in your docs: snippet-converter-examples. This prevents the plugin from building for me.

IllustratedMan-code commented 1 year ago

Made #12 to fix that.

IllustratedMan-code commented 1 year ago

Other than that, the only thing missing is some way to map the mode names to vim language names in the cases where they don't match. Examples of this are: web-mode -> html ess-mode -> r, S-Plus, SAS, julia and stata. (there might be more?) This is probably pretty easy to do with a json file (I am happy to maintain it).

IllustratedMan-code commented 1 year ago

Thanks for implementing this!

smjonas commented 1 year ago

Other than that, the only thing missing is some way to map the mode names to vim language names in the cases where they don't match.

Thanks for catching that! I have now implemented this, e.g. the following will now be a part of the generated package.json file when converting snippets in a web-mode folder:

{
    "language": [
        "html"
    ],
    "path": "./web.json"
}

With this information, snippet engines like LuaSnip will show the snippets defined in web.json when the user edits .html files.

Could you test if this works as exptected for you?

This is probably pretty easy to do with a json file (I am happy to maintain it).

I really appreciate your offer to maintain this. Feel free to create a PR containing more mode-to-filetype mappings (maybe there exists some kind of "official" list for this?). You can find the current ones here (although the ess ones are currently incorrect since they have to be lowercase):

https://github.com/smjonas/snippet-converter.nvim/blob/e04de71d8183a876a6f1af4d330019d6b46a7c31/lua/snippet_converter/core/snipmate/yasnippet/parser.lua#L11-L14

IllustratedMan-code commented 1 year ago

Not an official list but emacs has a variable that keeps track of this! My emacs install is pretty comprehensive so this is probably most if not all of the cases:

(("\\(?:\\(?:\\.\\(?:b\\(?:\\(?:abel\\|ower\\)rc\\)\\|json\\(?:ld\\)?\\)\\|composer\\.lock\\)\\'\\)" . json-mode)
 ("Procfile\\'" . yaml-mode)
 ("templates/.+\\.php\\'" . web-mode)
 ("wp-content/themes/.+/.+\\.php\\'" . web-mode)
 ("\\.eco\\'" . web-mode)
 ("\\.jinja2?\\'" . web-mode)
 ("\\.twig\\'" . web-mode)
 ("\\.svelte\\'" . web-mode)
 ("\\.mustache\\'" . web-mode)
 ("\\.hbs\\'" . web-mode)
 ("\\.ejs\\'" . web-mode)
 ("\\.as[cp]x\\'" . web-mode)
 ("\\.jsp\\'" . web-mode)
 ("\\.[lh]?eex\\'" . web-mode)
 ("\\.erb\\'" . web-mode)
 ("\\.\\(?:tpl\\|blade\\)\\(?:\\.php\\)?\\'" . web-mode)
 ("\\.[px]?html?\\'" . web-mode)
 ("/bspwmrc\\'" . sh-mode)
 ("\\.\\(?:zunit\\|env\\)\\'" . sh-mode)
 ("\\.bats\\'" . sh-mode)
 ("\\.rs$" . rustic-mode)
 ("/Pipfile\\'" . conf-mode)
 ("[./]flake8\\'" . conf-mode)
 ("/flake\\.lock\\'" . json-mode)
 ("/README\\(?:\\.md\\)?\\'" . gfm-mode)
 ("\\.tex\\'" . LaTeX-mode)
 ("\\.tsx\\'" . typescript-tsx-mode)
 ("\\.pac\\'" . rjsx-mode)
 ("\\.es6\\'" . rjsx-mode)
 ("\\.[mc]?js\\'" . rjsx-mode)
 ("\\.js\\(?:on\\|[hl]int\\(?:rc\\)?\\)\\'" . json-mode)
 ("\\.jl\\'" . ess-julia-mode)
 ("\\.Cask\\'" . emacs-lisp-mode)
 ("\\.rss\\'" . nxml-mode)
 ("\\.xs\\(?:d\\|lt\\)\\'" . nxml-mode)
 ("\\.p\\(?:list\\|om\\)\\'" . nxml-mode)
 ("\\.h\\'" . +cc-c-c++-objc-mode)
 ("\\.mm\\'" . objc-mode)
 ("\\.pdf\\'" . pdf-view-mode)
 ("\\.\\(e?ya?\\|ra\\)ml\\'" . yaml-mode)
 ("\\.styl\\'" . stylus-mode)
 ("\\.sass\\'" . sass-mode)
 ("\\.slim\\'" . slim-mode)
 ("\\.\\(?:jade\\|pug\\)\\'" . pug-mode)
 ("\\.haml\\'" . haml-mode)
 ("\\.rs\\'" . rustic-mode)
 ("\\.rs\\'" . rust-mode)
 ("requirements\\.in" . pip-requirements-mode)
 ("requirements[^z-a]*\\.txt\\'" . pip-requirements-mode)
 ("\\.pip\\'" . pip-requirements-mode)
 ("\\.\\(plantuml\\|pum\\|plu\\)\\'" . plantuml-mode)
 ("\\.gp\\'" . gnuplot-mode)
 ("\\.gnuplot\\'" . gnuplot-mode)
 ("\\.nix\\'" . nix-mode)
 ("\\`/nix/store/.+\\.drv\\'" . nix-drv-mode)
 ("\\.lua\\'" . lua-mode)
 ("\\.hva\\'" . latex-mode)
 ("\\.ts\\'" . typescript-mode)
 ("\\.jsx\\'" . rjsx-mode)
 ("\\.hsc\\'" . haskell-mode)
 ("\\.l[gh]s\\'" . haskell-literate-mode)
 ("\\.hsig\\'" . haskell-mode)
 ("\\.[gh]s\\'" . haskell-mode)
 ("\\.cabal\\'\\|/cabal\\.project\\|/\\.cabal/config\\'" . haskell-cabal-mode)
 ("\\.chs\\'" . haskell-c2hs-mode)
 ("\\.ghci\\'" . ghci-script-mode)
 ("\\.dump-simpl\\'" . ghc-core-mode)
 ("\\.hcr\\'" . ghc-core-mode)
 ("go\\.mod\\'" . go-dot-mod-mode)
 ("\\.go\\'" . go-mode)
 ("\\.tres\\'" . conf-toml-mode)
 ("\\.tscn\\'" . conf-toml-mode)
 ("\\.gd\\'" . gdscript-mode)
 ("\\.cpp[rR]\\'" . poly-c++r-mode)
 ("\\.[Rr]cpp\\'" . poly-r+c++-mode)
 ("\\.[rR]brew\\'" . poly-brew+r-mode)
 ("\\.[rR]html\\'" . poly-html+r-mode)
 ("\\.rapport\\'" . poly-rapport-mode)
 ("\\.[rR]md\\'" . poly-markdown+r-mode)
 ("\\.[rR]nw\\'" . poly-noweb+r-mode)
 ("\\.Snw\\'" . poly-noweb+r-mode)
 ("\\.nw\\'" . poly-noweb-mode)
 ("\\.md\\'" . poly-markdown-mode)
 ("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
 ("\\.Sout\\'" . S-transcript-mode)
 ("\\.[Ss]t\\'" . S-transcript-mode)
 ("\\.Rd\\'" . Rd-mode)
 ("DESCRIPTION\\'" . conf-colon-mode)
 ("/Makevars\\(\\.win\\)?\\'" . makefile-mode)
 ("\\.[Rr]out\\'" . ess-r-transcript-mode)
 ("CITATION\\'" . ess-r-mode)
 ("NAMESPACE\\'" . ess-r-mode)
 ("\\.[rR]profile\\'" . ess-r-mode)
 ("\\.[rR]\\'" . ess-r-mode)
 ("/R/.*\\.q\\'" . ess-r-mode)
 ("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode)
 ("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode)
 ("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode)
 ("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode)
 ("\\.tsv\\'" . tsv-mode)
 ("\\.[Cc][Ss][Vv]\\'" . csv-mode)
 ("\\.glsl\\'" . glsl-mode)
 ("\\.geom\\'" . glsl-mode)
 ("\\.frag\\'" . glsl-mode)
 ("\\.vert\\'" . glsl-mode)
 ("\\.cuh\\'" . cuda-mode)
 ("\\.cu\\'" . cuda-mode)
 ("\\.cmake\\'" . cmake-mode)
 ("CMakeLists\\.txt\\'" . cmake-mode)
 ("\\.ipynb\\'" . ein:ipynb-mode)
 ("\\.envrc\\'" . envrc-file-mode)
 ("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)\\'" . markdown-mode)
 ("/git/ignore\\'" . gitignore-mode)
 ("/info/exclude\\'" . gitignore-mode)
 ("/\\.gitignore\\'" . gitignore-mode)
 ("/etc/gitconfig\\'" . gitconfig-mode)
 ("/\\.gitmodules\\'" . gitconfig-mode)
 ("/git/config\\'" . gitconfig-mode)
 ("/modules/.*/config\\'" . gitconfig-mode)
 ("/\\.git/config\\'" . gitconfig-mode)
 ("/\\.gitconfig\\'" . gitconfig-mode)
 ("/git/attributes\\'" . gitattributes-mode)
 ("/info/attributes\\'" . gitattributes-mode)
 ("/\\.gitattributes\\'" . gitattributes-mode)
 ("/git-rebase-todo\\'" . git-rebase-mode)
 ("\\nextflow.config\\'" . nextflow-mode)
 ("\\.nextflow\\'" . nextflow-mode)
 ("\\.nf\\'" . nextflow-mode)
 ("\\.\\(?:nf\\)?patterns\\'" . nextflow-mode)
 ("/Jenkinsfile\\'" . groovy-mode)
 ("\\.g\\(?:ant\\|roovy\\|radle\\)\\'" . groovy-mode)
 ("\\.scad$" . scad-mode)
 ("\\.mips\\'" . mips-mode)
 ("\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'" nil epa-file)
 ("\\.elc\\'" . elisp-byte-code-mode)
 ("\\.zst\\'" nil jka-compr)
 ("\\.dz\\'" nil jka-compr)
 ("\\.xz\\'" nil jka-compr)
 ("\\.lzma\\'" nil jka-compr)
 ("\\.lz\\'" nil jka-compr)
 ("\\.g?z\\'" nil jka-compr)
 ("\\.bz2\\'" nil jka-compr)
 ("\\.Z\\'" nil jka-compr)
 ("\\.vr[hi]?\\'" . vera-mode)
 ("\\(?:\\.\\(?:rbw?\\|ru\\|rake\\|thor\\|jbuilder\\|rabl\\|gemspec\\|podspec\\)\\|/\\(?:Gem\\|Rake\\|Cap\\|Thor\\|Puppet\\|Berks\\|Brew\\|Vagrant\\|Guard\\|Pod\\)file\\)\\'" . ruby-mode)
 ("\\.re?st\\'" . rst-mode)
 ("\\.py[iw]?\\'" . python-mode)
 ("\\.m\\'" . octave-maybe-mode)
 ("\\.less\\'" . less-css-mode)
 ("\\.scss\\'" . scss-mode)
 ("\\.awk\\'" . awk-mode)
 ("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode)
 ("\\.idl\\'" . idl-mode)
 ("\\.java\\'" . java-mode)
 ("\\.m\\'" . objc-mode)
 ("\\.ii\\'" . c++-mode)
 ("\\.i\\'" . c-mode)
 ("\\.lex\\'" . c-mode)
 ("\\.y\\(acc\\)?\\'" . c-mode)
 ("\\.h\\'" . c-or-c++-mode)
 ("\\.c\\'" . c-mode)
 ("\\.\\(CC?\\|HH?\\)\\'" . c++-mode)
 ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode)
 ("\\.\\(cc\\|hh\\)\\'" . c++-mode)
 ("\\.\\(bat\\|cmd\\)\\'" . bat-mode)
 ("\\.[sx]?html?\\(\\.[a-zA-Z_]+\\)?\\'" . mhtml-mode)
 ("\\.svgz?\\'" . image-mode)
 ("\\.svgz?\\'" . xml-mode)
 ("\\.x[bp]m\\'" . image-mode)
 ("\\.x[bp]m\\'" . c-mode)
 ("\\.p[bpgn]m\\'" . image-mode)
 ("\\.tiff?\\'" . image-mode)
 ("\\.gif\\'" . image-mode)
 ("\\.png\\'" . image-mode)
 ("\\.jpe?g\\'" . image-mode)
 ("\\.te?xt\\'" . text-mode)
 ("\\.[tT]e[xX]\\'" . tex-mode)
 ("\\.ins\\'" . tex-mode)
 ("\\.ltx\\'" . latex-mode)
 ("\\.dtx\\'" . doctex-mode)
 ("\\.org\\'" . org-mode)
 ("\\.dir-locals\\(?:-2\\)?\\.el\\'" . lisp-data-mode)
 ("eww-bookmarks\\'" . lisp-data-mode)
 ("tramp\\'" . lisp-data-mode)
 ("/archive-contents\\'" . lisp-data-mode)
 ("places\\'" . lisp-data-mode)
 ("\\.emacs-places\\'" . lisp-data-mode)
 ("\\.el\\'" . emacs-lisp-mode)
 ("Project\\.ede\\'" . emacs-lisp-mode)
 ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
 ("\\.l\\'" . lisp-mode)
 ("\\.li?sp\\'" . lisp-mode)
 ("\\.[fF]\\'" . fortran-mode)
 ("\\.for\\'" . fortran-mode)
 ("\\.p\\'" . pascal-mode)
 ("\\.pas\\'" . pascal-mode)
 ("\\.\\(dpr\\|DPR\\)\\'" . delphi-mode)
 ("\\.\\([pP]\\([Llm]\\|erl\\|od\\)\\|al\\)\\'" . perl-mode)
 ("Imakefile\\'" . makefile-imake-mode)
 ("Makeppfile\\(?:\\.mk\\)?\\'" . makefile-makepp-mode)
 ("\\.makepp\\'" . makefile-makepp-mode)
 ("\\.mk\\'" . makefile-gmake-mode)
 ("\\.make\\'" . makefile-gmake-mode)
 ("[Mm]akefile\\'" . makefile-gmake-mode)
 ("\\.am\\'" . makefile-automake-mode)
 ("\\.texinfo\\'" . texinfo-mode)
 ("\\.te?xi\\'" . texinfo-mode)
 ("\\.[sS]\\'" . asm-mode)
 ("\\.asm\\'" . asm-mode)
 ("\\.css\\'" . css-mode)
 ("\\.mixal\\'" . mixal-mode)
 ("\\.gcov\\'" . compilation-mode)
 ("/\\.[a-z0-9-]*gdbinit" . gdb-script-mode)
 ("-gdb\\.gdb" . gdb-script-mode)
 ("[cC]hange\\.?[lL]og?\\'" . change-log-mode)
 ("[cC]hange[lL]og[-.][0-9]+\\'" . change-log-mode)
 ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
 ("\\.scm\\.[0-9]*\\'" . scheme-mode)
 ("\\.[ckz]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
 ("\\.bash\\'" . sh-mode)
 ("/PKGBUILD\\'" . sh-mode)
 ("\\(/\\|\\`\\)\\.\\(bash_\\(profile\\|history\\|log\\(in\\|out\\)\\)\\|z?log\\(in\\|out\\)\\)\\'" . sh-mode)
 ("\\(/\\|\\`\\)\\.\\(shrc\\|zshrc\\|m?kshrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode)
 ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode)
 ("\\.m?spec\\'" . sh-mode)
 ("\\.m[mes]\\'" . nroff-mode)
 ("\\.man\\'" . nroff-mode)
 ("\\.sty\\'" . latex-mode)
 ("\\.cl[so]\\'" . latex-mode)
 ("\\.bbl\\'" . latex-mode)
 ("\\.bib\\'" . bibtex-mode)
 ("\\.bst\\'" . bibtex-style-mode)
 ("\\.sql\\'" . sql-mode)
 ("\\(acinclude\\|aclocal\\|acsite\\)\\.m4\\'" . autoconf-mode)
 ("\\.m[4c]\\'" . m4-mode)
 ("\\.mf\\'" . metafont-mode)
 ("\\.mp\\'" . metapost-mode)
 ("\\.vhdl?\\'" . vhdl-mode)
 ("\\.article\\'" . text-mode)
 ("\\.letter\\'" . text-mode)
 ("\\.i?tcl\\'" . tcl-mode)
 ("\\.exp\\'" . tcl-mode)
 ("\\.itk\\'" . tcl-mode)
 ("\\.icn\\'" . icon-mode)
 ("\\.sim\\'" . simula-mode)
 ("\\.mss\\'" . scribe-mode)
 ("\\.f9[05]\\'" . f90-mode)
 ("\\.f0[38]\\'" . f90-mode)
 ("\\.indent\\.pro\\'" . fundamental-mode)
 ("\\.\\(pro\\|PRO\\)\\'" . idlwave-mode)
 ("\\.srt\\'" . srecode-template-mode)
 ("\\.prolog\\'" . prolog-mode)
 ("\\.tar\\'" . tar-mode)
 ("\\.\\(arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|cbr\\|7z\\|squashfs\\|ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\|SQUASHFS\\)\\'" . archive-mode)
 ("\\.oxt\\'" . archive-mode)
 ("\\.\\(deb\\|[oi]pk\\)\\'" . archive-mode)
 ("\\`/tmp/Re" . text-mode)
 ("/Message[0-9]*\\'" . text-mode)
 ("\\`/tmp/fol/" . text-mode)
 ("\\.oak\\'" . scheme-mode)
 ("\\.sgml?\\'" . sgml-mode)
 ("\\.x[ms]l\\'" . xml-mode)
 ("\\.dbk\\'" . xml-mode)
 ("\\.dtd\\'" . sgml-mode)
 ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
 ("\\.js[mx]?\\'" . javascript-mode)
 ("\\.har\\'" . javascript-mode)
 ("\\.json\\'" . javascript-mode)
 ("\\.[ds]?va?h?\\'" . verilog-mode)
 ("\\.by\\'" . bovine-grammar-mode)
 ("\\.wy\\'" . wisent-grammar-mode)
 ("[:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode)
 ("\\`\\..*emacs\\'" . emacs-lisp-mode)
 ("[:/]_emacs\\'" . emacs-lisp-mode)
 ("/crontab\\.X*[0-9]+\\'" . shell-script-mode)
 ("\\.ml\\'" . lisp-mode)
 ("\\.ld[si]?\\'" . ld-script-mode)
 ("ld\\.?script\\'" . ld-script-mode)
 ("\\.xs\\'" . c-mode)
 ("\\.x[abdsru]?[cnw]?\\'" . ld-script-mode)
 ("\\.zone\\'" . dns-mode)
 ("\\.soa\\'" . dns-mode)
 ("\\.asd\\'" . lisp-mode)
 ("\\.\\(asn\\|mib\\|smi\\)\\'" . snmp-mode)
 ("\\.\\(as\\|mi\\|sm\\)2\\'" . snmpv2-mode)
 ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode)
 ("\\.\\(dif\\|pat\\)\\'" . diff-mode)
 ("\\.[eE]?[pP][sS]\\'" . ps-mode)
 ("\\.\\(?:PDF\\|DVI\\|OD[FGPST]\\|DOCX\\|XLSX?\\|PPTX?\\|pdf\\|djvu\\|dvi\\|od[fgpst]\\|docx\\|xlsx?\\|pptx?\\)\\'" . doc-view-mode-maybe)
 ("configure\\.\\(ac\\|in\\)\\'" . autoconf-mode)
 ("\\.s\\(v\\|iv\\|ieve\\)\\'" . sieve-mode)
 ("BROWSE\\'" . ebrowse-tree-mode)
 ("\\.ebrowse\\'" . ebrowse-tree-mode)
 ("#\\*mail\\*" . mail-mode)
 ("\\.g\\'" . antlr-mode)
 ("\\.mod\\'" . m2-mode)
 ("\\.ses\\'" . ses-mode)
 ("\\.docbook\\'" . sgml-mode)
 ("\\.com\\'" . dcl-mode)
 ("/config\\.\\(?:bat\\|log\\)\\'" . fundamental-mode)
 ("/\\.\\(authinfo\\|netrc\\)\\'" . authinfo-mode)
 ("\\.\\(?:[iI][nN][iI]\\|[lL][sS][tT]\\|[rR][eE][gG]\\|[sS][yY][sS]\\)\\'" . conf-mode)
 ("\\.la\\'" . conf-unix-mode)
 ("\\.ppd\\'" . conf-ppd-mode)
 ("java.+\\.conf\\'" . conf-javaprop-mode)
 ("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-javaprop-mode)
 ("\\.toml\\'" . conf-toml-mode)
 ("\\.desktop\\'" . conf-desktop-mode)
 ("/\\.redshift\\.conf\\'" . conf-windows-mode)
 ("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\(?:\\.d/.+\\)?\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
 ("\\`/etc/\\(?:acpid?/.+\\|aliases\\(?:\\.d/.+\\)?\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\|sysconfig/.+\\)\\'" . conf-mode)
 ("[cC]hange[lL]og[-.][-0-9a-z]+\\'" . change-log-mode)
 ("/\\.?\\(?:gitconfig\\|gnokiirc\\|hgrc\\|kde.*rc\\|mime\\.types\\|wgetrc\\)\\'" . conf-mode)
 ("/\\.\\(?:asound\\|enigma\\|fetchmail\\|gltron\\|gtk\\|hxplayer\\|mairix\\|mbsync\\|msmtp\\|net\\|neverball\\|nvidia-settings-\\|offlineimap\\|qt/.+\\|realplayer\\|reportbug\\|rtorrent\\.\\|screen\\|scummvm\\|sversion\\|sylpheed/.+\\|xmp\\)rc\\'" . conf-mode)
 ("/\\.\\(?:gdbtkinit\\|grip\\|mpdconf\\|notmuch-config\\|orbital/.+txt\\|rhosts\\|tuxracer/options\\)\\'" . conf-mode)
 ("/\\.?X\\(?:default\\|resource\\|re\\)s\\>" . conf-xdefaults-mode)
 ("/X11.+app-defaults/\\|\\.ad\\'" . conf-xdefaults-mode)
 ("/X11.+locale/.+/Compose\\'" . conf-colon-mode)
 ("/X11.+locale/compose\\.dir\\'" . conf-javaprop-mode)
 ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t)
 ("\\.\\(?:orig\\|in\\|[bB][aA][kK]\\)\\'" nil t)
 ("[/.]c\\(?:on\\)?f\\(?:i?g\\)?\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-mode-maybe)
 ("\\.[1-9]\\'" . nroff-mode)
 ("\\.art\\'" . image-mode)
 ("\\.avs\\'" . image-mode)
 ("\\.bmp\\'" . image-mode)
 ("\\.cmyk\\'" . image-mode)
 ("\\.cmyka\\'" . image-mode)
 ("\\.crw\\'" . image-mode)
 ("\\.dcr\\'" . image-mode)
 ("\\.dcx\\'" . image-mode)
 ("\\.dng\\'" . image-mode)
 ("\\.dpx\\'" . image-mode)
 ("\\.fax\\'" . image-mode)
 ("\\.hrz\\'" . image-mode)
 ("\\.icb\\'" . image-mode)
 ("\\.icc\\'" . image-mode)
 ("\\.icm\\'" . image-mode)
 ("\\.ico\\'" . image-mode)
 ("\\.icon\\'" . image-mode)
 ("\\.jbg\\'" . image-mode)
 ("\\.jbig\\'" . image-mode)
 ("\\.jng\\'" . image-mode)
 ("\\.jnx\\'" . image-mode)
 ("\\.miff\\'" . image-mode)
 ("\\.mng\\'" . image-mode)
 ("\\.mvg\\'" . image-mode)
 ("\\.otb\\'" . image-mode)
 ("\\.p7\\'" . image-mode)
 ("\\.pcx\\'" . image-mode)
 ("\\.pdb\\'" . image-mode)
 ("\\.pfa\\'" . image-mode)
 ("\\.pfb\\'" . image-mode)
 ("\\.picon\\'" . image-mode)
 ("\\.pict\\'" . image-mode)
 ("\\.rgb\\'" . image-mode)
 ("\\.rgba\\'" . image-mode)
 ("\\.tga\\'" . image-mode)
 ("\\.wbmp\\'" . image-mode)
 ("\\.webp\\'" . image-mode)
 ("\\.wmf\\'" . image-mode)
 ("\\.wpg\\'" . image-mode)
 ("\\.xcf\\'" . image-mode)
 ("\\.xmp\\'" . image-mode)
 ("\\.xwd\\'" . image-mode)
 ("\\.yuv\\'" . image-mode)
 ("\\.tgz\\'" . tar-mode)
 ("\\.tbz2?\\'" . tar-mode)
 ("\\.txz\\'" . tar-mode)
 ("\\.tzst\\'" . tar-mode)
 ("\\.drv\\'" . latex-mode)
 ("/LICENSE\\'" . text-mode)
 ("\\.log\\'" . text-mode)
 ("rc\\'" . conf-mode)
 ("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode)
 ("\\.vue\\'" . web-mode))

I'll get around to making a pull request soon.

IllustratedMan-code commented 1 year ago

Vim has something similar in filetype.vim I might see if I can match them by their regex.

smjonas commented 1 year ago

Just a note because you mentioned filetype.vim: you don't need to do something like mapping .mmes to nroff-mode (Nvim already detects .mmes files as nroff using filetype.lua).

smjonas commented 1 year ago

Hey @IllustratedMan-code, I have decided to merge this feature in its current state. I'll wait for your (or the community's) contribution to add more mode -> filetype mappings.