martanne / vis

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

lua: get lua to recognize bashrc file #896

Closed 80aff123-9163-4f3e-a93d-4a2f35af9be1 closed 3 years ago

ninewise commented 3 years ago

Wouldn't you want to leave off the %? IIRC that's for the rest of the filename, but there should not be anything there in this case.

80aff123-9163-4f3e-a93d-4a2f35af9be1 commented 3 years ago

@ninewise

Thank you for catching that! I edited the last commit and pushed to this branch in order to update. It should reflect what you suggested.

Let me know if there are any other issues with this PR.

all the best.

ghost commented 3 years ago

@ccao001 The correct Lua pattern for that is "^%.bashrc$". The percent sign is an escape character in Lua patterns - https://www.lua.org/manual/5.3/manual.html#6.4.1

erf commented 3 years ago

Need the escape char "%", but not the "start-of-line" char "^" i think, as you'd only want the end of the line.

ninewise commented 3 years ago

Oh, excuse me, seems I mixed up all those grammars again.

ghost commented 3 years ago

The ^ is needed, as .bashrc is the whole name, hence the pattern needs to be anchored on both ends.

The code is a bit misleading, using ext as key. It is up to each pattern whether to match the extension or the whole name. There are a few other filetypes that match the whole name as well - Dockerfile, crontab, PKGBUILD, etc.

martanne commented 3 years ago

@lepotic is right about the correct pattern to use.

But more fundamentally, I don't really want to add a listing of all possible shell related files. Why don't we add entries for .bash_profile, .bash_logout, ... ? And this is only for bash, what about all other shells (currently we use the same lexer for all)?

If you really want this, then patch it locally or tweak your file(1) configuration to recognize it properly.