mvbasic
mvbasic copied to clipboard
[FEATURE] Auto-detect and set BASIC language
Other languages rely on a file extension to determine the language. With BASIC we have no such common conventions. Examples:
- foo.java
- bar.cs
- baz.php
This is a proposal to auto-detect BASIC code.
There are two ways that I know of which can be used.
First, when the workspace includes a recognized file, it can trigger the activation of an extension. So if we include a file like ".mvbasic", this extension would activate, and we could default to opening all files in this workspace with BASIC language handling.
Second, whenever a file/document is opened in a VSCode TextEditor object, an event is fired. We can hook that event and use a function to determine if the file is a BASIC program. Avoiding random scans for words like COMMON, CRT, PRINT, READ, GOSUB, etc, I propose we standardize on using a comment as a definitive marker. So for example if the text * MVBASIC
is found anywhere in the document, then we can assume it's a BASIC program.
The first option is the simplest and requires almost no effort from the user/developer. However it does clutter the workspace with an extra file, which may not be desirable for some.
The second option is best for one-off programs that get loaded, outside the context of an entire workspace. So if you drag/drop a program from anywhere, or load via FTP, etc, it will be recognized. This is also helpful if coding is coming from two different environments - language processing should be specific to the document currently active - the text inside a document should override the workspace spec.
Because both of these options have merit, I think both should be implemented.
Further, it would help to have an automated way to select the MVBASIC dialect for a code module. Again, this can be done at the workspace level, looking for files named .uvbasic, .qmbasic, .d3basic, etc. And for in-program cues: * UVBASIC
... * QMBASIC
etc.
If this is approved, unless someone else wants to tackle it, I think I can handle it.
If this functionality is already included. OOPS! Sorry! :face_with_head_bandage: :laughing: