I have Intellij ultimate version 14.1.4. How do I enable optimizing imports automatically with each save for "Go"? In Settings->Editor->General->Auto Imports, I see options for Java/python/scala but not for Go. I have the Go plugin installed already. But this unused import compile error is a noise. I want to enable automatic optimizing of imports to avoid CTRL+ALT+O combination
This functionality is not yet available for the Go plugin, that's why you don't see any options there / it doesn't work automatically.
You might want to watch this issue or maybe this PR to get notified when they will be fixed.
Meanwhile, you can use the Code -> Goimports file functionality and maybe assign it a shortcut of your own preference as it doesn't have one by default. For this to work you will need to have goimports installed and in your system's PATH.
Related
I am an Eclipse/STS user/developer, now trying to use IntelliJ Idea (CE)
2020.2.(1,2,3)
For a project based on Gradle, how spring-integration, when I open the IDE it happens the following
Ok, let the IDE load the project ... but
From above, that is the problem, I don't want that the IDE starts automatically to build/rebuild the project. I just need, open the project and that's all.
Observation: for example in Eclipse/STS exists the option to disable Build Automatically
I did do a research in the Web and I read the following posts and questions:
How to disable automatic gradle builds?
IntelliJ IDEA “Build project automatically” apparently not working
Intellij IDEA Java classes not auto compiling on save
Sadly the dialog options were changed but ...
Therefore:
From above, seems nothing to do.
Observation: from above observe the Build project automatically option is disabled
Even with that disabled and after to restart the IDE, I must always stop manually the build process
So what is missing? or Do I need a special extra plugin to accomplish my goal?
The images that you show indicate that you are building with Gradle, but the Compiler option that you disable is relevant for building projects with Idea not with Gradle.
For the 2020.2 version, you need to do the following:
Open the Setting > Build Tools page.
Disable the "Reload changes in build scripts" option.
This way you can manually control the reload. When you change the build script, you will see a small gradle icon in the right side of the editor.
For more info, refer to the IntelliJ IDEA help > Gradle section.
https://www.jetbrains.com/help/idea/work-with-gradle-projects.html#auto_reload
There are two different things in IntelliJ's Gradle support that sometimes confused: sync and build. Your pictures demonstrate sync process (note caption on the toolwindow). Word build is kind of misleading here.
What is sync? In gradle we use Groovy to define the build procedure. Groovy is an imperative programming language, so it's hard to predict resulting dependencies graph without actually executing the script. During the sync Idea executes configuration phase of gradle build (one that builds dependency graph), and obtains configured objects from the Gradle daemon. This information is used to setup project in the IDE: modules, libraries, dependencies, which sources are test, which are prod, etc.
Actual build is not happening during sync. You can convince yourself by adding syntax error to any source file, and observe that the sync succeeds. But build will fail if you invoke it.
In answer to the original question: you can't disable automatic build, because it is not enabled.
Is it possible to disable sync in Gradle project? Short answer - no. If you need a code browser, which is not required to understand all the cross-references in the source code, IDEA is not the best choice probably.
TL;DR;
Without sync IDE does not know which files are sources, and which are not. IDEA cannot open folders. It only can open projects. Good thing is that module can contain folder. So you can do the following: File | New | Project. Select Empty project, Next, select some random folder outside the source folder you want to open, Finish.
Then add new module:
Select Java in the left panel, everything else keep default, Next, Finish. Then in new module remove existing content root, and add folder with sources as new content root
Resulting project is mostly useless. Tons of red code (at least, unresolved symbols from external libraries), no inspections, no navigation, no sense. But it might be useful in some rare situations indeed.
Is there any way to fix ONLY unused imports in Rust automatically? I have seen cargo fix, which does work, but it makes a whole bunch of other fixes too. Is there any way to tell cargo fix to only fix unused imports (preferably in a specified file) and nothing else?
Side question: Is there any way to make IntelliJ do this? The usual shortcut (Cmd+Option+O) works in other languages, but for Rust, it just re-orders the imports.
According to this pull request, JetBrains' Rust plugin should be able to remove unused imports already but it is not enabled by default. According to this comment, it seems like the dev team need to wait until org.rust.macros.proc (currently an experimental feature disabled by default) to be enabled by default.
Individual lints are currently only configurable via attributes in your source code. There is no way to tell cargo check or cargo fix to ignore certain lint rules through the command line tool.
From my experience with JetBrains tools, it's unlikely that they'd use cargo fix under the hood anyway. They have built their own Rust tooling for parsing and analysing code, and that is where this feature would go.
I suggest submitting a feature request to JetBrains.
Enable Settings > Editor > Inspections > Rust > Lints > Unused Import.
Disable Enable inspection only if procedural macros are enabled in the same section.
Versions
IntelliJ IDEA Build #IU-223.7571.182
Rust Plugin 0.4.185.5086-223
For our project we use EcmaScript 6 through Babel, Gulp and npm.
We have three projects: Base, Common and Game.
We're actively developing Common and Game so we have those checked out (and npm link from Game to Common), while we get the Base project through npm and don't change it often.
The import paths we use start with the project name such as import "Base/utils/svg" or import "Game/model/boardtile". The map according to the following on the file system:
Base → /intellij-project/base-project-src/node_modules/base/
Common → /intellij-project/base-project-src/js/
Game → /intellij-project/game-project-src/js/
The problem: IntelliJ does not understand this import scheme. We use the moduleRoot and moduleId options of Babel to identify our AMD modules that way during the gulp build process. When that is done we concatenate everything into one big file. That works, but IntelliJ does not know that we do this magic.
Is there a way to still make IntelliJ understand our imports? So that it will know that Base/utils/svg actually means /intellij-project/base-project-src/node_modules/base/? At the moment the IDE is mostly a glorified text editor, as refactorings obviously relies on the IDE understanding the imports.
Note: Unfortunately I can't change the import structure, as it's a decision I can't change. Nor can I switch to other tools instead of the above mentioned ones, such as WebPack.
I'm facing the same problem with this. I'm looking for a way to get rid of the annoying relative paths as you guys have done, but to get them to work with IntelliJ is another piece of work.
What can help is the symlink approach that can be found here.
https://gist.github.com/branneman/8048520
IntelliJ can work nicely with node_modules, so you could symlink a folder in your node_modules to point to the real thing. Then I suppose IntelliJ will be able to resolve your imports.
I'm trying to open an existing project into Idea Community Edition (it is a netbeans project). I tried using create project from existing code.
One of the modules ends with .Lib (something like MyApp.Lib). For some reason Idea doesn't import that module, and even if I try to create a project with just that module it doesn't let me (it doesn't even show up in the directory browser, even though that it is there if I check with windows explorer).
I'm guessing it has to do something with the Lib at the end, probably it considers it as a library folder. Does anyone happen to know a way around this?
Renaming the module is not an option, as it is under version control.
I found the solution to this. Needed to remove .lib from the Ignore files and folders in the Settings>File Types section.
I want to switch my python-IDE from idle to pydev (eclipse). I am using a couple of modules which I have as compiled bytecode (*.pyc) only. In idle that was never a problem and it even offers code completion for those compiled modules. But pydev gives me a lot of "undefined variable" errors - however the code is interpreted correctly.
Is there a way pydev can handle bytecode modules the way idle does? Perhaps without decompiling the files?
Try adding the modules as forced builtins.
To do that, go into Settings → PyDev → Interpreter - (Python/Jython/IronPython as approriate), select the interpeter you're using, and add it to the list on the Forced Builtins tab (look here for more details).
(Note that you may or may not have to add multiple entries for subpackages and modules; for example to get Fabric working properly one needs to add both fabric and fabric.api)
That makes PyDev load those modules into an interpreter to get code-completion and error checking data, rather than just analysing source code.
I've not tried it for .pyc files, but it works for other things like importing something that's generated dynamically by a script's __init__.py or something (ie fabric) so it might work for you.
(see also this FAQ and that one on the PyDev site)