vim-polyglot icon indicating copy to clipboard operation
vim-polyglot copied to clipboard

Write heuristics for all ambiguous extensions

Open sheerun opened this issue 5 years ago • 6 comments

If someone would like to help this project you can try to write filetype detection heuristics for some extensions that are ambiguous. The process is to download project, run "make dev", write tests for given extension in tests/extensions.vim and then write actual heuristics in heuristics.yaml. Here's list of ambuguous extensions and packages that use them:

  • [ ] No heuristics for .inc extension (c/c++, html5, php)
  • [ ] No heuristics for .em extension (emberscript, emblem)
  • [ ] No heuristics for .es extension (erlang, javascript)
  • [ ] No heuristics for .frag extension (glsl, javascript)
  • [ ] No heuristics for .gs extension (glsl, javascript)
  • [ ] No heuristics for .comp extension (glsl, perl)
  • [ ] No heuristics for .mod extension (gmpl, xml)
  • [ ] No heuristics for .p extension (gnuplot, tptp)
  • [ ] No heuristics for .workflow extension (hcl, xml)
  • [ ] No heuristics for .fcgi extension (lua, perl, php, python, ruby, sh)
  • [ ] No heuristics for .cgi extension (perl, python, sh)
  • [x] No heuristics for .ps1xml extension (powershell, xml)
  • [ ] No heuristics for .spec extension (python, ruby)
  • [ ] No heuristics for .pro extension (qmake, dosini, prolog)
  • [ ] No heuristics for .pluginspec extension (ruby, xml)
  • [ ] No heuristics for .zir extension (zig, zig)

Please send one PR per extension!

sheerun avatar Sep 29 '20 17:09 sheerun

Why are .frag files considered a JS sources? I personally don't know of a JS library or runtime which uses .frag extensions, though this extension is much, much more common for GLSL fragment shaders.

dmitmel avatar Oct 17 '20 21:10 dmitmel

Okay, so Github's linguist program also lists the .frag extension as a a possible extension for JS sources (introduced in commit github/linguist@a148d52aed82b966f00a034e167a5eff94b11382), but to be honest the samples for this extension they include (intro.js.frag, outro.js.frag) are pretty strange to say the least. Perhaps they use meant "fragment of a file", but I dunno, it doesn't mean JS specifically and can be applied to any kind of file. Again, I personally have never seen usage of this extension in the context of JS. .js.frag can be used for JS sources instead to disambiguate, while .frag is left for GLSL shaders.

dmitmel avatar Oct 17 '20 21:10 dmitmel

Could you send PR to linguist that removes this extension?

sheerun avatar Oct 18 '20 10:10 sheerun

Is this plugin generated from linguist's languages.yml?

dmitmel avatar Oct 18 '20 10:10 dmitmel

among others, yes

sheerun avatar Oct 18 '20 11:10 sheerun

Could you send PR to linguist that removes this extension?

After a year I have finally opened a PR (github/linguist#5645), but they say they don't remove extensions, only add heuristics. In any case, this can be worked around by putting something like this into, say, ~/.vim/ftdetect/customizations.vim:

autocmd BufNewFile,BufRead *.frag setf glsl

dmitmel avatar Nov 14 '21 14:11 dmitmel