microsoft / vscode-makefile-tools

MAKE integration in Visual Studio Code
Other
195 stars 60 forks source link

Add formatter for Makefile #388

Open nicola-lunghi opened 1 year ago

nicola-lunghi commented 1 year ago

see title

bobbrow commented 1 year ago

Thank you for the feature idea.

0dminnimda commented 1 year ago

Any updates?

andreeis commented 1 year ago

@0dminnimda , we did not have a chance to get to this request but after we release 0.7 we will try to look at all "Language Service" work items, triage and cost them. There is demand from the community. In the mean time, @0dminnimda and @nicola-lunghi, if you'd like, you could describe more about what you'd like to see with this makefile formatter. Is this only spacing/tabbing related?

0dminnimda commented 1 year ago

Is this only spacing/tabbing related?

I could add that it would be also nice to see formatting for macros, like

ifeq ($(QUEUE), vector)
    $(info INFO: using vector implementation of queue (QUEUE=$(QUEUE)))
    override CFLAGS += -D QUEUE_IMPL=\'V\'
else
    $(info INFO: using list implementation of queue (QUEUE=$(QUEUE)))
endif
trumanpurnell commented 11 months ago

Pleaseeeee

gcampbell-msft commented 10 months ago

@nicola-lunghi @0dminnimda @trumanpurnell

Circling back to this, because I wanted to get more context on the request for a formatter. What would you expect a formatter to do for a Makefile?

Since the syntax for a Makefile is actually somewhat rather free form (as long as it adheres to a certain set of rules), there isn't a great way to control the formatting many of the rules, though it is possible for some things, like if statements, etc. (For context, I was doing some initial investigation and came upon this post that has some similar questions and thoughts).

Any feedback would be great!

0dminnimda commented 10 months ago

The biggest pain point would be to make sure all the indentations are tabs since makefile can throw not very intuitive error messages if the format is not correct. Indentation on if statments and that's probably it. ALso the question you mentioned seems to be good example.

glass-ships commented 2 months ago

+1 for this FR!

nicola-lunghi commented 1 month ago

Hi sorry @gcampbell-msft I missed the reply

At the moment I would like something simple that removed double lines, remove spaces at the end of the line, format comment with a space before the '#' and maybe checks for tabs/spaces/double tabs???

Thank you

NAICOLAS commented 1 month ago

Also, ensure that PHONY has a dot (.) before and a colon (:) after. Simple things I guess.