zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.95k stars 1.17k forks source link

[feature request] linter plugin matches the file name when using `domatch` #3156

Closed taconi closed 4 weeks ago

taconi commented 7 months ago

The default linter plugin has the domatch option:

should the filetype be interpreted as a lua pattern to match with the actual filetype ...

However, the default is based on the file type.

For example, if I wanted to create a lua pattern for files that end with .nelua I wouldn't be able to do so because there is no syntax for files with that extension and its buf:FileType() will be unknown. In this scenario, the match would be ('unknown'):match(v.filetype).

The suggestion would be to change the match to pattern lua to use regex using the regexp.MatchString function. And that this match is already made in the name of the complete file.

I believe that the change in the code would be the import of the regex local regex = import(regex) and it is on line 118:

if v.domatch then
  ftmatch = regex.MatchString(v.filetype, buf.AbsPath)
end