In spacemacs, how can I enable editorconfig-mode by default ? - spacemacs

Currently I use editorconfig in my projects, and every time I open emacs/spacemacs, I need to press M-x and enable editorconfig-mode manually.
How can I enable editorconfig-mode by default ?

from gitter:
Add (editorconfig-mode 1) to dotspacemacs/user-config before the closing parenthesis

Related

Add time on ohmyzsh console on robbyrussell theme

Very simple problem, i would like to see the time when i prompted my commands in the ohmyzsh console. I use the robbyrussell theme and would prefer to keep it if possible.
Thanks !
You can try
PROMPT="%D{%m/%f/%y}|%D{%L:%M:%S}"
See more at https://superuser.com/questions/943844/add-timestamp-to-oh-my-zsh-robbyrussell-theme/943916

Force retesting or disable test caching

Problem:
When I run the same go test twice the second run is not done at all. The results are the cached ones from the first run.
PASS
ok tester/apitests (cached)
Links
I already checked https://golang.org/cmd/go/#hdr-Testing_flags but there is no cli flag for that purpose.
Question:
Is there a possibility to force go test to always run test and not to cache test results.
There are a few options as described in the testing flags docs:
go clean -testcache: expires all test results
use non-cacheable flags on your test run. The idiomatic way is to use -count=1
That said, changes in your code or test code will invalidate the cached test results (there's extended logic when using local files or environment variables as well), so you should not need to invalidate the test cache manually.
In Go11, I couldn't disable cache using GOCACHE with modules, I used -count=1 instead:
go test -count=1
Prior to Go11:
GOCACHE=off go test
Or, clean test cache and run test again:
go clean -testcache && go test
There's also GOCACHE=off mentioned here.
The way that I fixed this (I'm using Visual Studio Code on macOS):
Code > Preferences > Settings
Click ... on the right hand side of the settings page
Click Open settings.json
Either:
Add the following snippet to your settings.json file
"go.testEnvVars": {
"GOCACHE": "off"
}
Change the value of go.testEnvVars to include the following: "GOCACHE": "off"
For VS Code (in 2022)
Open VSCode's settings.json. To open settings.json, press Ctrl + , (or Cmd+, on Mac), then click the Open JSON button shown below. Optionally, if you don't want to set this globally, you can create a .vscode/settings.json file at the project root.
Set the go.testFlags value in settings.json:
{
"go.testFlags": ["-count=1"]
}
Save and enjoy.
Note: these steps ensure test cache will be skipped every time. If you want a one-time fix, then run go clean -testcache in the terminal, as Marc's most-voted answer says.

Visual Studio Code Formatting fail on save

I've started learning React Native.
I'm using Visual Studio Code as my editor.
I've set up the boiler plate and started the app. But whenever I change a .js file and hit save, VSCode is messing up all the formatting.
I thought I could sort this in the settings.json file but after googling for a while and playing around I can't find the correct setting.
Is this a bug or am I doing something wrong?
Setting file is default one:
UPDATE: I re-installed vscode. Then set up a basic js file with a react native tag and a html tag. I added in:
"editor.formatOnSave": false,
"javascript.format.enable": false
To my settings.json file and the problem still occurs:
The problem is having tags in a js file, I just don't know how to tell vscode to ignore them?
I found out what this was by looking though the extensions. Thanks to #wgj for the hint.
Turns out it was the JS-CSS-HTML formatter. I looked through the instructions and have removed the auto save for now. I'll have to work out the specific settings for this.
It uses js-beautify so if anyone knows the settings I should be looking at would be much appreciated.
I had a similar problem and it turned out my ultimate culprit was...
So I simply disabled it for the workspace.
Same here, all my HTML format messed up after saving, I disable "JS-CSS-HTML Formatter" and problem solved
In the end, what did the trick was changing the file format from JavaScript to JavaScript React on the bottom toolbar.
All my HTML format messed up in js after saving, I disable "JS-CSS-HTML Formatter" and restarted vscode, problem solved.
I found my solution to this problem by converting my components file extension from js to jsx. No more issues and everything is working fine.
Disable js-css-html formatter.
if you are using prettier and beautify together, override the setting as :
"beautify.ignore": [
"**/*.js",
"**/*.jsx"
]
Use Prettier Code Formatter instead of Beautify. Works perfectly for language mode Babel JavaScript
You should search for "format" in settings.json. You'll find a whole lot of TypeScript/JavaScript formatting tweaks in there, but the one that stands out to me is:
// Defines space handling after opening and before closing non empty brackets.
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false
Alternative, you're not a fan of formatting at all, you can turn it off entirely:
// Enable/disable default JavaScript formatter.
"javascript.format.enable": true,
However, a lot of my formatting options come from language server extensions, so if you're using one for React Native specifically, be sure to check the attributes in settings.json, or the docs to see if there are any attributes you can add.
Add this on settings.json file. Whether you are using any extension or not, use this code. It works fine for me:
Solution 1: Just Disable JS-CSS-HTML Formatter
Solution 2: Press Ctrl+, (open settings) after that search Code formatted and change none --> Prettier
If you don't have prettier install from the extension's marketplace.
i just had this problem , apparently its because of the beautify/prettier , try to disable both , then restart Vs code (your editor) . but then if u really want to use prettier , go under its extension settings and make sure its in strict with whitespaces and toogle around a few other settings and you should be fine , cheers .
Just turning off format on save option from the settings would work.
You can select JavaScript React in the task bar under Select Language Mode.
You can try one of the following
uninstall other formatters which are not required. To check how many formatters you have just press ctrl + shift + p or command +shift + p (mac) and type format document after that a menu will appear showing you your formatters
press ctrl + shift + p or command +shift + p (mac) and type settings and click on open users settings and then search for format on save and check the box
that's it!!
Enjoy
changing the file format from JavaScript to JavaScript React on the bottom toolbar worked just fine for me
I have tried all methods but the problem is solved completely by this:
-> Open setting.json
-> "files.associations": {
"*.js": "javascriptreact"
}
->Add above lines and press save the problem will solve
You can type the following command string when creating your project
npx create-react-app name-of-app react-complete-guide
or the following, if you have create-react-app installed already
create-react-app name-of-app react-complete-guide

Hide settings bundle option from code

In my app I have an option defined in the Settings.bundle that is used only for debugging purposes.
Is there a way of hiding this from code, for when the application is in production, without manually deleting the option from Settings.bundle/Root.plist ?
Something in the lines of:
#ifdef DEBUG
// Remove the option from the settings bundle
#else
// Show the option in (or don't actually remove the option from) the settings bundle
#endif
Thank you!
There're a few options:
use a separate dev target with special Settings.bundle,
modify Settings.bundle with a Run script at Build Phases for the single target adding the section for DEBUG configuration, check CONFIGURATION variable for that.
I'm almost certain there is no way to do that.

How to disable code formatting for some part of the code using comments?

I'd like to selectively disable the IntelliJ IDEA code formatter for a portion of code just like I can in Eclipse. Does IntelliJ support this feature, and if so, how do I use it?
Since version 13 it's possible to wrap the code with
// #formatter:off
...
// #formatter:on
IntelliJ IDEA v.2018+:
File > Settings > Editor > Code Style
IntelliJ IDEA v.2016+:
Preferences > Editor > Code Style
IntelliJ IDEA v.14+:
Preferences > Editor > Code Style > Formatter Control
You can change the formatter control markers, as long as they're in comments.
Ensure formatter markers in comments are enabled, as shown in the following figure:
Note for Carlos' answer of #formatter:off and #formatter:on to work, you may need to enable the preference first:
Discovered via How to config intellij-idea not format some part of the code?
IDEA-56995 Disabled code formatting per region using comments
In xml files, use:
<!-- #formatter:off -->
<!-- #formatter:on -->
Obsolete answer from 2010:
No, it's not possible right now, I've submitted a new issue which you can track.
As a temporary solution you can use external formatter plug-in for IDEA which can utilize Eclipse code formatter (I didn't check whether this particular option is supported).
It's currently not possible to exclude entire files (like regression test data xmls) from formatting. See https://youtrack.jetbrains.com/issue/IDEA-167112