Is there an option to disable "explicit" import suggestions in VSCode, like shown in the picture below? I find these visually displeasing because they add extra unnecessary lines. These are Haskell imports.
Related
When writing JSX (or any typescript code really) if you have an available import that's not yet imported, you get a squiggly line under it and can press ctrl+dot on it and then automatically import the code as a "refactoring."
How can I set this up in Javascript? I've seen a screenshot of someone else's VSC where it is available underneath "more options" and so I'm pretty sure it's possible, but when I press ctrl+dot I get nothing.
Note: I'm aware I can press ctrl+space. However, I don't want to do this, for two reasons. (1) alt+space is pretty bad UX because if you press it in the middle of a word it continues to autocomplete even if you already had the full name there and so you are left with an incorrect tag (e.g. if your cursor was after the d in Keyboard for a component called KeyboardRow you are left with KeyboardRowRow) and (2) I want to rebind quick fix to alt+enter to match pycharm; and I want the same hotkey & UX in both Typescript and Javascript.
I haven't worked too much with JS, mainly with TS, but I have two extensions installed in my vscode that helped me a lot while coding in vanilla JS.
Path intellisense and Auto import
You can try if My Code Actions can be used to construct a Quick Fix for these types of PROBLEMS/squiggles
So, here is the problem:
Whenever I am coding with Flutter and Dart, and I use a feature from another file, when I press Tab, VS Code will auto-import the file for me.
The thing is, VS Code will use the package import syntax, like import 'package:<project_name>/<file_path>';. But I prefer relative import syntax.
So, is there a setting I can change in VS Code for Dart to configure it to use relative imports by default?
Thanks!
While importing, you can find both option by tapping on yellow bulb or pressing ctrl+.
Another handy thing, using dart-import extension on Vs-code.
Personally, I am using dart-import extension. There is an extension setting you can turn on to modify imports on save. So, you can have a consistent import structure without needing to choose every single time.
There is a recommendation in effective dart guideline for relative path import usage.
Every time I want to add a widget by selecting it on the autocomplete list from VS Code, let it be a Container, Column, etc., the full path is re-imported. Sometimes the autocomplete list will also show multiple lines for the same widget. import 'package:flutter/material.dart';' is already included on the file.
e.g.
import '../../../../../flutter_linux_v1.0.0-stable/flutter/packages/flutter/lib/src/widgets/framework.dart';
import '../../../../../flutter_linux_v1.0.0-stable/flutter/packages/flutter/lib/src/widgets/container.dart';
Image here: screenshot of autocomplete
It goes away if I run Flutter clean but comes right back. Any ideas to make this go away?
Which extensions are you using? Might there might be some extensions which is overriding flutters default extension behaviour.
You can run code --list-extensions from command line to get all extension installed. You can post it here so that me or someone else can help you out.
if I type autorun inside the code, vscode suggests me to auto import it from mobx:
I want to define some custom names for that for example if I type _ somewhere in the code, I want vscode to suggest me to import lodash
or if type PropTypes I want vscode to suggest auto import PropTypes from 'prop-types'
Is this possible?
I haven't written any vscode extensions yet, but I can take a swing at it if that's what it takes to complete this functionality
Thanks in advance for any help and guidance!
There's no support for this built into VSCode currently. Basically you're looking to define a list of names/aliases for default exports (i.e import MyCustomName from 'lodash'). Cool idea! I think you'd have to write a pretty low-level VSCode extension to accomplish this might end up being limited by the TypeScript compiler itself. Good luck!
Best I could do is declaring it on a file and importing it from there:
tailwind.ts
export { default as tailwind } from "tailwind.macro";
someFile.ts
import tailwind from "~/tailwind";
I have a question. If there's any possibility to automatically import necessary classes when I work with Activities in text editor (gedit) or Netbeans? Because Android Studio is incredibly slow on my PC.
I mean import android.app.Activity import android.os.Bundle etc.
RTFM:
according to Netbeans doc:
There are several ways of how you can work with import statements. The IDE's Java Editor constantly checks your code for the correct use of import statements and immediately warns you when non-imported classes or unused import statements are detected.
When a non-imported class is found, the Bulb error icon error mark appears in the IDE's lefthand margin (this margin is also called the glyph margin). Click the error mark and choose whether to add the missing import or create this class in the current package.
While you are typing, press Ctrl-Shift-I (or choose Source > Fix Imports from the menu) to add all missing import statements at once.
Press Alt-Shift-I to add an import only for the type at which the cursor is located.
When you select a class from the code completion window, the Editor automatically adds an import statement for it, so you do not need to worry about this.