Closed kohane27 closed 2 years ago
@kohane27 provide some react code that can reproduce will be useful
Hello @glepnir
Thank you for looking into this issue. I appreciate it.
What's strange is that other commands (Lspsaga code_action
, Lspsaga hover_doc
) work. Only Lspsaga preview_definition
doesn't work.
npx create-react-app my-typescript-app --typescript
my-typescript-app
npm start
index.js
import reportWebVitals from './reportWebVitals';
) and put cursor to reportWebVitals
:Lspsaga preview_definition
As you can see, the command Lspsaga preview_definition
doesn't result in anything. But gd
works to jump to definition.
Thank you again!
maybe that's mean there is no response from server . test it later
if you use typescript in react .I don't think there can have a index.js file
Hello @glepnir . I tested again on a lua file and it's working! js/ts is a hit or miss however. Not sure why but I guess it's nothing to do with lspsaga. Thanks again!
hmm you can test the lua vim.lsp.buf.definition()
in that file . if this work then lspsaga definition still have some bug in that file. also you cancheck the lspsaga lsp_finder
it also show definition
@glepnir
Thank you for getting back to me. I appreciate it.
As you can see, lua vim.lsp.buf.definition()
work but Lspsaga preview_definition
doesn't. Is there any suggestion as how I could debug this?
I'm on nvim v0.7.2 so I can't use and test lsp_finder
.
lsp_finder work on 0.7 . preview definition works on my local
@glepnir
Lspsaga lsp_finder
works perfeclty but Lspsaga preview_definition
still doesn't.
when you press command it show a diagnostic window? this window not belong the lspsaga
The hover window is from the following code:
vim.cmd([[
" show line diagnostics automatically in hover window
autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, { focus = false })
]])
I commented it out and tested again:
Given it works on the lua file I suspect it's js/jsx related. Thank you anyway!
which server typescript-language-server
? I had test in 0.7 preview definition works fine.
Lspsaga preview_definition doesn't work for me on React files. I'm using neovim 0.7.2.
I will add a message in preview definition then you can report it in there. I can't reproduce this issue on my local .so need more useful information Thanks . reopen.
Thanks for reopening it. I'll report more info when I can.
I had add a notify in preview definition so you can try it and if there has messages post it in there.
Great news! With the log I figured it out.
It's the LSP attach order:
Once I change the order to attach tsserver
first, preview_definition
is working:
Client: tsserver (id: 2, pid: 193872, bufnr: [14, 13, 20])
filetypes: javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx
autostart: true
root directory: /home/username/my-app
cmd: typescript-language-server --stdio
Client: cssmodules_ls (id: 3, pid: 193873, bufnr: [14, 13, 20])
filetypes: javascript, javascriptreact, typescript, typescriptreact
autostart: true
root directory: /home/username/my-app
cmd: cssmodules-language-server
Thank you again!
Okay found problem because there has multiple servers that both support definition
method . fix it later
Confirmed it's working even with the following lsp attached order:
Client: cssmodules_ls (id: 3, pid: 193873, bufnr: [14, 13, 20])
filetypes: javascript, javascriptreact, typescript, typescriptreact
autostart: true
root directory: /home/username/my-app
cmd: cssmodules-language-server
Client: tsserver (id: 2, pid: 193872, bufnr: [14, 13, 20])
filetypes: javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx
autostart: true
root directory: /home/username/my-app
cmd: typescript-language-server --stdio
Thank you!
Hello there. Hope you're doing well.
https://user-images.githubusercontent.com/57322459/185334799-642e61b7-0c05-4d86-b4a2-e923347263f9.mp4
To reproduce:
gd
to make sure I can jump to definitionLspsaga preview_definition
Environment
Operating system: Linux lspsaga commit: eec313a
Any input is much appreciated. Thank you:)