Using goto definition in a .vue file makes multiple calls
My lspconfig: https://github.com/catgoose/nvim/blob/4a81fde7ff8ee086416e5c06121e41c182bb7e19/lua/plugins/lspconfig.lua#L152-L171
In neovim (and other IDE I would assume) when calling vim.lsp.buf.definition on a symbol in a .vue file that is imported from a typescript file results in calls being made from both tsserver and the @vue/typescript-plugin LSP
For example:
<script setup lang="ts">
import { useCounterStore } from './stores/counter'
const store = useCounterStore()
</script>
<template>
<div></div>
</template>
When calling vim.lsp.buf.definition on useCounterStore and overriding the on_list functionality:
vim.lsp.buf.definition({on_list = function(list) vim.print(list) end})
results in the following tables being printed:
{
items = { {
col = 5,
filename = "/home/cg/src/vue/lsp-testing/node_modules/pinia/dist/pinia.d.ts",
lnum = 639,
text = " (pinia?: Pinia | null | undefined, hot?: StoreGeneric): Store<Id, S, G, A>;\r",
user_data = {
originSelectionRange = {
["end"] = {
character = 29,
line = 3
},
start = {
character = 14,
line = 3
}
},
targetRange = {
["end"] = {
character = 79,
line = 638
},
start = {
character = 4,
line = 638
}
},
targetSelectionRange = {
["end"] = {
character = 79,
line = 638
},
start = {
character = 4,
line = 638
}
},
targetUri = "file:///home/cg/src/vue/lsp-testing/node_modules/pinia/dist/pinia.d.ts"
}
}, {
col = 14,
filename = "/home/cg/src/vue/lsp-testing/src/stores/counter.ts",
lnum = 4,
text = "export const useCounterStore = defineStore('counter', () => {",
user_data = {
originSelectionRange = {
originSelectionRange = {
["end"] = {
character = 29,
line = 3
},
start = {
character = 14,
line = 3
}
},
targetRange = {
["end"] = {
character = 2,
line = 11
},
start = {
character = 0,
line = 3
}
},
targetSelectionRange = {
["end"] = {
character = 28,
line = 3
},
start = {
character = 13,
line = 3
}
},
targetUri = "file:///home/cg/src/vue/lsp-testing/src/stores/counter.ts"
}
} },
title = "LSP locations"
}
{
items = { {
col = 10,
filename = "/home/cg/src/vue/lsp-testing/src/App.vue",
lnum = 2,
text = "import { useCounterStore } from './stores/counter'",
user_data = {
range = {
["end"] = {
character = 24,
line = 1
},
start = {
character = 9,
line = 1
}
},
uri = "file:///home/cg/src/vue/lsp-testing/src/App.vue"
}
} },
title = "LSP locations"
}
I believe the first table is from tsserver while the second is from @vue/typescript-plugin.
Also if you run
:lua vim.lsp.buf.definition({on_list = function(list) vim.print(list) end})
the resultant output is:
called
called
If we were still using takeover mode, this would not be an issue, but would it even be possible to disable tsserver goto definition in .vue files and still be able to use @vue/typescript-plugin?
I think this happens on every interaction with lsp on vue files. Rename asks twice to handle renaming, references etc. vim.lsp.buf.references displays No references found message and then displays references.
I think this happens on every interaction with lsp on vue files. Rename asks twice to handle renaming, references etc.
vim.lsp.buf.referencesdisplaysNo references foundmessage and then displays references.![]()
Yeah I actually wrote a plug-in to make this work better:
https://github.com/catgoose/vue-goto-definition.nvim
I might try to implement some fix for the LSP rename because it really does not work well.
Closed because Hybrid Mode is mandatory after version 3.0. See #5456.