VS Code Extension - Best approach for extending JSON - visual-studio-code

I'm looking into what would be the best option to extend VS code with an extension which add some more features to the JSON Format such as additional keyword highlighting.
What would be the best approach ?
Taking over the tmlanguage file for JSON and add additional options for eg syntax highlighting connected to a new language ?
"Extending" the JSON fomat ?
Custom linter ?
This looks my best bet I could find till now: Can a language in Visual Studio Code be extended?
Tnx in advance for giving advice what would be the best approach.

It depends on what features do you want and how much time you would like to spend on it.
If the syntax highlighting is the main purpose, just get a tmLanguage file for the programming language and use the official generator yocode to create an extension from it.
Visual Studio Code and Microsoft behind it are promoting the Language Server Protocol which may be the ultimate solution. And of course, it requires much more work.

Related

How do I get visual studio code to run a programming language that I created?

I'm trying to get the visual studio code IDE to support a programming language that I created using python. I want vscode to have basic language and intellisense support for my language. Also, I would like the program to use the .csap file extension. Less importantly, I am interested in making a debugger extension.
Its a very simple programming language with print statements, loops, input, conditions, and some of my own built-in functions.
It is very similar to python. I have it working in my terminal right now.
What are the most important ideas for me to know about to make these extensions? What are the best resources and tutorials on the subject?
If you believe this post is to broad, please advise me on how to make it more specific.
You need the entire ecosystem for your new language, so I see at least 2, maybe 3 kind of extensions, and could look these resources:
Syntax Highlight:
https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide
https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide
Intellisense like features:
https://code.visualstudio.com/api/language-extensions/programmatic-language-features
https://code.visualstudio.com/api/language-extensions/language-server-extension-guide
Debugger
https://code.visualstudio.com/api/extension-guides/debugger-extension
This repo (https://github.com/microsoft/vscode-extension-samples) contains a lot of samples, and is a great source of information.
Hope this helps

Code analysis using visual studio extension

Is it possible to write an extension which will do code analysis? I looked at the api and I didnt see how I can get all variables that are declared in the document/xref on specific variable and get it flow in the code. If someone know api in visual studio code which actually helps with it, it will be great.
Creating such an extension is certainly possible, however you have to do your own language processing. AFAIK there's no way to access the internal structures (syntax tree, symbol table etc.) of the existing JS/TS (or other language for that matter) extensions.

VS Code formatting plugins

Is there a way in VS Code to format code according to the style that a person prefers? I guess there might be a plugin for this sort of thing but I've not found that.
For example, I prefer 'K&R' coding style while a colleague prefers 'Whitesmiths' style. When we share code or functions it would be nice to autoformat code into the style that each prefers.
This does not seem like it should be so difficult for a plugin to do except that coding style also has to parse the language of the code, so Whitesmiths PowerShell is going to be different from Whitesmiths on Perl I would imagine.
Are there any plugins like this (or internal functionality in VS Code - it's a very comprehensive tool without installing any plugins of course!) that people use regularly like this?
In contrast to its name, "JIndent" (commercial) is a tool I've been using for the exact purpose you're asking about.

Delete a specific Intellisense suggestion in VS Code

Intellisense sometimes comes up with irrelevant suggestions that I will never use in my project. Those can get in the way of the valuable other suggestions.
They also prevent VS Code features like "Add all missing imports" from working.
For example:
The first DocumentType is a low-level module that I will never use.
The second is one that I need in most of my files.
So how can I get rid of the first one?
Related (obsolete and unanswered) questions:
VS Code intellisense remove some suggestions
Disable specific autocomplete suggestion in Visual Studio 2013
You cannot disable specific IntelliSense completion options, however, there are a few other relevant caveats.
Answer to not your question: You can filter whole classes of keywords with the editor setting editor.suggest.filteredTypes. See more about this here.
IntelliSense does not allow you to configure or filter specific keywords. The list of all IntelliSense options is here. It also appears this is impossible with other major options. For example, the language server protocol does not support this(GitHub thread abt this). That being said, there is a plethora of autocomplete extensions and I'm certain this feature exists for some.
Something like intellicode might also be an answer, as it will look through other files you've edited to try to learn your practices.
If you're 100% sold on IntelliSense, and you're willing to sink several hours into this, you could set up a discrete language server, and then use something like this to filter completions as they are sent to the editor. While this would work, I think it's a terrible idea.
After spending several hours with no satisfying result, I created my own IntelliSense snippets. I used another keyword to make sure, it will show on top.
I used the Easy Snippet plugin for this.

Is there a VSCode equivalent to Notepad++'s user defined language configuration?

I really enjoyed defining syntax highlighting rules in Notepad++ for the various build logs and artifacts I've worked on in the past to make certain text markers pop out. I was wondering if VSCode has any capabilities to do likewise.
For reference to the unfamiliar here's the Notepad++ documentation and a live demonstration:
https://npp-user-manual.org/docs/user-defined-language-system/
How to Create Custom Language Definitions in Notepad++
Looks like there is support for something in this direction. The terminology is slightly different though and there may not be a GUI interface like Notedpad++
Declarative Language Feature
Syntax Highlight Guide: VS Code uses TextMate grammar for syntax highlighting. This guide will walk you through writing a simple TextMate grammar and converting it into a VS Code extension.
Create Custom Language in Visual Studio Code
https://code.visualstudio.com/api/language-extensions/overview#declarative-language-features
https://code.visualstudio.com/api/language-extensions/language-configuration-guide