martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.19k stars 260 forks source link

Missing mail.lua lexer #1190

Closed brettwhiteinc closed 1 month ago

brettwhiteinc commented 1 month ago

Problem

When trying to edit a .eml file I receive the following warning:

...38lmki87333kxbqnr40vgy6p2a82-vis-0.9/share/vis/lexer.lua:1522: no file '$HOME/.config:/nix/store/n32h38lmki87333kxbqnr40vgy6p2a82-vis-0.9/share/vis/lexers/mail.lua'
no file '$HOME/.config:/nix/store/n32h38lmki87333kxbqnr40vgy6p2a82-vis-0.9/share/vis/mail/init.lua/mail.lua'
no file '/Users/xxx/.config/vis/lexers/mail.lua'
no file '/Users/xxx/.config/vis/mail/init.lua/mail.lua'
no file '/etc/vis/lexers/mail.lua'
no file '/etc/vis/mail/init.lua/mail.lua'
no file '/nix/store/n32h38lmki87333kxbqnr40vgy6p2a82-vis-0.9/share/vis/lexers/mail.lua'
no file '/nix/store/n32h38lmki87333kxbqnr40vgy6p2a82-vis-0.9/share/vis/mail/init.lua/mail.lua'
no file '/nix/store/j1xjh7fpixc2bk5yy7clj1hzwy2asi7l-lua-5.2.4-env/share/lua/5.2/lexers/mail.lua'
no file '/mail.lua'

This appears to be due to the fact that filetype.lua has an entry for "mail", but there is no mail.lua under the lexers directory. I feel like the long-term fix is to add a mail.lua, but I've modified my own copy by simply removing mail from filetype.lua.

Steps to reproduce

vis test.eml

vis version (vis -v)

vis 0.9 +curses +lua +tre

Terminal name/version

macOS Terminal.app v2.14 (default for Sonoma 14.4.1)

$TERM environment variable

xterm-256color

mcepl commented 1 month ago

On Mon May 6, 2024 at 4:48 PM CEST, brettwhiteinc wrote:

This appears to be due to the fact that filetype.lua has an entry for "mail", but there is no mail.lua under the lexers directory. I feel like the long-term fix is to add a mail.lua, but I've modified my own copy by simply removing mail from filetype.lua.

I don’t think that either of these is a good solution. Given we are taking lexers from upstream and so we are not in full control of what’s available, and given that we want to be able to extend the list of filetypes detected by vis, we should really make it possible for vis to fail softly when the lexer for the specific filetype is not available (something like a message on the status bar should be sufficient).

Best,

Matěj

-- http://matej.ceplovi.cz/blog/, @@.*** GPG Finger: 3C76 A027 CA45 AD70 98B5 BC1D 7920 5802 880B C9D8

Of all tyrannies, a tyranny exercised for the good of its victims may be the most oppressive. It may be better to live under robber barons than under omnipotent moral busybodies. The robber baron’s cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end, for they do so with the approval of their consciences. -- C. S. Lewis

rnpnr commented 1 month ago

vis to fail softly when the lexer for the specific filetype is not available

Yes, it was already supposed to do that. b6ae2fb corrected that behavior.

mcepl commented 1 month ago

Hey all,

My bad if the To header for this mail isn't what it should be, I'm not that experienced with mailing lists.

[...], we should really make it possible for vis to fail softly when the lexer for the specific filetype is not available (something like a message on the status bar should be sufficient).

I'd like to not even have a warning on the status line. There are a few plugins, like vis-lspc and vis-format that rely on the syntax field in win to run the correct language server or formatter respectively. vis-filetype-settings will also benefit, and there might be more.

Personally I think having the detected filetype available without any warnings even when there is no lexer available benefits these plugins by allowing them to use the existing filetype detection. For example, I have a stub hcl.lua lexer for Terraform files. This enables me to run the required tools automatically. I'd like to be able to share this configuration (and others) as a default in vis-format and vis-lspc without having to write a lexer.

— Michiel

rnpnr commented 1 month ago

Yes, the intended behaviour was to fail silently. The check was broken but should be fixed now. Any commands that were supposed to be run for the filetype will be run in either case.

mcepl commented 1 month ago

On Wed May 8, 2024 at 3:49 PM CEST, Michiel van den Heuvel wrote:

My bad if the To header for this mail isn't what it should be, I'm not that experienced with mailing lists.

Reply-to-all is probably best ATM, I just wanted to have this discussion archived outside of the Microsoft’s domain.

[...], we should really make it possible for vis to fail softly when the lexer for the specific filetype is not available (something like a message on the status bar should be sufficient).

I'd like to not even have a warning on the status line. There are a few plugins, like vis-lspc and vis-format that rely on the syntax field in win to run the correct language server or formatter respectively. vis-filetype-settings will also benefit, and there might be more.

Personally I think having the detected filetype available without any warnings even when there is no lexer available benefits these plugins by allowing them to use the existing filetype detection. For example, I have a stub hcl.lua lexer for Terraform files. This enables me to run the required tools automatically. I'd like to be able to share this configuration (and others) as a default in vis-format and vis-lspc without having to write a lexer.

I said intentionally “should be sufficient” … that was meant as the upper limit of what I could accept as a good idea. If you think, it is too much, just go ahead.

-- http://matej.ceplovi.cz/blog/, @@.*** GPG Finger: 3C76 A027 CA45 AD70 98B5 BC1D 7920 5802 880B C9D8

Las cosas claras y el chocolate espeso. (Ideas should be clear and chocolate thick.) -- Spanish proverb