PhpStorm synchronise settings company wide - intellij-idea

I'm currently try to establish company wide coding standards and different setting which should be the same on every developers setup.
There are multiple way to achive this and the current aproach to sync some of the .idea-folders files via version control doesn't seems to be as easy as expected.
We also tried to use the 'Settings Repository' plugin which ended up in confusion.
Has anyone tried solve a similar problem? Does anyone use the plugin successful in a bigger team?
Would be happy to get some of your thoughts on this.
Best regards

With the recent release of PhpStorm 2017.2 it's now possible to apply code style from ESLint.
https://www.jetbrains.com/phpstorm/whatsnew/
Import from ESLint
You can now import some ESLint code style rules to the IDE’s
JavaScript code style settings. Reply ‘Yes’ when prompted about this
in the .eslintrc file to apply the matched rules and make the IDE
formatting more consistent with your ESLint configuration.
That's still not completely automatic, but maybe better than having the .idea folders in the repo.

Admin in your company setups personal Settings Repository (Upsteam).
Configures code styles schemes.
Developer in your company adds this repository as "read-only source" (https://www.jetbrains.com/help/idea/settings-repository.html)
Currently, sometimes read-only source changes are not synced automatically, in this case please use VCS -> Sync Settings -> Merge.

Related

IntelliJ different project settings based on used IDE

I have a Git repo with two directories:
backend (PHP/Laravel code)
frontend (TypeScript/Vue code)
I would like that backend is marked as excluded when the project is opened in WebStorm and frontend to be excluded when it is opened in PhpStorm.
This is to ensure that searches/indexing only happen for the files that I would actually edit in that specific IDE.
When I change the excluded directory it seems to automatically apply this to the other IDE as well. Is there some way to keep this setting separate?
Comments:
I intentionally have both frontend and backend in one repository.
Opening the subdirectories in their own IDEA projects does not seem
to be an option because the Git integration only works when the
project is in the root folder of the repository.
When I change the excluded directory it seems to automatically apply this to the other IDE as well.
It is expected. That's because the project settings are stored in the .idea subfolder. All IDEA-based IDEs use the same .idea settings format. So opening the same folder/project in different IDEs simply makes them use that already-made config (shared between IDEs).
Plus, both PhpStorm and WebStorm use the same module type ID (WEB_MODULE) and can have only 1 module in total in a project. IntelliJ IDEA and some other IDEs (like PyCharm for example) can work with projects that can have more than one module and of different types.
Is there some way to keep this setting separate?
Yes, with the help of a small workaround: you need to store .idea used by another IDE in another place. As simple as that.
The setup and steps:
Lets assume that you have your project in C:\Projects\MyProject.
Make a brand new empty project in another place, e.g. C:\Projects\IDEProjectsStore\MyProject-frontend. It will be used for a frontend.
Go to Settings/Preferences | Directories and remove an existing Content Root (which will be C:\Projects\IDEProjectsStore\MyProject-frontend from the previous step).
Add new Content Root instead -- point to the actual project (C:\Projects\MyProject from step #1)
Save and configure as needed.
What you will have now:
This frontend project will now have its settings stored in C:\Projects\IDEProjectsStore\MyProject-frontend\.idea while another (original project with backend) will have them in C:\Projects\MyProject\.idea.
Projects (project-specific IDE settings) are stored in 2 separate places while they both use the same folder with the code.
Basically: a project in the IDE's eyes is an .idea folder with a parent folder added as a Content Root by default. Our workaround keeps the second project in a different folder while sharing the same Content Root between them.
https://youtrack.jetbrains.com/issue/IDEA-170102/ -- that's a ticket that asks for a straightforward way of doing this.
I would like that backend is marked as excluded when the project is opened in WebStorm and frontend to be excluded when it is opened in PhpStorm.
Why do you need two IDEs for this?
In case if you do not know: PhpStorm = WebStorm + PHP + Database. You do not really need WebStorm here. Just install any missing plugins that come bundled with WebStorm.

How to share just part of the IntelliJ settings repository?

I'm testing out the Setting Repository feature, but we only want to share certain settings. Specifically, codestyles and inspections. Near as I can tell so far in playing with it, you have to share everything or nothing.
But everyone has their own keymaps and color scheme, we don't want to share those bits.
Is there a way to configure this IntelliJ feature to share just selected portions of the settings?
You can create a scheme for your project by selecting "Project" in the Code Style configuration:
When doing that, a "Project" code style file will be generated in your project tree:
You can add this file to your VCS, like Git. And everyone working with you will be able have the same settings for Code Style.

Intellij Annotate Option Grayed Out

I am trying to look at who changed a line in Intellij 15. I know I can use git blame but I want to learn how to do it correctly in intellij. I am right clicking on the line numbers on the file but when I get the context menu the annotate option is grayed out. What setting am I missing?
I looked at this page and couldn't find an answer. What am I missing?
If you check File > Settings > Version Control and see that your current project is listed under "Unregistered Roots", go to (on the menubar) VCS > Enable Version Control Integration. It will ask you to select the VCS tool you use, then click ok and you'll have all the integrations working (including the annotate feature which uses git blame).
The answer by #activedecay let me in the right direction. In my case, I have a multi-module project - each has a separate git repo - but we're all in the same workspace.
In my case, Intellij IDEA 2017.2, the Preferences -> Version Control (update from 2022: or Preferences > Version Control > Directory Mappings) panel shows a listing of all the project roots. The module with the disabled "Annotate" option was in the "Unregistered Roots" section.
To fix the problem, I selected the module and pressed the "+" icon in the lower toolbar to register the module root with Intellij VCS. The change is immediate and the "Annotate" options becomes available.
Looks like its a fresh project. First configure the Version Control like Git and than commit at least once. After first commit Annotate option will not be grayed out.
Also update git for any new version.
Your VCS is not enabled, hence the issue. Below is the solution for that:
Click on the VCS option in the menu bar
Enable VCS
Select your version control
Done, you should be able to use the annotate option.
Make sure the file is tracked by version control
Add the project to "Version Control" settings
I had the same issue with the Annotate being greyed out however VCS was already set up. Editing the current VCS Directory Mapping fixed the issue for me.
Go to
Settings -> Version Control
Click on the current entry for your
your application listed under projects.
Click the pen icon to edit it
Hit Ok, then ok to close the main dialog
Under the version control setting, make sure to remove any unregistered roots, I had a similar issue where there was a Unregistered roots entry was found, after removing this unwanted entry, I was able to annotate on file.
I the following two screen short will solve your problem:
1.
I hope after those steps you will be able to see who changed a line.
Here are the steps i followed :
Go to VCS -> Checkout from Version Control -> Git -> give the URL for your repository.
The annotate option will be enabled now.
I had exactly the same issue and managed to solve it by updating git.
The reason for that is that I have recent InteliJ Idea and an old 2.1.x git installed.
For Mac:
brew upgrade git
brew link git
followed by IDE restart.
Perhaps you did not check Git Integration while setting up a fresh installation of IntelliJ. It happened to me when I updated to a major release. When I was setting up the new program, I might have unchecked the Git Integration on the wizard installation.
In order to solve this for IntelliJ Community 2019.1, access File > Settings > Plugins, go to the tab Installed and make sure the plugin Git Integration is checked. You should restart the IDE in order to make the Annotate action work.
I had the same issue, but my VCS settings were all configured properly. It turns out that git itself was considering the file as a brand new file and therefore didn't have any history for it. The file was actually not new, but simply renamed. While my rename changes were unstaged, git understood it as two separate files: a deletion of the old file and creation of a new file. However, once I git added the "deleted" file and the "new" file, git understood that it was actually a rename and IntelliJ was able to annotate on the file as expected.
I'm not sure why git didn't understand the rename when it was unstaged, but hopefully this helps someone!

How can I stop indexing intellij idea?

Without "excluding" folders, how can I stop Indexing intellij idea on start? It's very very annoying that it starts indexing on startup without allowing you to, for example, debug a test case making you wait until indexing has finished.
You can stop synchronizing/indexing each time you switch to the IDEA and it's quite useful when dealing with big projects and outside build process which triggers indexing.
Just disable checkbox System Settings -> Synchronize files on frame or editor tab activation.
Make sure you run indexing manually to update hints when needed through Synchronize menu (Cmd-Alt-Y on Mac) or File -> Reload All from Disk to run it manually for IDEA 2020 running under Linux
Try:
File-> Invalidate Caches / Restart.
I think that this issue happens (at least for me it seems to be the reason) if you start commit and then close the IDE in the middle of the process.
Now, "excluding" folders is the only way to disable indexing when a change occurs in one of excluded folders (except for generated sources that mustn't be excluded).
Checked with Intellij 2016.2.5
I suggest you to tune your Intellij configuration, see this post : https://stackoverflow.com/a/22508853/779338
You Can easily resolve it.
Just Go to: File -> Setting -> Directories.
Stop all the files that are going to included and need to empty ADD Content Root.
Like This:
It may be because of libraries folder is added more than one sub folder in the project. example in my case i have node_modules folder in two locations in the project. one is under root directory(app-->node_modeules) another one is under(app-->test-->node_modules)
Simply Right click on each folder and then selected Mark Directory As --> Excluded
It resolved my problem. Hope it would be helpful.
After struggling with this issue for around a week and searching all the solution I came to below conclusion:
either upgrade your intellij which gives you feature to pause the indexing ( I can't upgrade my intellij due to license issues ) so the other option was to disable all the plugins and then try enabling as per the need one by one.
After enabling any of the plugin if you see it behaving the same uninstall the plugin and download some alternative of it.
If longer indexing is an issue you can enable the shared indexes.
Add this plugin in your intellij and follow the instructions from here.
In my case i had constantly indexing files in Angular application when i remove node_modules folder.
I've tried to invalidate caches multiple times what didn't help at all.
Only solution was to remove project with clear Git state and reclone project - than everything started to work just flawlessly.

How to share Code Style settings between developers in IntelliJ

I would like all developers on my team to use the same default code style settings. We all use IntelliJ 11+ as our IDE and we use git as our source control system.
What is the easiest way to make sure they're all using the same settings? I thought there would be a way to check in the style settings into the project and have their editors discover them automatically, but that doesn't seem to be the case.
PS. I don't mind if developers consciously override some of the default settings with their own preferences, but I do want to make sure that we all at least start from a common set of default settings.
Code Style can be copied to project and saved in .idea/codeStyles to be shared via version control:
Copy to Project Click this button to create a copy of the current global scheme to the project level. After creating the copy, IntelliJ
IDEA suggests to switch to this new scheme at the project level.
The Settings Repository feature was introduced at IntelliJ IDEA 2016.
This option helps us to share IDE settings between different computers, including sharing settings between developers.
The settings are stored at Git repository, for example on GitHub or Bitbucket.
To setup Git repository we should set URL via Settings Repository menu option.
The developer can load remote settings, overwrite remote settings or merge local settings with remote ones.
The structure of Git repository with settings:
I used personal access token for GitHub authentication.
More information:
Settings Repository
Creating a personal access token for the command line
I came across this long after the fact, but thought I'd share if anyone ran into this. Add the following to your .gitignore
# IDE - IntelliJ
/.idea/*
# Keep the code styles.
!/.idea/codeStyles
/.idea/codeStyles/*
!/.idea/codeStyles/Project.xml
!/.idea/codeStyles/codeStyleConfig.xml
# Keep the inspection levels
!/.idea/inspectionProfiles
/.idea/inspectionProfiles/*
!/.idea/inspectionProfiles/Project_Default.xml
And of course, make sure your .gitignore also has a ! in front of it so these changes get picked up.
Basically, gitignore's recursive looking is a little wonky, so the below ignores a directory's contents, except for a subdirectory, then ignores that subdirectory's contents, except for the files we want.
codeStyleConfig lets you use per project settings, the project file itself is your actual code styles, and I included the Project_Default as it holds the warning levels, which you likely want if you're doing the code style work anyways.
You can create .editorconfig file in Your project (and it can be managed on directory level). More info on https://www.jetbrains.com/help/idea/configuring-code-style.html#editorconfig and https://editorconfig.org/
With this approach You can keep all Your code style settings in one file and it's not limited to IJ only.