stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.69k stars 83 forks source link

next() and next_up() do not jump to the next tag in the vue file #183

Closed Wjinlei closed 1 year ago

Wjinlei commented 1 year ago

Describe the bug

I'm not sure if it's a bug, but it's really weird next() and next_up() do not jump to the next tag in the vue file, prev() and prev_up() are fine,

System information



**To Reproduce**
Steps to reproduce the behavior:
1. open .vue file
2. invoke aerial.next() or aerial.next_up()
stevearc commented 1 year ago

That certainly sounds like a bug. Could you provide a minimal sample file that exhibits this problem?

Also, I assume that you're using vuels as your language server?

Wjinlei commented 1 year ago

@stevearc Configuration file as above, I bind the key is

vim.keymap.set("n", "<C-m>", "<cmd>AerialToggle!<CR>", { buffer = bufnr })
vim.keymap.set("n", "<C-k>", "<cmd>lua require('aerial').prev()<CR>", { buffer = bufnr })
vim.keymap.set("n", "<C-j>", "<cmd>lua require('aerial').next()<CR>", { buffer = bufnr })

Here's a demo Peek 2022-11-16 09-40

As you can see, when I press Ctrl+k, everything works fine, but when I press Ctrl+j, it doesn't seem to work.

The lsp server I use is volar lsp

stevearc commented 1 year ago

I meant can you provide a minimal .vue file. I don't use vue or volar and it will be easier for me to repro this if I don't have to first figure out how to set up a vue project. Also there will be fewer differences between our two setups when I test it.

Wjinlei commented 1 year ago

@stevearc This is a demo vue file

<template>
  <h1>Hello {{ world }}</h1>
</template>

<script>
export default {
  name: 'Demo',
  data() {
    return {
      world: 'vue'
    }
  }
}
</script>
Wjinlei commented 1 year ago

@stevearc Here's another one

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello World</title>
    <script src="https://unpkg.com/vue@3.2.31/dist/vue.global.js"></script> <!-- 引入Vue3 -->
</head>

<body>
    <div id="app">
        <h1>Hello {{ lanuage }}</h1>
    </div>
</body>

<script>
    const app = Vue.createApp({
        data() {
            return {
                lanuage: "Vue"
            }
        }
    })
    const vm = app.mount("#app")
</script>

</html>
stevearc commented 1 year ago

Ugh, as expected this is because volar is giving...if not incorrect symbol ranges, then at least surprising ones. The starting column of the symbols is off the end of the line, which means that it's impossible for us to ever be exactly on that symbol and that generally creates issues (navigation being the most obvious).

I've added a hack that should work around this, but the real solution is for the language server to produce correct symbol positions. I've reported this upstream https://github.com/johnsoncodehk/volar/issues/2118

Wjinlei commented 1 year ago

@stevearc Thank you, it's working fine now, hopefully upstream can fix it too