Git Extensions GUI: set source code language for "colorization"? - plugins

I'm working with a repository of MATLAB code in git (company internal repo) using the "GitExtensions" app. The displayed code in the "FileTree" window is colorized more or less as though it were c-language code. Is there any way to specify other languages, similar to how Notepad++ does?

Related

How to change the diff tool used by VSCode for git?

I would like to use the difftastic diff tool, which ignores whitespace changes in code (amongst other useful functionalities), and I have set my .gitconfig to use difft (the binary file of difftastic) as my preferred external diff tool using this command:
git config --global diff.external difft
And, my .gitconfig has these lines in it:
[diff]
external = difft
However, the VSCode text editor still shows whitespace diffs. I have searched for a way to change the diff tool in VSCode to no avail, the only results are "How to set VSCode as the default merge/diff tool for git".
To clarify, I would like to change the diff tool used by the vscode text editor section as well as the diff viewer. I do not want to change the tool used by the commandline git command itself. In the image I've linked, it shows changes for whitespace, which should not be happening if difft is set as the diff tool.
You can change the tool Git uses to "diff" two files: https://git-scm.com/docs/git-difftool (this is Git functionality - it has nothing directly to do with VSCode).
You can substitute a custom editor for the built-in the Visual Studio code editor: https://code.visualstudio.com/api/extension-guides/custom-editors.
You can add a custom "diff" plugin to Visual Studio, for example, "Partial Diff": https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff.
What you CANNOT do is swap in a custom app to change the "diff" functionality of the default VSCode editor.
Visual Studio Code does not use an external utility to compute the diff. The necessary algorithms are directly implemented in VS Code and you don't have any control over them.
Using an arbitrary external utility would most likely not result in a good user experience either. If VS Code cannot understand the generated diff, it would not be able to display the output with the diff editor and you would lose features like syntax highlighting.
However, I may have an alternative solution to your original problem (using difftastic in VS Code). I am currently working on my own extension that adds a semantic diff mode to VS Code. It supports fewer languages than difftastic, but has additional features like moved code detection:
If that is what you are looking for, you can find the extension (SemanticDiff) in the Visual Studio Code Marketplace.

Disable competing language servers / code highlighters

I want to add a language server to handle completion / highlighting / etc. for a file.
As a basis for testing stuff I am using an example from Microsoft (https://github.com/microsoft/vscode-extension-samples/tree/main/lsp-sample) and changed it to be active for any File. This language server highlights any word in all capital letters.
When opening a C++ File, I get the highlighting / completion of my language server and the default one for C++ (See image).
I would like to detect if some other extension / build in highlighter is active for a file and deactivate it for this workspace or the current file if it is impossible for the current workspace)
Is there a way to do this in a generic way where I do not have to know which extensions are highlighting code?
If no, is there a way to do this, if I know a set of extensions I want to deactivate?
I finally had enough time to try around a bit more and found that providing your own language for the same extension is enough.
In package.json I added an element in contributes.languages with extensions containing .cpp (since I am using cpp files for testing).
I also copied over some implementation code from an example.
This suppressed the default highlighter and code completion for cpp files. Since i am only implementing a semantic token provider, I can see the default highlighting before my provider takes over. (I think this could be solved by adding a syntax highlighter, but this is already sufficient fo my preliminary testing)
I am not sure, how stable all of this would be as a plugin (I only tested in Extension Development Host mode)
Here an image of the results:

VCS for Jupyter Notebooks in PyCharm

I'm wondering how to make PyCharm's VCS (i.e. Git) work with Jupyter Notebook files.
Changing even 1 loc results in 3 modifications detected during commit:
Sorry if it's a duplicate, but I haven't found anything similar.
Well, I wouldn't say that the current support of Jupyter Notebook files versioning doesn't work at all. You can see it on your own screenshot that your changes are detected.
We don't parse all of the changes to detect only the source code changes.
And even if we did, many people actually want to track the output because, for example, in data science, the results are not always reproducible and you may want to keep track of the output as well as src.
Although it can be enhanced with the implementation of the following functionality https://youtrack.jetbrains.com/issue/PY-20132 that would allow committing all of the changes, but see only changes of source code, so feel free to upvote and leave comments.
I use Pycharm Community edition. I love the way Pycharm integrates with git and its VCS shows the diffs visually. However, for jupyter notebook files, the diff is difficult to track visually. Running a cell introduces various changes.
Notebook files normally diff like text files. I use a simple method to enhance the visual quality. I created a new file type Settings>Editor>File Types for *.ipynb files. I enable matching for all types of brackets. I add few keywords,
Keyword 1:
"outputs"
"source"
Keyword 2:
"code"
"markdown"
This highlighted format shows up in the Pycharm VCS and enables us to easily locate changes in code and markdown cells and outputs. An example of this effect is shown in this screenshot. Now, we don't need to worry about changes in the execution count or meta data.

How to merge files(differentiate) in visual studio code

I am using Visual studio code for angular2 application. The requirement is to merge files, so, I want to differentiate changes in two files as it happens in Netbeans IDE. Is there, any extensions available to achieve the task in visual studio code.
For e.g - Merging Two files by differentiating changes like below:-
Please suggest some solution.
abc.component.ts (located in project1)
abc <-- text for understanding purpose
def
abc.component.ts ( located in project2)
abc
I want to differentiate two component files and push changes in another like it happens in Netbeans IDE? Is there, any solution available for Visual studio code?
First using vscode natively with the git toolset
(Make sure to look on the second title as it's a better native way!)
This way may be available on older version of vscode too! Still a good thing to know! (even we should always run on the latest version! And vscode is always keeping getting better and better).
A native powerful and cool way is to use the git toolset within vscode! It still not the most fluid way! But if you are in a setup where you don't have anything else or time or resources to use anything else! Also as a requirement you need to have a git repo initiated! Here we go:
First we will use the change and diffing capability of the git tool set. And the steps go as bellow:
Commit all the current changes
once done: copy past the other file to diff on the place of the current one. And save.
Cool now in the git pallet you can see the file in changes list! Click on it and the diffing editor will show!
Bingo this is it! You can compare and make direct changment! The diffing will keep happening in real time. Note the current state is in the right. And you make changement there.
Here an illustration of direct modification for instance the part in the left is missing from the current file
And here another illustration (current have in plus)
Well to sum up! Git tool and diffing in vscode is so powerful! And all that one need! The only problem is the extra step of committing and cleaning after if desired!
Here some tips! If you want to have the commit history cleaner! Or not have a merge separate! You can remove the last commits from history as much as you need: Without hard reset and commit again a cleaner one!
git reset --soft HEAD~1
You can check
How to cancel a local git commit
Otherwise it can be ok with atomic commit and merge mention!
Also if what you need is to be able to keep a lot from the current file! You can copy the current elsewhere! past the other file to compare! commit ! and then past again the old one! You'll have the old in the right and as current (Not as described on the above) In such a scenario this work well! (Hacky a bit but you may need it).
Native way (direct open of the compare editor)
(May require the newer version of vscode)
open a file that you gonna compare
open the command pallet
CTRL + SHIFT + P
type file: compare
You can see the different possible ways! For a file we can choose compare active file with.
Then you choose the file! The file need to be within the project directory.
And then you choose a file and the compare editor will open
The above was tested on my brother computer on a new vscode installation. I wasn't sure at first if it was part of the core! And i just confirmed that it is. That too remove the need to the method above involving git! And it's the best native way to go with.
Vscode extensions
Here two extensions i suggest the first:
https://marketplace.visualstudio.com/items?itemName=jinsihou.diff-tool
Easy and simple! It add two elements to the right click menu:
In current file right click -> Select as first file for diff, select one again to view the diff results
select to compare and compare with select no more simple then that !
Another extension to check:
https://marketplace.visualstudio.com/items?itemName=fabiospampinato.vscode-diff
I prefer the first! As this one compare a lot to the native way. And having the control in the contextual menu is just great.
Out of vscode! Using other tools
A quick google search and you'll find a lot of tools!
https://meldmerge.org/
meld merge is cross platform and open source and nice!
in linux and debian:
sudo apt install meld
Otherwise you can check the long list here:
https://www.jotform.com/blog/25-useful-document-and-file-comparison-tools/
https://stackify.com/code-merge-tools/
There is too winMerge to mention (an open source project for windows)
https://winmerge.org/

Search Tool: Generate URL from Source File + Line (Visual Studio)

I'll took some time to find a tool (without success) that helps to easily switch from Visual Studio editor to the web frontend of our (git) code repository.
The idea in mind is: In a (chat) discussion about some coding sometime its useful to refer to a line of code. Currently one/I am writing e.g.
see repo_path/Dragable.cpp:29
... or bit better/easier/faster to follow is sending the link to our repo web frontend e.g.
see http://192.168.2.50:7990/projects/GST/repos/gst/browse/src/Client/ClientGUI/Dragable.cpp#29
In my case the is a atlassian-stash based URL because we are using atlassian-stash as git repo / web frontend. But I think this problem is valid for nearly any code repo with a web frontend e.g. github
(same example but github)
https://github.com/google/protobuf/blob/master/src/google/protobuf/arenastring.h#L88
Now the question:
Typically I am browsing through the code while discussing things using my favorite IDE (this is in our team typically visual studio). I am searching for a tool that allows to generate a URL (like above) from the current cursor position (where a relative path from the current source file + the line is placed into an URL stub).
I still did not find an adequate tool (or plugin) that has this functionality in it (maybe as side functionality). Before starting building a custom VS Extension, I would like to ask if maybe somebody else was faced to the same issue, solved it already with an existing tool or can suggest a tool/workflow for this?