zyedidia / micro

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

Change the linter match to a regex in the file name when "domatch=true" #3159

Open taconi opened 4 months ago

taconi commented 4 months ago

Previously, the match was done with a lua pattern in the file type. The change is for the pattern to be a regular expression that will match the full file path.

This way, linters can be added to files that do not have a type defined in the micro editor and allow the user to use regular expressions.

Example of a linter for files ending with .rb:

function init()
  linter.makeLinter(
    'rubocop',                      -- name
    '\\.rb$',  -- filetype
    'rubocop',                      -- cmd
    { '--format', 'emacs', '%f' },  -- args
    '%f:%l:%c: C: %m',              -- errorformat
    {},                             -- os
    false,                          -- whitelist
    true       -- domatch: filetype will be a regex pattern that will match the file path.
  )
end

closes #3156