Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the auto indent setting. #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,21 @@
"configuration": {
"title": "Split HTML Attributes",
"properties": {
"splitHTMLAttributes.tabSize": {
"type": "number",
"default": 2,
"description": "Number of spaces for indentation.",
"scope": "resource"
},
"splitHTMLAttributes.useSpacesForTabs": {
"type": "boolean",
"default": true,
"description": "Use spaces for tabs.",
"splitHTMLAttributes.indentType": {
"type": "string",
"default": "Auto",
"enum": [
"Auto",
"Tab",
"Spaces 0",
"Spaces 1",
"Spaces 2",
"Spaces 3",
"Spaces 4",
"Spaces 5",
"Spaces 6"
],
"description": "What indents to use.",
"scope": "resource"
},
"splitHTMLAttributes.closingBracketOnNewLine": {
Expand Down
15 changes: 13 additions & 2 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@ function activate(context) {

// get config
let config = vscode.workspace.getConfiguration('splitHTMLAttributes', editor.document.uri)
let tabSize = config.get("tabSize")
let useSpacesForTabs = config.get("useSpacesForTabs")
let closingBracketOnNewLine = config.get("closingBracketOnNewLine")
let sortOrder = config.get("sortOrder")

// get indent options
let tabSize, useSpacesForTabs, indentType = config.get("indentType");
if (indentType.toLowerCase() === "auto") {
tabSize = editor.options.tabSize
useSpacesForTabs = editor.options.insertSpaces
} else if (indentType.toLowerCase() === "tab") {
tabSize = 1;
useSpacesForTabs = false;
} else {
tabSize = parseInt(indentType);
useSpacesForTabs = true;
}

// get document & selection
const document = editor.document
Expand Down