L-I-V / MQL-Tools

42 stars 15 forks source link

Brilliant Extension with One Frustration: Formatting #61

Open ananta-dev opened 2 months ago

ananta-dev commented 2 months ago

I love the MQL Tools extension, but being a software developer, I am used to prettier and other formatters. This is the only frustration I am having with MQL Tools. I cannot get the formatter to work.

Perhaps the problem is in my settings files.

This is the content of my .vscode > settings.json

{
    "C_Cpp.default.forcedInclude": [
        "c:\\Users\\juang\\.vscode\\extensions\\l-i-v.mql-tools-2.1.0\\data\\mql5_en.mqh"
    ],
    "C_Cpp.default.includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}/Include",
        "c:\\MT5\\Workshop-01\\MQL5\\Include\\Include"
    ],
    "C_Cpp.default.compilerPath": "",
    "C_Cpp.default.intelliSenseMode": "gcc-x64",
    "C_Cpp.errorSquiggles": "disabled",
    "C_Cpp.autocompleteAddParentheses": true,
    "files.exclude": {
        "**/*.ex4": true,
        "**/*.ex5": true,
        "**/*_@!!@.mq4": true,
        "**/*_@!!@.mq5": true,
        "**/*_@!!@.mqh": true
    },
    "files.associations": {
        "*.mqh": "cpp",
        "*.mq4": "cpp",
        "*.mq5": "cpp"
    },
    "C_Cpp.clang_format_style": "{ BasedOnStyle: Google, UseTab: Never, IndentWidth: 4, TabWidth: 4, ColumnLimit: 0}"
}

And this is, after many editions, currently the content of my main VS CODE settings file (C:\Users\\AppData\Roaming\Code\User\settings.json):

{
    "files.exclude": {
        "**/.git": false
    },
    "security.workspace.trust.untrustedFiles": "open",
    "python.defaultInterpreterPath": "",
    "python.terminal.activateEnvironment": false,
    "workbench.iconTheme": "material-icon-theme",
    "explorer.confirmDelete": false,
    "git.ignoreMissingGitWarning": true,
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "jupyter.askForKernelRestart": false,
    "workbench.colorTheme": "Ariake Dark",
    "editor.fontLigatures": true,
    "editor.fontFamily": "Consolas, 'Fira Code iScript', 'Courier New', monospace",
    "vscode_custom_css.policy": true,
    "vscode_custom_css.imports": ["file:///C:/vscode_files/styles.css"],
    "editor.tokenColorCustomizations": {
        "[Ariake Dark]": {
            "textMateRules": [
                {
                    "scope": ["comment"],
                    "settings": {
                        "foreground": "#BBBBBB"
                    }
                }
            ]
        }
    },
    "bracketPairColorizer.depreciation-notice": false,
    "workbench.startupEditor": "none",
    "liveServer.settings.donotShowInfoMsg": true,
    "git.ignoreWindowsGit27Warning": true,
    "editor.linkedEditing": true,
    "explorer.confirmDragAndDrop": false,
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[django-html]": {
        "editor.formatOnSave": false
    },
    "emmet.triggerExpansionOnTab": true,
    "files.associations": {
        "**/*.html": "html",
        "**/templates/*/*.html": "django-html",
        "**/templates/*": "django-html",
        "**/requirements{/**,*}.{txt,in}": "pip-requirements",
        "*.css": "tailwindcss",
        "*.mqh": "cpp",
        "*.mq4": "cpp",
        "*.mq5": "cpp"
    },
    "editor.quickSuggestions": {
        "strings": true
    },
    "emmet.showSuggestionsAsSnippets": true,
    "emmet.includeLanguages": {
        "javascript": "javascriptreact",
        "django-html": "html"
    },
    "beautify.language": {
        "html": ["htm", "html", "django-html"]
    },
    "workbench.editor.labelFormat": "short",
    "eslint.alwaysShowStatus": true,
    "explorer.compactFolders": false,
    "editor.formatOnPaste": false,
    "editor.formatOnSave": true,
    "quokka.showOutputOnStart": true,
    "prettier.arrowParens": "avoid",
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "files.autoSave": "onFocusChange",
    "xml.symbols.maxItemsComputed": 50000,
    "[xml]": {
        "editor.defaultFormatter": "DotJoshJohnson.xml"
    },
    "scm.inputFontSize": 14,
    "printcode.fontSize": 14,
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true,
        "editor.formatOnType": true
    },
    "black-formatter.args": ["--line-length", "120"],
    "python.formatting.blackArgs": ["--line-length", "120"],
    "[scss]": {
        "diffEditor.codeLens": true,
        "editor.bracketPairColorization.independentColorPoolPerBracketType": true
    },
    "files.eol": "\n",
    "prettier.singleQuote": true,
    "prettier.jsxSingleQuote": true,
    "prettier.semi": false,
    "prettier.tabWidth": 4,
    "eslint.options": {
        "rules": {
            "no-plusplus": "off"
        }
    },
    "liveServer.settings.fullReload": true,
    "lightrun.certificatePinningList": [
        "515a630cfd1fb908e30087bcc20b7413ad146b9bf2b23d3aaa72c28e45b24fb2",
        "ee80811b38e7e6c2dc4cc372cbea86bd86b446b012e427f2e19bf094afba5d12"
    ],
    "lightrun.serverURL": "https://app.lightrun.com",
    "lightrun.sendSourceFullPath": true,
    "quokka.automaticRestart": true,
    "scm.diffDecorations": "none",
    "reactSnippets.settings.importReactOnTop": false,
    "workbench.colorCustomizations": {
        "editor.background": "#000000",
        "sideBar.background": "#000000",
        "panel.background": "#000000",
        "activityBar.background": "#000000",
        "activityBar.foreground": "#FFFFFF",
        "activityBar.inactiveForeground": "#CCCCCC",
        "activityBar.border": "#CCCCCC",
        "editorBracketHighlight.foreground1": "#fafafa",
        "editorBracketHighlight.foreground2": "#9F51B6",
        "editorBracketHighlight.foreground3": "#F7C244",
        "editorBracketHighlight.foreground4": "#F07850",
        "editorBracketHighlight.foreground5": "#97c26c",
        "editorBracketHighlight.foreground6": "#C497D4",
        "editorBracketHighlight.unexpectedBracket.foreground": "#fb6165"
    },
    "editor.guides.bracketPairs": "active",
    "python.terminal.executeInFileDir": true,
    "gitlens.codeLens.enabled": false,
    "tailwind-fold.autoFold": false,
    "editor.wordWrap": "on",
    "editor.minimap.enabled": false,
    "genieai.openai.organization": "org-iPCMWe4O1UHt0HRJBAEdQ0OC",
    "extensions.ignoreRecommendations": true,
    "genieai.enableConversationHistory": true,
    "editor.inlineSuggest.suppressSuggestions": true,
    "mql_tools.Metaeditor.Metaeditor5Dir": "C:\\MT5\\Workshop-01\\MetaEditor64.exe",
    "mql_tools.Script.PortableMT5": true,
    "mql_tools.Metaeditor.Include5Dir": "C:\\MT5\\Workshop-01\\MQL5\\Include",
    "material-icon-theme.files.associations": {
        "*.ex4": "../../mql-tools-icons/material-icon-theme-custom-icons/ex4",
        "*.ex5": "../../mql-tools-icons/material-icon-theme-custom-icons/ex5",
        "*.mq4": "../../mql-tools-icons/material-icon-theme-custom-icons/mq4",
        "*.mq5": "../../mql-tools-icons/material-icon-theme-custom-icons/mq5",
        "*.mqh": "../../mql-tools-icons/material-icon-theme-custom-icons/mqh"
    },
    "vsicons.customIconFolderPath": "c:\\Users\\juang\\.vscode\\extensions\\mql-tools-icons",
    "vsicons.associations.files": [
        {
            "icon": "mq4",
            "extensions": ["mq4"],
            "format": "svg"
        },
        {
            "icon": "mq5",
            "extensions": ["mq5"],
            "format": "svg"
        },
        {
            "icon": "mqh",
            "extensions": ["mqh"],
            "format": "svg"
        },
        {
            "icon": "ex4",
            "extensions": ["ex4"],
            "format": "svg"
        },
        {
            "icon": "ex5",
            "extensions": ["ex5"],
            "format": "svg"
        }
    ],
    "[cpp]": {
        "editor.defaultFormatter": "L-I-V.mql-tools",
        "editor.formatOnSave": true
    }
}

I am sure I need to change something in the above files to get it to work, but I cannot find any documentation on how to do it.

pungggi commented 1 month ago

For me it works but does one thing that messes up everthing.. the color literals are formatted from C'29,60,118' to C '29,60,118' I dont know how to fix that

pungggi commented 1 month ago

@ananta-dev "editor.defaultFormatter": "ms-vscode.cpptools",

ananta-dev commented 1 month ago

Thank you @pungggi, but when I set it like this:

        "editor.defaultFormatter": "ms-vscode.cpptools",
        "editor.formatOnSave": true
    }

It messes several things up. Among them, the following two:

  1. if I have an sinput line followed by an input line like this:
sinput group "### AJUSTES MEDIA MÓVIL ###" 
input int PeriodoMA = 30;

When I format the input is moved up to the same line as the sinput:

sinput group "### AJUSTES MEDIA MÓVIL ###" input int PeriodoMA = 30;
  1. The date literals are broken as the formatter inserts a space:

This

    glTiempoBarraApertura = D'1971.01.01 00:00';

is transformed into this:

    glTiempoBarraApertura = D  '1971.01.01 00:00';

Have you been able to fix the issue?

aipungggi commented 1 month ago

at the moment I turn off formatting on those circumstances:

// clang-format off
glTiempoBarraApertura = D'1971.01.01 00:00';
// clang-format on
ananta-dev commented 1 month ago

I, too, have decided to turn formatting off. In my case, I am doing all MQL5 formatting manually.

It is a real pitty to have such as good extension without simple automatic formatting MQL5 working fine.