gojimmypi / GcodeLanguageExtension

Visual Studio g-code syntax highlighter for CNC and 3DPrinters
MIT License
2 stars 1 forks source link

Ability to customise the registered file type extensions #2

Open DavidHopkinsFbr opened 5 years ago

DavidHopkinsFbr commented 5 years ago

Hi! Thanks for making this extension.

In the system I work with, the G-code files have the extension .nc, rather than .gcode, so the extension isn't activating for our G-code files. Wikipedia also mentions that other systems which use G-code use the extensions .mpt or .mpf.

Is it possible to reconfigure the current version of the VS extension to register itself for different file extensions? Or would code changes be needed?

Would it be difficult to add something to the Visual Studio Options dialogue to configure the registered file types?

gojimmypi commented 5 years ago

Hi @DavidHopkinsFbr! I'm glad someone is actually using this extension :)

I've added support to highlight syntax for .nc, .mpt, mpf files in addition to .gcode. Please see version 0.1.4 that should be now available on the marketplace.

If you are interested, I have code for another project that not only highlights code, but also has hover text to actually indicate what the respective keyword means. For me as a newbie to g-code, I would find this tremendously helpful and educational.

Perhaps if you could provide a list of all the g-codes - ideally in plain text, comma-delimited format, and their respective meanings, I could add this feature as well to this extension? (feel free to open a new issue for this).

As for your questions: Yes - any sort of "register itself" for different file extensions would definitely require a code change.

Regarding the option for a dialogue to configure... well, everything is easy when you know how ;) I'm not sure how this would work.

For both of those questions, the file extension is configured as a decorator, specifically here. I'm not sure how to programmatically alter this at runtime.

DavidHopkinsFbr commented 5 years ago

Thanks for the response!

I've opened another ticket with some links to reference material for understanding the G-code instructions.

If I get some free time I might do some research on how to add options to a VS extension.

DavidHopkinsFbr commented 5 years ago

I've installed 0.1.4 but .nc files are still uncolored for me.

gojimmypi commented 5 years ago

Hello @DavidHopkinsFbr - What version of Visual Studio are you using? Are .code files still highlighted for you? I noticed that VS2015 does not offer me an update to 0.1.4 - however VS2019 and VS2017 both appear to work with that version for me with all 4 of the sample files. Here are my versions:

Microsoft Visual Studio Enterprise 2019
Version 16.1.6
VisualStudio.16.Release/16.1.6+29102.190
Microsoft .NET Framework
Version 4.8.03752

and

Microsoft Visual Studio Enterprise 2017 
Version 15.9.11
VisualStudio.15.Release/15.9.11+28307.586
Microsoft .NET Framework
Version 4.8.03752

Here's my G-Code Extension Version: image

And a .nc file: image

Are any errors reported for you when opening .nc files? Have you tried my sample files? I'm wondering if perhaps there's a different encoding or something. Perhaps you could send me a sample that is not working?

thanks for the info in https://github.com/gojimmypi/GcodeLanguageExtension/issues/4 - I think it would be cool to have hover text.

DavidHopkinsFbr commented 5 years ago

I'm using VS2015, unfortunately. No obvious errors are being reported. I installed 0.1.4 through the Extensions and Updates dialogue box in VS2015. There's no highlighting being applied to any of the four test files. The extension works fine in VS2017 for me.

Incidentally, the colouring rule for the axis values is a bit clashy when using a light editor theme. (I mostly use light themes because my monitor is so glossy it basically turns into a mirror when using dark themes!)

gojimmypi commented 5 years ago

I spent some time looking at why VS2015 might not be happy, but I've not been able to yet determine a cause. I've opened a new issue https://github.com/gojimmypi/GcodeLanguageExtension/issues/5 for this.

gojimmypi commented 5 years ago

@DavidHopkinsFbr - regarding the light/dark editor color theme: I do have "if dark theme use this color, else use this color" feature in my Verilog Highlighter - if you'd like to define your preferred colors, I'd be happy to provide the code infrastructure for this? I added issue https://github.com/gojimmypi/GcodeLanguageExtension/issues/6