Support whitespace before target name for make completions #858
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR: The "simple" example from https://www.gnu.org/software/make/manual/html_node/Simple-Makefile.html is currently not compatible with the custom completion script found in
custom-completions/make/make-completions.nu
. This PR tries to fix that.As I was working on
nur
(https://github.com/ddanier/nur) and thenurify
script to convert tonur
from different task runners (https://github.com/ddanier/nur/blob/main/scripts/nurify.nu) I wanted to create a good way to convert from usingmake
. So I thought themake
completion would for sure implement a good way to get a list of all possiblemake
targets. Hence I started looking atcustom-completions/make/make-completions.nu
.Then I searched for a good documentation for how
Makefile
s work, as the last time I was using this myself is about 5 to 10 years ago. If you for example look at the documentation on gnu.org you may find examples ofMakefile
s not working with the current autocompletion. See https://www.gnu.org/software/make/manual/html_node/Simple-Makefile.html for example, the "simple" example they provide.The reason for this not working is that the targets use some whitespace after the target name. This is somehow allowed and thus valid. See https://www.gnu.org/software/make/manual/html_node/Rule-Introduction.html for a quick overview about how the
Makefile
s syntax works. I quickly checked this to ensuremake
actually parses this correctly, it really does.This means that the current
make
completion does miss support for the "simple" example provided mymake
itself. So I went on to fix this.My suggested solution is:
'^[\w\.-]+\s*:'
to ensure possible targets.
and-
)For me this did fix the issue with the "simple"
Makefile
, allowing me to put this into mynurify
script.Would be nice to get this "backported" to nu scripts as well. Might help others 😉