Vagrant up when opening project in PhpStorm - ide

Is there a way to automatically run vagrant up when I open up a project in PhpStorm?
(and may a vagrant halt when closing the project)
I tried to add a task, what actually only runs external programms or tools. My thought was to call a shell-script. But I would prefer to keep this all in PhpStorm and seeking for a possibility to handle all this inside of PhpStorm.

In PHPStorm :
CTRL + SHIFT + A.
Startup Tasks.
in the bottom left corner click on + icon.
Add configuration.
Add shell script.
now you can either enter the content of the command in that case 'vagrant up' or create a .sh file and put the path of it in the path section.
now each time you'll open PHPStorm on this project, your VM will boot up.

Related

Configuring Groovy SDK within IntelliJ IDEA

I am running IntelliJ IDEA 2017.2.3. I installed Groovy 2.4.12 via Homebrew (OS X). When I open a Groovy source file (or a Jenkinsfile), I get the following:
Groovy SDK is not configured for module 'my-module' . . . . . Configure Groovy SDK...
Clicking "Configure Groovy SDK..." leads me to the following dialog:
I tried hitting "Create..." and selecting many different Groovy-related folders and executables, but nothing works.
How can I get IntelliJ IDEA to accept my Groovy SDK?
IntelliJ IDEA expects the standard Groovy SDK layout which is provided with the official distributions available at https://groovy.apache.org/download.html. Just download, unpack into any directory, specify this directory as the library home.
Homebrew package layout may be different, however it may have the standard layout in the libexec subdirectory in some cases. Try /usr/local/opt/groovy/libexec (use Cmd + Shift + G to navigate to it).
Another suggestion to add to this solution here described in MAC OS you can also add symbolic link in Library. This will make it easy to select it within IntelliJ:
sudo ln -s /usr/local/opt/groovy/libexec /Library/Groovy
This first answer it excellent, but not sufficient. The hidden folder in Mac blocked me one more day.
On Mac system, you can press
Cmd + Shift + G
to invoke the input dialog and input "/usr/local/opt/groovy/libexec" directly to resolve the issue that you cannot find the lib folder.
CrazyCoder gave the correct hints. But some of us use brew as our standard.
brew install groovysdk
In intellij when you get the dialog, as stated by haltTim, Cmd + Shift + G
Navigate to /usr/local/opt/groovysdk/libexec or the cellar path /usr/local/Cellar/groovysdk/???/libexec
From the main menu select File | Project Structure ⌘;.
In the Project Structure dialog, under Platform Settings, select
Global Libraries.
Image depicting the Intellij environment
Select Global Libraries, if nothing is there, click on add(+) icon at the top.
Then a small dialog box will appear, Select "from Maven", then another dialog box as shown below appears, iamge showing dialog box
Type in Groovy, then several options will pop up, select an option which has groovy:groovy-all and version 2.4.1(change version according to your need) and click ok. then apply and ok,
After this go to the same dialog box, of Configure SDK and select from drop-down.

How to automatically synchronize/refresh SCSS/CSS file on change?

Recently my client switched from Eclipse to Intellij. In both IDEs I was editing SCSS files externally and running "compass watch" in terminal. This worked great in Eclipse. immediately after compiling SCSS file I was able to simply refresh browser and see the changes.
In Intellij it takes up to 30 seconds to see the changes, or if I enable "synchronize files on frame activation" I have to switch to browser first, then back to Intellij, and then back again to browser in order to force refresh. Third option is to manually sync "css" folder, which is not convenient. I had a same issue when I was editing and compiling SCSS files in Intellij.
How can I force Intellij to detect CSS file change faster?
I've found the solution.
Open "Settings / File Watchers" and go to SCSS. Make sure that field "Output paths to refresh" has the same value for the output as "Arguments" field.
For example, this is my setup:
Arguments:
--no-cache --update $FileName$:$FileParentDir$\css\$FileNameWithoutExtension$.css
Output paths to refresh:
$FileParentDir$\css\$FileNameWithoutExtension$.css

Autoreload file system changes in phpstorm/webstorm/intellij

Ahoi
I have an project with grunt, and whenever I save a file it runs the csscomb script in the grunt:watch task. My old "IDE" Sublime reloaded the changes automatically, phpStorm doesn't do that. I always have to manually synch the file.
The whole problem is that I write code, save in between and continue programming, and then the popup about the file system changes appears.
LG
Do you run grunt:watch outside of webStorm, or using Grunt console? In the latter case, the file system should be synchronized when task is completed. But if the task is run externally, outside of webstorm, you have to synchronize files manually
I know this is old stuff, but I had the same problem with WebStorm - i.e grunt running externally on a network server.
I just unchecked "use safe-write ..." in Settings > Appearance & Behaviour > System Settings and now my WS writes saves directly to the file triggering watch grunt tasks.
Try Preferences -> Appearance & Behavior -> System Settings -> Synchronize files on frame activation. PHPStorm will automatically reload file system changes once you switch to its window.

How to configure custom PYTHONPATH with VM and PyCharm?

I am using IntelliJ with the Python plugin and the Remote Interpreter feature to communicate with my Vagrant VM. It sets up the remote interpreter correctly to use my VM's interpreter. But, I use a custom PYTHONPATH in my VM, and I would like IntelliJ to recognize that path and include the modules in that path when developing.
How do I configure IntelliJ/PyCharm's remote interpreter to use a custom PYTHONPATH on the VM?
For PyCharm 5 (or 2016.1), you can:
select Preferences > Project Interpreter
to the right of interpreter selector there is a "..." button, click it
select "more..."
pop up a new "Project Interpreters" window
select the rightest button (named "show paths for the selected interpreter")
pop up a "Interpreter Paths" window
click the "+" buttom > select your desired PYTHONPATH directory (the folder which contains python modules) and click OK
Done! Enjoy it!
Instructions for editing your PYTHONPATH or fixing import resolution problems for code inspection are as follows:
Open Preferences (On a Mac the keyboard short cut is ⌘,).
Look for Project Structure in the sidebar on the left under Project: Your Project Name
Add or remove modules on the right sidebar
EDIT: I have updated this screen shot for PyCharm 4.5
To me the solution was to go to
Run > Edit Configuration > Defaults > Python
then manage the
"Add content roots to PYTHONPATH" and
"Add source root to PYTHONPATH"
checkboxes, as well as setting the "Working directory" field.
If you have set up your own Run/Debug Configurations then you might want to go to
Run > Edit Configuration > Python > [Whatever you called your config]
and edit it there.
My problem was that I wanted to have my whole repository included in my PyCharm 2016.2 project, but only a subfolder was the actual python source code root. I added it as "Source Root" by right clicking the folder then
Mark directory as > Source Root
Then unchecking "Add content roots to PYTHONPATH" and checking "Add source root to PYTHONPATH" in the Run/Debug config menu. I then checked the folder pathing by doing:
import sys
logger.info(sys.path)
This outputed:
[
'/usr/local/my_project_root/my_sources_root',
'/usr/local/my_project_root/my_sources_root',
'/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages'
]
However, without the fix it said:
[
'/usr/local/my_project_root/my_sources_root',
'/usr/local/my_project_root', <-- NOT WANTED
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages'
]
Which meant I got the project root folder included. This messed up the pathing for me.
This was done with PyCharm Community 2019.1
Go to Project Settings
Go to Project Structure and right click on the directory you want to add and click "Sources"
This should add the directory to your pythonpath
An update to the correct answer phil provided, for more recent versions of Pycharm (e.g. 2019.2).
Go to File > Settings and find your project, then select Project Interpreter. Now click the button with a cog to the right of the selected project interpreter (used to be a ...).
From the drop-down menu select Show All... and in the dialog that opens click the icon with a folder and two sub-folders.
You are presented with a dialog with the current interpreter paths, click on + to add one more.
In my experience, using a PYTHONPATH variable at all is usually the wrong approach, because it does not play nicely with VENV on windows. PYTHON on loading will prepare the path by prepending PYTHONPATH to the path, which can result in your carefully prepared Venv preferentially fetching global site packages.
Instead of using PYTHON path, include a pythonpath.pth file in the relevant site-packages directory (although beware custom pythons occasionally look for them in different locations, e.g. enthought looks in the same directory as python.exe for its .pth files) with each virtual environment. This will act like a PYTHONPATH only it will be specific to the python installation, so you can have a separate one for each python installation/environment. Pycharm integrates strongly with VENV if you just go to yse the VENV's python as your python installation.
See e.g. this SO question for more details on .pth files....
Latest 12/2019 selections for PYTHONPATH for a given interpreter.
Well you can do this by going to the interpreter's dialogue box. Click on the interpreter that you are using, and underneath it, you should see two tabs, one called Packages, and the other called Path.
Click on Path, and add your VM path to it.
In pycharm 5 follow this,
https://www.jetbrains.com/pycharm/help/configuring-python-interpreter-for-a-project.html
1)Open the Settings dialog box, and click Project Interpreter page.
2)In the Projects pane, choose the desired project.
3)For the selected project, choose SDK from the list of available Python interpreters and virtual environments.
In Intellij v2017.2 you can go to:
run > edit configurations > click ... next to the field 'Environment variables' > click the green + sign
Name= PYTHONPATH
value= your_python_path
Pycharm 2020.3.3 CE ZorinOS(Linux) File>Settings > Project Structure > {select the folder} > Mark as Source(blue folder icon) > Apply
To verify:
import sys
print(sys.path)
Selected path should be listed here.

How to run Luke(Lucene tool)?

I had downloaded 'Lukeall-3.5.0' on http://code.google.com/p/luke/downloads/list It's a JAR file , but i don't know how let it work? Can somebody show me the detailed steps to run Luke? Thank you!
You can run eg. from command line issuing java -jar lukeall-3.5.0.jar command
If you want the .jar to run on double click then you have to make an association between .jar files and the program that needs to open them, javaw.exe. You can do this manually by following the steps below, or see this site for an automatic tool called Jarfix.
Right click the .jar and go to "Properties"
Click "Change"
Click "Browse..."
Navigate to your Java install folder
In the "bin" folder you should see "javaw"
Select "javaw" and click "Open"
Click "OK"
Click "Apply"
Tried everything including jarfix , javaW commandline but was not running.
Then I downloaded the jar from this link https://code.google.com/archive/p/luke/downloads. there are many .jar and .tgz file. I tried the latest one with "type-executable" label on it. And once it was downloaded somehow the extension got changed to .zip.
1) changed the extension back to .jar
2) right click open with -> Java(this was installed before)
Bingo! Luke opened up!
At first, you need to download and install Java Runtime to your PC.
Then open command prompt: press Windows Key + R, type cmd in the textbox and hit Ok.
Change directory to your jar file locating folder (using cd command), type java -jar .\yourFileName.jar and hit enter.
Hope this will work.