I try to change line break with prettier, but vs code ignore my settings for this...
I try to put line-length: 140 but nothing happened.
I try this, but without success
// edit your tslint.json
"max-line-length": [
true,
{
"limit": 140,
"ignore-pattern": "^import |^export {(.*?)}"
}
],
I use
prettier: [3.18.0]
VS code: 1.41.1
here are my settings
{
"workbench.editor.highlightModifiedTabs": true,
"files.trimFinalNewlines": true,
"window.menuBarVisibility": "default",
"workbench.activityBar.visible": true,
"files.autoSave": "off",
"window.zoomLevel": 0,
"editor.rulers": [
140
],
"editor.wordWrapColumn": 140,
"[markdown]": {
"editor.wordWrap": "wordWrapColumn",
"editor.quickSuggestions": false
},
"diffEditor.ignoreTrimWhitespace": true,
"vsicons.projectDetection.autoReload": true,
"files.eol": "\n",
"editor.formatOnSave": true,
"editor.tabSize": 2,
"javascript.referencesCodeLens.enabled": true,
"cSpell.userWords": [
"dropdown",
"toastr"
],
"typescript.updateImportsOnFileMove.enabled": "always",
"terminal.integrated.rendererType": "dom",
"html.format.wrapLineLength": 140,
"editor.wordWrap": "bounded",
"prettier.jsxBracketSameLine": true,
"html.format.wrapAttributes": "preserve-aligned",
"prettier.printWidth": 140
}
Is there any another way to get this to work, because prettier always format my components or html file in a strange way...
let's say,
this
languageLocale: [null, [Validators.minLength(1), Validators.maxLength(255)]],
to this
languageLocale: [
null,
[Validators.minLength(1), Validators.maxLength(255)]
],
or html
<mat-form-field>
<input class="disabledInput" formControlName="id" matInput/>
</mat-form-field>
to this
<mat-form-field>
<input
class="disabledInput"
formControlName="id"
matInput
/>
</mat-form-field>
And this is terrible to read if we have multiple input fields
Need to put config to package.json
Refered to here https://prettier.io/docs/en/configuration.html
"prettier":{
"arrowParens": "avoid",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 140,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"vueIndentScriptAndStyle": false,
"rangeStart": 0
}
Related
I am using VS code with a number of extensions, including pylance , editorconfig, prettier, . No matter how many times I change the insertSpaces to true for the different languages or any indentation related settings to spaces mode, at some point (sometimes after a couple of minutes of usage, sometimes after reopening VS code) the tab key starts indenting with tab. I notice this mostly by pressing enter. How can I figure out which extension is doing overriding the spaces indentation mode? I don't want to go through the exercise of testing them one by one. Here's my settings.json that I have pruned down to remove nonrelevant settings.
{
"workbench.statusBar.visible": true,
"editor.insertSpaces": true,
"editor.tabSize": 4,
//"shellformat.useEditorConfig": true,
"editor.fontSize": 10,
"editor.tabCompletion": "on",
"editor.renderWhitespace": "all",
"editor.suggestSelection": "first",
"editor.codeLens": true,
// Generic
"cSpell.enabled": true,
"cSpell.language": "en",
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--disable=C0303",
"--indent-string=\" \""
],
"python.linting.pylintEnabled": true,
"python.autoComplete.addBrackets": true,
"python.terminal.activateEnvironment": true,
"[python]": {
"editor.defaultFormatter": "ms-python.vscode-pylance",
"editor.tabSize": 4,
"editor.autoClosingBrackets": "always",
"editor.insertSpaces": true,
},
"prettier.useEditorConfig": true,
"prettier.tabWidth": 4,
"python.linting.pylintCategorySeverity.convention": "Hint",
"python.linting.pylintCategorySeverity.refactor": "Warning",
"python.linting.maxNumberOfProblems": 200,
"python.linting.pycodestyleArgs": [
"--max-line-length=100"
],
"python.jediEnabled": false,
"vsintellicode.python.completionsEnabled": true,
"[json]": {
"editor.insertSpaces": true
},
// R
"[r]": {
"editor.autoClosingBrackets": "always",
"editor.defaultFormatter": "Ikuyadeu.r",
"editor.comments.insertSpace": true,
},
"r.interpreter": 0,
"r.linting.enable": true,
"r.lsp.debug": true,
"r.linting.maxLineLength": 105,
"r.editor.tabSize": 2,
"r.linting.noTabs": true,
"editor.detectIndentation": false,
"editor.comments.insertSpace": true,
"prettier.useTabs": false,
"editor.useTabStops": true,
"editor.stickyTabStops": false,
"update.enableWindowsBackgroundUpdates": false,
"breadcrumbs.enabled": true,
// REMOTE connection
"remote.SSH.showLoginTerminal": true,
"remote.SSH.lockfilesInTmp": true,
"window.openFoldersInNewWindow": "on",
"search.showLineNumbers": true,
"r.lsp.diagnostics": false,
"diffEditor.ignoreTrimWhitespace": false,
"workbench.iconTheme": "vscode-icons",
"material-icon-theme.showUpdateMessage": false,
"window.zoomLevel": 3,
"sync.removeExtensions": true,
"sync.syncExtensions": true,
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.analysis.extraPaths": [],
"python.terminal.activateEnvInCurrentTerminal": true,
"python.workspaceSymbols.enabled": true,
"python.analysis.completeFunctionParens": true,
"python.languageServer": "None",
"gitlens.currentLine.enabled": false,
"gitlens.hovers.currentLine.over": "line",
"gitlens.statusBar.enabled": false,
"jupyter.askForKernelRestart": false,
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"editor.autoIndent": "brackets",
"formattingToggle.affects": [
"editor.formatOnPaste",
"editor.formatOnSave",
"editor.formatOnType"
],
}
I have been trying to set up Prettier for VS Code globally so that I have all the basic features as well as single quotes. Before installing Prettier I uncommented VS Code's default Prettier configurations in settings.json file but it wasn't working.
Then I installed Prettier and enabled what I needed from VS Code's Settings > Extensions > Prettier tab but it still wasn't working. After that I created .prettierrc.json file and put it right beside where VS Code's settings.json file is, which is in c:\\Users\\Admin\\AppData\\Roaming\\Code\\User\\settings.json. Then I added this path in VS Code's Settings > Extensions > Prettier > Config Path field. And guess what, it is still not working.
What am I doing wrong here?
Here's how my settings.json file looks like:
{
"terminal.integrated.shell.windows": "D:\\Program Files\\Git\\bin\\bash.exe",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.autoClosingBrackets": "always",
"editor.bracketPairColorization.enabled": true,
"editor.maxTokenizationLineLength": 2000000,
"diffEditor.maxFileSize": 0,
"json.maxItemsComputed": 50000000,
"svelte.enable-ts-plugin": true,
"liveServer.settings.donotShowInfoMsg": true,
"bracketPairColorizer.depreciation-notice": false,
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"javascript.updateImportsOnFileMove.enabled": "always",
"workbench.colorTheme": "Community Material Theme Palenight High Contrast",
"reactSnippets.settings.importReactOnTop": false,
"reactSnippets.settings.prettierEnabled": true,
"html.completion.attributeDefaultValue": "singlequotes",
"html.format.indentInnerHtml": true,
"powermode.enabled": true,
"powermode.combo.counterEnabled": "hide",
"powermode.shake.enabled": false,
"powermode.combo.location": "off",
"powermode.presets": "flames",
// "prettier.jsxBracketSameLine": true,
"prettier.jsxSingleQuote": true,
"prettier.singleQuote": true,
// "prettier.tabWidth": 4,
// "prettier.useTabs": true,
"prettier.bracketSpacing": true,
"prettier.tabWidth": 4,
"prettier.useTabs": true,
"prettier.arrowParens": "avoid",
"prettier.configPath": "c:\\\\Users\\\\Admin\\\\AppData\\\\Roaming\\\\Code\\\\User\\\\.prettierrc.json"
// "prettier.bracketSameLine": true,
// "prettier.arrowParens": "avoid",
// "editor.wordWrapColumn": 120
}
And this is my .prettierrc.json file:
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": true,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5",
"useTabs": true,
"vueIndentScriptAndStyle": false,
"parser": "json",
"filepath": "c:\\Users\\Admin\\AppData\\Roaming\\Code\\User\\.prettierrc.json"
}
Any suggestions?
Python autocomplete in VSCode is messing up my code
Here is my system:
If I use Pylance, Intellisense does not work properly
and if I use Jedi, Intellisense does not work properly
When I press enter, my code is completely borked. This is just one example and has been frustrating the heck out of me!
Below is my settings.json file:
{
"AREPL.pythonPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe",
"dicom.alwaysShowMenu": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.formatOnSave": true,
"editor.insertSpaces": false,
"editor.rulers": [
90
],
"editor.suggestSelection": "first",
"explorer.compactFolders": false,
"explorer.confirmDragAndDrop": false,
"files.exclude": {
"**/.git": false
},
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"git-graph.defaultColumnVisibility": {
"Author": false,
"Commit": true,
"Date": false
},
"git-graph.referenceLabels.alignment": "Branches (aligned to the graph) & Tags (on the right)",
"glassit.alpha": 255,
"json.format.enable": true,
"mypy.dmypyExecutable": "${workspaceFolder}\\.venv\\Scripts\\dmypy.exe",
"mypy.runUsingActiveInterpreter": true,
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
"python.defaultInterpreterPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe",
"python.formatting.blackArgs": [
"--line-length",
"90"
],
"python.formatting.provider": "black",
"python.languageServer": "Jedi",
"python.linting.enabled": true,
// "python.linting.flake8Args": [
// "--line-length",
// "90"
// ],
"python.linting.mypyEnabled": true,
"python.linting.mypyPath": "${workspaceFolder}\\.venv\\Scripts\\mypy.exe",
// "python.linting.pylintArgs": [
// "--generate-members"
// ],
// "python.linting.pylintEnabled": true,
"python.pythonPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe",
"python.terminal.activateEnvironment": true,
"python.testing.pytestArgs": [
"${workspaceFolder}\\tests"
],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": true,
"python.venvPath": ".venv",
"restructuredtext.builtDocumentationPath": "${workspaceFolder}\\docs\\build\\html",
"restructuredtext.confPath": "{workspaceFolder}\\docs\\source",
"restructuredtext.languageserver.disabled": true,
"restructuredtext.sphinxBuildPath": "${workspaceFolder}\\.venv\\Scripts\\sphinx-build.exe",
"screencastMode.keyboardOverlayTimeout": 1500,
"screencastMode.mouseIndicatorSize": 20,
"screencastMode.onlyKeyboardShortcuts": true,
"screencastMode.verticalOffset": 0,
"security.workspace.trust.untrustedFiles": "open",
"shellcheck.customargs": [
"-x"
],
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.fontFamily": "CaskaydiaCove Nerd Font Mono",
"terminal.integrated.tabs.enabled": true,
"trailing-spaces.syntaxIgnore": [
"markdown"
],
"update.enableWindowsBackgroundUpdates": false,
"vsicons.dontShowNewVersionMessage": true,
"workbench.colorTheme": "Predawn",
"workbench.editor.enablePreview": true,
"workbench.editorAssociations": {
"*.dcm": "default",
"*.ipynb": "jupyter-notebook",
"*.tiff": "tiff.preview",
"git-rebase-todo": "default"
},
"workbench.iconTheme": "material-icon-theme",
"workbench.settings.editor": "json",
"workbench.settings.openDefaultSettings": true,
"workbench.settings.useSplitJSON": true,
"workbench.startupEditor": "newUntitledFile"
}
Why is this happening and how can I fix my Intellisense?
Update:
Removing "editor.suggestSelection": "first" helped, but I still get errors:
Adding the following to my settings.json makes Intellisense work as expected:
"editor.acceptSuggestionOnEnter": "off",
"editor.tabCompletion": "on"
Why the defaults are "on" and "off", respectively, I will never know. Everyone expects to press tab if you want to use the suggestion (like in bash terminal), and no one wants the autocomplete to complete blindly upon hitting enter.
Is there a way to make vscode format python files using 4 spaces while formatting files from other languages such JS, Typescript and HTML using 2 spaces only?
It`s pretty annoying to have to indent manually every time.
All of this trying is setting up a mess on my settings and still, I can`t make it work as I want.
This is what my settings.json looks like for the moment
{
"python.jediEnabled": false,
"miramac.node.terminalMode": false,
"python.pythonPath": "/usr/local/bin/python3",
"workbench.colorTheme": "Dracula",
"workbench.startupEditor": "newUntitledFile",
"workbench.editor.labelFormat": "short",
"terminal.integrated.fontSize": 12,
"editor.fontFamily": "Fira Code",
"editor.lineHeight": 19,
"editor.fontLigatures":true,
"editor.suggestSelection": "first",
"editor.renderLineHighlight": "gutter",
"editor.detectIndentation": true,
"editor.insertSpaces": false,
"editor.tabSize": 2,
"editor.autoIndent": "full",
"eslint.alwaysShowStatus": true,
"eslint.debug": true,
"eslint.format.enable": true,
"eslint.options": {
},
"python.languageServer": "Microsoft",
"liveServer.settings.donotVerifyTags": true,
"[html]": {
"editor.tabSize": 2,
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
},
"liveServer.settings.donotShowInfoMsg": true,
"prettier.tabWidth": 2,
"[javascript]":{
"editor.codeActionsOnSave": {
"source.fixAll": true,
}
},
"[javascriptreact]":{
"editor.codeActionsOnSave": {
"source.fixAll": true,
}
},
"[typescript]":{
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[typescriptreact]":{
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[python]": {
"editor.tabSize": 4,
"editor.codeActionsOnSave": {
// "source.fixAll": true,
},
},
"extensions.ignoreRecommendations": true,
"explorer.compactFolders": false,
//perguntar se vc confirma delete e drag and drops
"explorer.confirmDragAndDrop": false,
"explorer.confirmDelete": false,
//mostra o caminho completo do arquivo
"breadcrumbs.enabled": true,
"javascript.updateImportsOnFileMove.enabled": "never",
"typescript.updateImportsOnFileMove.enabled": "never",
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=pygame"
],
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
//set zsh theme to my terminal
//"terminal.integrated.shell.osx": "/bin/bash",
"terminal.integrated.shell.osx": "/bin/bash",
//"terminal.integrated.cwd": "",
"editor.renderControlCharacters": false,
"window.zoomLevel": -1,
"git.path": "/usr/local/git/bin/git",
"gitlens.views.repositories.files.layout": "list",
"gitlens.views.compare.files.layout": "tree",
"emmet.syntaxProfiles": {"javascript": "jsx"},
"emmet.includeLanguages": {"javascript": "javascriptreact"},
"typescript.tsserver.log": "verbose",
"javascript.suggest.autoImports": true,
"git.enableCommitSigning": true,
"git.enableSmartCommit": true,
"git.rebaseWhenSync": true,
"git.showPushSuccessNotification": true,
"workbench.sideBar.location": "left",
"workbench.activityBar.visible": true,
"terminal.integrated.automationShell.osx": "",
// "editor.defaultFormatter": "vscode.python",
// "editor.tokenColorCustomizationsExperimental": {},
"workbench.preferredDarkColorTheme": "Dracula",
"workbench.preferredHighContrastColorTheme": "Visual Studio Dark",
"material-icon-theme.activeIconPack": "nest",
"workbench.iconTheme": "material-icon-theme",
"material-icon-theme.folders.associations": {
"infra": "app",
"entities": "class",
"schemas": "class",
"typeorm": "database",
"repositories": "mappings",
"http": "container",
"migrations": "tools",
"modules": "components",
"implementations": "core",
"dtos": "typescript",
"fakes": "mock",
"coverage_reports": "tools",
},
"material-icon-theme.files.associations": {
"ormconfig.json": "database",
"routes.tsx": "routing",
"routes.ts": "routing",
"*.html": "html",
},
"sqlite.databaseExtensions": [
"db",
"db3",
"sdb",
"s3db",
"sqlite",
"sqlite3",
"ts"
],
}
Would there be anyone who can help in this issue?
I believe option + control + "B" should work
It is also a right click on the document and you should see a "format document" option.
It works for me
For the life of me I cannot figure this out. I have a complex VSCode setup and I believe the prettier extension is causing some behavior I do not want, and I hope someone knows how to disable or re-configure it:
JS files:
takes:
child.gender = $(pref).find('#ml').prop('checked')? 'male' : 'female';
And renders:
child.gender = $(pref)
.find('#ml')
.prop('checked')
? 'male'
: 'female';
I really need the formatter and would like to try to fix rather than disable.
Thanks for your help.
existing options:
"workbench.iconTheme": "material-icon-theme",
"php.suggest.basic": false,
"editor.minimap.enabled": false,
"editor.fontLigatures": true,
"editor.fontFamily": "'Fira Code', 'Arial', monospace",
"php.validate.executablePath": "C:\\wamp64\\bin\\php\\php7.2.4\\php.exe",
"files.associations": {
"*.php": "php",
"*.phtml": "php"
},
"php.validate.run": "onType",
"editor.cursorSmoothCaretAnimation": true,
"editor.smoothScrolling": true,
"files.trimFinalNewlines": true,
"emmet.includeLanguages": {
"blade.php": "html"
},
"vetur.format.options.tabSize": 4,
"vetur.format.options.useTabs": false,
"blade.format.enable": true,
"vetur.format.defaultFormatter.html": "prettyhtml",
"vetur.format.defaultFormatter.css": "prettier",
"vetur.format.defaultFormatter.postcss": "prettier",
"vetur.format.defaultFormatter.scss": "prettier",
"vetur.format.defaultFormatter.less": "prettier",
"vetur.format.defaultFormatter.stylus": "stylus-supremacy",
"vetur.format.defaultFormatter.js": "prettier",
"vetur.format.defaultFormatter.ts": "prettier",
"eslint.enable": false,
"window.zoomLevel": 0,
"files.trimTrailingWhitespace": true,
"prettier.singleQuote": true,
"prettier.trailingComma": "es5",
"prettier.eslintIntegration": true,
"prettier.disableLanguages": [],
"eslint.autoFixOnSave": true,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.detectIndentation": true,
"editor.tabSize": 4,
"editor.formatOnPaste": false,
"editor.formatOnType": true,
"editor.renderControlCharacters": true,
"editor.renderWhitespace": "none",
"files.exclude": {
".babelrc": true,
".editorconfig": true,
".eslintignore": true,
".eslintrc.js": false,
".gitignore": true,
".jshintrc": true,
".postcssrc.js": true,
"**/node_modules": true,
"build": true
},
"eslint.validate": [
{
"autoFix": true,
"language": "javascript"
},
{
"autoFix": true,
"language": "vue"
}
],
"attrsSorter.order": [
"is",
"v-for",
"v-if",
"v-else-if",
"v-else",
"v-show",
"v-cloak",
"v-once",
"v-pre",
"id",
"ref",
"key",
"slot",
"v-model",
"v-model.+",
"v-bind",
"v-bind.+",
":.+",
"v-text",
"v-text.+",
"v-html",
"v-html.+",
"class",
"v-on.+",
"#.+",
"name",
"data-.+",
"ng-.+",
"src",
"for",
"type",
"href",
"values",
"title",
"alt",
"role",
"aria-.+",
"$unknown$"
],
"gitlens.currentLine.enabled": false,
"gitlens.hovers.currentLine.over": "line",
"gitlens.codeLens.enabled": false,
"phpformatter.composer": true,
"phpformatter.pharPath": "php-cs-fixer",
"phpformatter.logging": true,
"laravel_goto_view.quickJump": true,
"laravel_goto_view.folderTip": true,
"git.enableSmartCommit": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true,
"bracketPairColorizer.highlightActiveScope": true