Skip to content

Indentation of Script Tags VUE_LS #5740

@Jojerames

Description

@Jojerames

Vue - Official extension or vue-tsc version

vue-language-server 3.1.3

VSCode version

NeoVim 0.11.4

Vue version

3.5.22

TypeScript version

14.6.0

System Info

System:
    OS: Linux 6.17 Arch Linux
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-13620H
    Memory: 9.53 GB / 15.24 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 25.1.0 - /usr/bin/node
    npm: 11.6.2 - /usr/bin/npm
    bun: 1.3.1 - /home/mia/.bun/bin/bun
  Browsers:
    Brave Browser: 141.1.83.118
    Chromium: 142.0.7444.59
    Firefox: 144.0.2
    Firefox Developer Edition: 144.0.2

package.json dependencies

"dependencies": {
    "sass": "^1.93.3",
    "vue": "^3.5.22",
    "vue-router": "^4.6.3"
  },
  "devDependencies": {
    "@tsconfig/node22": "^22.0.2",
    "@types/node": "^22.18.11",
    "@vitejs/plugin-vue": "^6.0.1",
    "@vue/eslint-config-prettier": "^10.2.0",
    "@vue/eslint-config-typescript": "^14.6.0",
    "@vue/tsconfig": "^0.8.1",
    "eslint": "^9.37.0",
    "eslint-plugin-vue": "~10.5.0",
    "jiti": "^2.6.1",
    "npm-run-all2": "^8.0.4",
    "prettier": "3.6.2",
    "typescript": "~5.9.0",
    "vite": "^7.1.11",
    "vite-plugin-vue-devtools": "^8.0.3",
    "vue-tsc": "^3.1.1"
  }

Steps to reproduce

Create a vue file with a script tag at the top;
The script tag should have attributes: 'setup' and 'lang="ts"'
The attributes should be on the same line as the opening tag like so

<script setup lang="ts">
    function helloWorld() {
        console.log("Hello, world!");
    }
<script>

This issue does NOT occur when the opening tag is split across multiple lines like so

<script
    setup
    lang="ts">
    function helloWorld() {
        console.log("Hello, world!");
    }
</script>

What is expected?

The expected behavior is that lines will be automatically indented when expected ( after "{", etc. ).
It is also expected for the "=" key to set the selected line to it's proper indentation based off of the context.

What is actually happening?

What is really happening is on any new line create, the indent is set to that of the previously selected line. This is the fallback behavior of neovim. Indentation works properly when the opening script tag is split into multiple lines as shown earlier in this bug report. I believe (but may be wrong) that the reason for this is that vue_ls does not provide it's own indentation specification. Setting "indentexpr" to "VueIndent()" or "GetVueIndent()" seeems to make all indenting fallback to the aformentioned fallback. By default "indentexpr" is set to "HtmlIndent()".

Link to minimal reproduction

https://github.com/Jojerames/VueBugReport/

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions