VS Code setting editor.autoClosingBrackets languageDefined - where are these language settings defined? - settings

Related issue on Github.
VS Code's setting editor.autoClosingBrackets: languageDefined says "Use language configurations to determine when to autoclose brackets".
Where does VS Code gets this information from?
Is the "language configuration" referring to language-specific user settings? If so, what setting controls this? If it's the editor.autoClosingBrackets setting that controls this, what's the default behaviour for:
[javascript]: {
"editor.autoClosingBrackets": "languageDefined"
}
Does it force the default behaviour for this language?
Where can I see a list of all language configurations?

I found this setting when I entered Command Palette(⇧⌘P) and typed "settings", and in the listing select the option "Preferences: Open Settings (JSON)", then you can make this setting.
For more informations: VS Code settings you should customize
My configurations:
{
"typescript.updateImportsOnFileMove.enabled": "always",
"explorer.confirmDragAndDrop": false,
"cSpell.userWords": [
"rxgo"
],
"go.toolsManagement.autoUpdate": true,
"js/ts.implicitProjectConfig.experimentalDecorators": true,
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.autoClosingBrackets": "always"
},
"angular.enable-strict-mode-prompt": false,
"[typescript, javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"security.workspace.trust.untrustedFiles": "open",
"editor.tabSize": 2,
"javascript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.importModuleSpecifier": "relative",
"files.autoSave": "afterDelay"
}

Related

How to auto-correct Ruby linting errors in VS Code (in 2023)

I'm using VS Code and writing Ruby code on MacOS 12.6. I have installed several extensions for linting. I can see the errors, but I cannot get any of them to provide automatic correction, even for trivial mistakes like single vs double quotes. It always says "no quick fixes available".
If I use the command palette to run "Format document" it will correct these kinds of mistakes. So somehow VS Code knows how to fix these problems. It just won't do it in a convenient way.
You can see in the screenshot which extensions I have installed / active:
Ruby by Peng Lv
VSCode Ruby by Stafford Bunk
Ruby Solargraph by Castwide
ruby-rubocop by misogi
I don't really care which extensions are used. I would be happy with any working configuration that provides this basic functionality.
Here is my entire settings.json
{
"workbench.tree.indent": 16,
"editor.formatOnSaveMode": "modifications",
"editor.formatOnSaveTimeout": 5000,
// "ruby.rubocop.onSave": true,
"ruby.useBundler": true, //run non-lint commands with bundle exec
"ruby.useLanguageServer": true, // use the internal language server (see below)
"ruby.lint": {
"rubocop": {
"useBundler": true // enable rubocop via bundler
},
"reek": {
"useBundler": true // enable reek via bundler
}
},
"ruby.format": "rubocop", // use rubocop for formatting
"eslint.format.enable": true,
"eslint.options": {
"extensions": [ ".html", ".js", ".vue", ".jsx" ]
},
"eslint.validate": [
"html",
"javascript",
"vue"
],
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// "[ruby]": {
// "editor.defaultFormatter": "misogi.ruby-rubocop",
// "editor.formatOnSave": true
// },
"[json]": {},
"ruby.codeCompletion": "rcodetools",
"ruby.intellisense": "rubyLocate",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.tabSize": 2,
"[ruby]": {
"editor.defaultFormatter": "misogi.ruby-rubocop"
},
"editor.formatOnSave": true,
"ruby.rubocop.useBundler": true,
}
Note
This question sounds similar to: vscode( vscode-ruby + rubocop ) how to auto correct on save?
But that question is old and the answers reference config settings that aren’t recognized anymore.
There is a revived Rubocop for Visual Studio Code extension by Loran Kloeze available on the Visual Studio Marketplace.
This extension is a fork of the original Rubocop extension and adds a few features, such as Rubocop server support for improved performance and specifically, a feature to Implement quick fixes for Rubocop.
Even with the original extension by m1sogi, you should have been able to use the global auto correct function. The new quick fix feature is probably more useful though...

Couldn't start dlv dap

When I launch in VSCode dlv dap debug, I get this message:
Couldn't start dlv dap:
Error:timed out while waiting for DAP server to start
I already have launch configurations for the project:
lunch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"showLog": true,
"env": {
"GO111MODULE": "on"
}
}
]
}
and setting.json is :
{
"folders": [
{
"path": "."
}
],
"settings": {
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.autocompleteUnimportedPackages": true,
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeImports": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"explorer.confirmDelete": false,
"go.formatTool": "goimports",
"go.docsTool": "gogetdoc",
"go.buildFlags": [],
"explorer.confirmDragAndDrop": false,
"window.zoomLevel": 0.8,
"editor.minimap.enabled": false,
"go.useLanguageServer": true,
"go.delveConfig":{
"debugAdapter":"dlv-dap"
},
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"experimentalWorkspaceModule": true,
"usePlaceholders": true, // add parameter placeholders when completing a function
"completionDocumentation": true // for documentation in completion items
}
},
}
The structure of the project is shown in the figure:
This might be happening due to recent updates to VS Code Go extension.
First options is to fix it by running "Go: Install/Update Tools" command from the Command Palette (Linux/Windows: Ctrl+Shift+P, Mac: ⇧+⌘+P).
Then, mark dlv & dlv-dap from the menu, and hit ok to start install/update.
Delve’s native DAP implementation is under active development, so take advantage of the most recent features and bug fixes by using Delve built from its master branch. The Go extension maintains this newest version of Delve separately from the officially released version of dlv and installs it with the name dlv-dap.
Second option, is to use legacy debug adapter. More on this in the link below ...
Check out the full documentation at https://github.com/golang/vscode-go/blob/master/docs/debugging.md
You might have some luck switching the delveConfig to use legacy mode:
"go.delveConfig":{
"debugAdapter":"legacy"
}
My team and I recently began seeing the same issue after updating VSCode. There's a little more info on this setting here: https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#switching-to-legacy-debug-adapter, but I believe root cause (if this does indeed solve your issue) is going to be your version of Golang is not the version targeted by dlv-dap. Anything below Go version 1.15 needs to use legacy mode, and the latest version of the delve debugger happens to skip legacy mode by default now.
I also needed to kill VSCode before this change took effect. According to the dlv-dap docs, you can also force it into legacy mode by switching launch.json's mode to "remote", so there's likely a few (maybe better) ways to resolve this issue.
For macOS users:
brew install delve
Linux/Windows: Ctrl+Shift+P, Mac: ⇧+⌘+P

Using Git Bash terminal in VS Code - how to force it to open internally

Duplicate: I asked this on SuperUser without answer
Using:
editor: VS Code
terminal: Git Bash
VS Code offers a shortcut Ctrl+Shift+C to open it externally and a shortcut Ctrl+` (or in my case Ctrl+F1) to open it internally.
In my case it opens it externally with both shortcuts as well as with menu View->Terminal.
I turned Google upside down to the best of my knowledge to find this solution.
I have reinstalled Git from git-scm.com.
I checked my VS Code settings (Code\User\settings.json) to find a clue, if I accidentally set to force external opening myself.
I know I shouldn't paste an entire file, but maybe you find where the problem in settings.json lies:
{
// Chosen Terminal
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
// Prevent losing aliases, colorization etc. for the Git bash terminal
// "terminal.integrated.shellArgs.windows": [
// "--login",
// "--init-file",
// "C:\\Program Files\\Git\\etc\\profile"
// ],
// Windows Terminal
"terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe",
// Chosen Theme Color and Color Customization
"workbench.colorTheme": "Monokai",
"workbench.colorCustomizations": {
"[Monokai]": {
// "statusBar.background": "#666666",
// "panel.background": "#555555",
// "sideBar.background": "#444444",
"tab.activeBackground": "#999999",
"tab.activeForeground": "#333333"
}
},
// Emmet Customization
"emmet.triggerExpansionOnTab": true,
// Editor Customization
"editor.fontSize": 14,
"editor.wordWrap": "on",
"editor.codeActionsOnSave": {},
"editor.tabSize": 2,
// PHP Tooltip Suggestions
"php.suggest.basic": false,
"php.validate.executablePath": "C:\\xampp\\php\\php.exe", //for linting
"php.validate.run": "onSave", //change to onType if need be
"explorer.confirmDelete": false,
"beautify.language": {
"js": {
"type": [
"javascript",
"json",
"jsonc"/*,
"html"*/
],
"filename": [
".jshintrc",
".jsbeautifyrc"
]
},
"css": [
"css",
"scss"
],
"html": [
"htm",
"html"
]
},
"beautify.config": {
"indent_size": 2,
"indent_char": " ",
"css": {
"indent_size": 2
}
},
// Git costumization
"window.zoomLevel": 0,
"workbench.colorCustomizations": {
"gitDecoration.addedResourceForeground": "#f45342",
"gitDecoration.modifiedResourceForeground": "#3888d8"
},
"workbench.settings.useSplitJSON": true,
"files.trimTrailingWhitespace": true,
"minify.minifyExistingOnSave": true
}
If I use Ctrl+Shift+C shortcut, let's say on two different projects, it opens two external terminals just as one would expect.
If I use Ctrl+F1 (default Ctrl+`) shortcut it wants to open them internally so bottom part of VS Code windows looks like this:
And it still opens them externally:
Can anyone provide some insight?
It seems adding "terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe" to Settings is the old way and doesn't work as expected.
Delete all lines related to bash from Settings JSON (check User, Workspace and Folder Settings to be sure) and save the file.
Then just open Command Palette (Ctrl + Shift + P) and type in
Select Default Shell
and choose bash from there.
Now all you have to do is restart VS Code and terminal will be running as expected.
For shells that aren't in your %PATH%, see the other answers.
See the complete Visual Studio Code shell reference.
There should be pre existing Terminal profiles already configured so it should be as simple as adding:
"terminal.integrated.defaultProfile.windows": "Git Bash",
to your settings.json

WebStorm does not recognize `browser`, `element` etc in Protractor test spec

Following Protractor guide I wanted to create my first test. While the test works unfortunately JetBrains WebStorm does not recognize all of my variables in given test
I have enabled in Libraries/JavaScript:
jasmine
karma
karma-jasmine
HTML
Node.js Core
selenium-webdriver
As seen above Node.js Core library is enabled.
I have also visited this question but unfortunately the angular-protractor is no longer available.
What am I missing?
Your editor will understand it if its imported. Elese it will know where to find browser ot by
Add import statement at top of your file.
import {by, element} from 'protractor';
Use JS Hint RC. It will work like magic.
You can find this by going to
Settings -> Languages and Frameworks -> Javascript(select ECMA Script 6) ->Code Quality Tools- >JS Hint - Enable, use config file.
As for config file, save the bellow file, with following name: '.jshintrc'.
Rate the answer as positive if this worked for you!
{
"jasmine": true,
"mocha": true,
"esversion":6,
"loopfunc": true,
"node": true,
"globals": {
"esversion": 6,
"angular": false,
"browser": false,
"inject": false,
"_": false,
"driver": false,
"protractor": false,
"$": false,
"$$": false,
"element": false,
"by": false,
"list": false
}
}

HTML Beautify Settings in Brackets

I understand that the Brackets Beautify extension is based on JS Beautify, and that I have a suite of preference settings available because of that, but I have no idea of how to alter them through the Brackets settings.json file. Does anyone have any idea?
Here are my current settings:
{
"debug.showErrorsInStatusBar": false,
"linting.collapsed": true,
"wordWrap": false,
"me.drewh.jsbeautify.on_save": false,
"styleActiveLine": true,
"themes.theme": "explicit-brackets-style",
"fonts.fontSize": "12px"
}
I'm assuming I just need to add new "me.drewh.jsbeautify" lines, but that doesn't seem to work...
I'm specifically looking at HTML settings, BTW.
Like the original library the extension uses a .jsbeautifyrc file for the settings.
It should work if you create such a file in your project root with content like this:
{
"eol": "\n",
"end_with_newline": true,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"indent_inner_html": false,
"brace_style": "collapse",
"indent_scripts": "normal",
"wrap_line_length": 0,
"wrap_attributes": "auto"
}
Additionally, I can only recommend you to have a look at my fork of that extension as it allows more detailed settings.

Resources