thqby / vscode-autohotkey2-lsp

Autohotkey v2 Language Support using vscode-lsp.
https://marketplace.visualstudio.com/items?itemName=thqby.vscode-autohotkey2-lsp
GNU Lesser General Public License v3.0
219 stars 21 forks source link

Auto-Indent issues, very frustrating, likely on my end #410

Closed samfisherirl closed 1 year ago

samfisherirl commented 1 year ago

Unsure all of the potential variable for indent to have issues.

No other extensions for ahk, only ahkv2lsp

I have enabled Editor onEdit formatting support.

Situation: When I write a function myfunction() I add the open Bracket { and press ENTER. The moment I press enter is where the issue occurs. All examples below will share where my CURSOR ends up, and how the page formats.

In a nut shell: I cant get the cursor and brackets to end where we all generally expect them to.

ideal

;cursor denoted by (~) 

myFunction(){
    ~
}

;or

myFunction()
{
    ~
}

broken formatting

Right now Im getting this:

myFunction(){
~}

when I add editorFormat settings it indents but doesnt linebreak after bracket

myFunction(){
    ~}

all cases require at least a few steps to return back to coding and arent a click away. makes me want to pull my hair out but its likely my fault. Here are my custom settings in vscode incase needed.

settings

ALL settings here with the name "bracket" or "indent" in the EXTENSION name have been REMOVED



{
    "tabnine.experimentalAutoImports": true,
    "ahk-simple-language-server.interpreterPath": "C:\\Program Files\\AutoHotkey\\v1.1.36.02\\AutoHotkeyA32.exe",
    "editor.fontSize": 21,
    "editor.fontWeight": "100",

    "editor.guides.bracketPairs": "active",
    "editor.language.colorizedBracketPairs": [],
    "BracketHighlighter.textColor": "#ff0096",
    "indentRainbow.excludedLanguages": [
        "autohotkey",
        "autohotkey2",
        "plaintext"
    ],
    "indentRainbow.lightIndicatorStyleLineWidth": 0.01,
    "indentRainbow.colors": [
      "rgba(3, 4, 94,0.15)",
      "rgba(2, 62, 138,0.15)",
      "rgba(0, 119, 182, 0.15)",
      "rgba(0, 150, 199,0.15)",
      "rgba(0, 180, 216,0.15)",
      "rgba(72, 202, 228,0.15)",
      "rgba(144, 224, 239,0.15)",
      "rgba(144, 224, 239,0.1)",
      "rgba(144, 224, 239,0.05)",
      "rgba(144, 224, 239,0.025)"
    ],
    "editor.wordWrap": "on",
      "bracket-pair-colorizer-2.activeScopeCSS": [
        "borderStyle : solid",
        "borderWidth : 1px",
        "borderColor : {color}",
        "opacity: 0.01"
    ],

    "files.associations": {
      "*.ahk": "ahk2",
      "*.py": "python",
      "*.html": "html"
    },
    "vscode-edge-devtools.webhint": false,
    "path-intellisense.autoSlashAfterDirectory": true,
    "AutoHotkey2.ActionWhenV1IsDetected": "Continue",

    "tabnine.receiveBetaChannelUpdates": true,
    "editor.bracketPairColorization.independentColorPoolPerBracketType": true,
    "BracketHighlighter.border": "1px white",
    "RainbowBrackets.rulerPosition": "Full",
    "editor.guides.bracketPairsHorizontal": true,
    "BracketHighlighter.outline": "1px yellow",
    "editor.wrappingIndent": "indent",
    "editor.accessibilitySupport": "off",
    "editor.lineHeight": 1.45,
    "BracketHighlighter.fontStyle": "1px white",
    "BracketHighlighter.regexMode": true,
    "BracketHighlighter.highlightScopeFromText": false,
    "BracketHighlighter.differentSymbolHighlightingUsed": false,
    "BracketHighlighter.borderSymbol": "1px white",
    "BracketHighlighter.textColorSymbol": "#ff007f",
    "BracketHighlighter.blurOpacity": "",
    "RainbowBrackets.depreciation-notice": false,
    "editor.lineNumbers": "on",
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "AutoHotkey2.AutoLibInclude": "All",
    "editor.hover.delay": 200,
    "workbench.hover.delay": 200,
    "workbench.sash.hoverDelay": 200,
    "BracketHighlighter.timeOutValue": 100,
    "editor.guides.highlightActiveIndentation": "always",
    "editor.tokenColorCustomizations": {
      "[*Light*]": {
        "textMateRules": [
          {
            "scope": "ref.matchtext",
            "settings": {
              "foreground": "#000"
            }
          }
        ]
      },
      "[*Dark*]": {
        "textMateRules": [
          {
            "scope": "ref.matchtext",
            "settings": {
              "foreground": "#fff"
            }
          }
        ]
      },
      "comments": "#5e5c5c",
      "textMateRules": [
        {
          "name": "Docstrings",
          "scope": "string.quoted.docstring",
          "settings": {
            "foreground": "#646464"
          }
        },
        {
          "name": "One Dark italic",
          "scope": [
            "comment",
            "entity.other.attribute-name",
            "keyword",
            "markup.underline.link",
            "storage.modifier",
            "storage.type",
            "string.url",
            "variable.language.super",
            "variable.language.this"
          ],
          "settings": {
            "fontStyle": "italic"
          }
        },
        {
          "name": "One Dark italic reset",
          "scope": [
            "keyword.operator",
            "keyword.other.type",
            "storage.modifier.import",
            "storage.modifier.package",
            "storage.type.built-in",
            "storage.type.function.arrow",
            "storage.type.generic",
            "storage.type.java",
            "storage.type.primitive"
          ],
          "settings": {
            "fontStyle": ""
          }
        }
      ]
    },
    "editor.matchBrackets": "never",
    "editor.renderWhitespace": "none",
    "zenMode.restore": false,
    "editor.codeActionsOnSave": {

    }, 

    "workbench.colorCustomizations": {
    "editor.background": "#131313" // Replace "#000000" with your preferred background color code
    },
    "AutoHotkey2.InterpreterPath": "C:\\Program Files\\AutoHotkey\\v2\\AutoHotkey64.exe",
    "[ahk2]": {

      "editor.defaultFormatter": "thqby.vscode-autohotkey2-lsp",
      "editor.quickSuggestions": {
        "other": true,
        "comments": false,
        "strings": true
      }
    },
    "subtleBrackets.pairs": [

      {
        "open": "(",
        "close": ")"
      },
      {
        "open": "[",
        "close": "]"
      },
      {
        "open": "{",
        "close": "}"
      }
    ],
    "subtleBrackets.style": {

      "borderWidth": "thin",
      "borderStyle": "solid",
      "borderColor": "rgba(128, 128, 128, 0.8)"
    },
    "ahk++.file.executePath": "C:\\Program Files\\AutoHotkey\\v1.1.37.01\\AutoHotkeyU64.exe",
    "workbench.iconTheme": "Monokai Pro Icons",
    "[javascript]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "terminal.integrated.fontSize": 12,
    "notebook.output.fontSize": 1,
    "notebook.output.textLineLimit": 11,
    "notebook.markup.fontSize": 3,
    "[css]": {
      "editor.defaultFormatter": "vscode.css-language-features"
    },
    "[json]": {
      "editor.defaultFormatter": "numso.prettier-standard-vscode"
    },
    "chatgpt.lang": "en",
    "workbench.editor.enablePreview": false,
      "explorer.sortOrder": "modified",
    "explorer.sortOrderUser": "modified",

    "workbench.colorTheme": "Community Material Theme Darker High Contrast",
    "window.zoomLevel": 1,
    "editor.mouseWheelScrollSensitivity": 3,
    "editor.foldingHighlight": false,
    "python.analysis.autoImportCompletions": true,
    "ahk++.file.interpreterPathV2": "C:/Program Files/AutoHotkey/v1.1.37.01/AutoHotkey64.exe",
    "github.copilot.enable": {
      "*": true,
      "plaintext": true,
      "markdown": false,
      "scminput": false
    },
    "vsintellicode.java.completionsEnabled": false,
    "editor.acceptSuggestionOnEnter": "smart",
    "editor.quickSuggestionsDelay": 200,
    "editor.suggest.preview": true,
    "editor.suggest.selectionMode": "whenQuickSuggestion",
    "vsintellicode.modify.editor.suggestSelection": "disabled",
    "vsintellicode.typescript.completionsEnabled": false,
    "explorer.confirmDragAndDrop": false,
    "editor.language.brackets": [

    ],
    "python.venvPath": "~/venv",
    "inlineFold.regex": ".*(\"\"\").*$",
    "inlineFold.supportedLanguages": [
      "astro",
      "vue",
      "html",
      "svelte",
      "vue-html",
      "php",
      "blade",
      "erb",
      "twig",
      "nunjucks",
      "django-html",
      "jinja-html",
      "javascript",
      "typescript",
      "javascriptreact",
      "typescriptreact",
      "python"
    ],
    "python.testing.pytestEnabled": true,
    "terminal.integrated.env.windows": {

    },
    "local-history.daysLimit": 12,
    "pythonIndent.keepHangingBracketOnLine": true,
    "AutoHotkey2.Warn.CallWithoutParentheses": true,
    "ahk++.formatter.allowedNumberOfEmptyLines": -1,
    "ahk++.formatter.trimExtraSpaces": false,
    "ahk++.intellisense.maximumParseLength": 0,
    "github.copilot-labs.advanced": {

    },
    "editor.autoIndent": "advanced",
    "[yaml]": {
      "editor.autoIndent": "brackets"
    },
    "[dockercompose]": {
      "editor.autoIndent": "brackets"
    },
    "editor.formatOnType": true,
    "editor.formatOnPaste": true,
    "ahk++.formatter.preserveIndent": true,
    "AutoHotkey2.CompleteFunctionParens": true,
    "editor.indentSize": "tabSize"
}```
samfisherirl commented 1 year ago

update: I've tested on a new install, it appears some setting is conflicting. Unsure what it is,

thqby commented 1 year ago

https://github.com/thqby/vscode-autohotkey2-lsp#codeformat set editor.formatOnType and brace_style property of AutoHotkey2.FormatOptions.

GroggyOtter commented 1 year ago

Try adding editor.autoIndent to your settings. These are some of my ahk2 settings:

"[ahk2]":
{
    // Aligns cursor with if statment when enter is pressed
    "editor.autoIndent": "brackets",
    // Always search/replace in a selection if one is made
    "editor.find.autoFindInSelection": "always",
    // Prevents closing brace while in strings (usually)
    "editor.autoClosingBrackets": "beforeWhitespace",
    // Prevents second quotation mark while in strings (usually)
    "editor.autoClosingQuotes": "beforeWhitespace"
},
thqby commented 1 year ago

editor.autoIndent only takes effect on indentationRules defined in the ahk2.configuration.json file, but there are limitations.

wilkster commented 1 year ago

Assuming you have the auto-closing Bracket enabled (and the cursor is in between them after entering {, i.e. {|}, try using Shift-Enter to split the line. It should move your cursor down and indent it with the bracket on the third line. If not, it may be some other setting.