Move to new file not working using FZF Lua
"Move to new file" not working with typescript-tools and FZF Lua Code actions.
require("typescript-tools").setup {
settings = {
tsserver_logs = "verbose",
code_lens_mode = "all",
tsserver_file_preferences = {
includeCompletionsForModuleExports = true,
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
importModuleSpecifierPreference = "non-relative",
quotePreference = "auto"
},
separate_diagnostic_server = true,
publish_diagnostic_on = "insert_leave",
expose_as_code_action = "all",
tsserver_max_memory = "auto",
complete_function_calls = true,
jsx_close_tag = {
enable = true,
filetypes = {"javascriptreact", "typescriptreact"}
}
}
"Move to new file" is working with lspconfig and FZF Lua
lspconfig["tsserver"].setup({})
This is a similar issue https://github.com/ibhagwan/fzf-lua/issues/1007
To reproduce the issue with typescript-tools
require("fzf-lua").lsp_code_actions {
previewer = true,
winopts = {
width = 0.5,
height = 0.5,
preview = {horizontal = "down:50%", horizontal = "right:50%"}
}
}
The issue can be resolved by disabling the previewer
require("fzf-lua").lsp_code_actions {
previewer = false,
winopts = {
width = 0.5,
height = 0.5,
}
}
Please see comment
I use telescope so I previously didn't bump into this problem. I'll look into it
Maybe this is related too did not know where to properly report it ... https://github.com/ibhagwan/fzf-lua/issues/949 https://github.com/ibhagwan/fzf-lua/issues/949#issuecomment-1972838951
I believe this https://github.com/ibhagwan/fzf-lua/issues/949#issuecomment-1973624200 from @ibhagwan about related issue would be useful here:
In order to display the diff for the code action preview, if the action doesn't contain the workspace edit section,
fzf-luawill send acodeAction/resolverequest to the LSP server, the first call works (as you found out) but any subsequent call is bugged (and returnsnil) withtypescript-tools.nvim. Iffzf-luasends a synchrounous request with:
:FzfLua lsp_code_actions previewer=codeaction_native
typescript-tools.nvimreturns a nil action, with the latest commit,fzf-luawill fallback to the original unresolved action and display this message (no error but also no diff):
If using the neovim builtin (non-native) previewer,
fzf-luawill send an async LSP request and waits for a callback which never returns, e.g.:
:FzfLua lsp_code_actions previewer=codeaction
Resulting in:
Originally posted by @ibhagwan in https://github.com/ibhagwan/fzf-lua/issues/949#issuecomment-1973624200
I use telescope so I previously didn't bump into this problem. I'll look into it
@pmizio, the reason you didn’t bump into is probably because this requires using code action previews, I believe Telescope doesn’t come builtin with code action previews unless you’re using: https://github.com/aznhe21/actions-preview.nvim
Based on my testing this issue only happens after sending a codeAction/resolve request which doesn’t get called unless you’re using fzf-lua with preview or the above Telescope extension.
Oh and @marcoSven, I’m pretty sure the "Move to new file" will work if you disable the code actions previewer by setting lsp.code_actions.previewer=false at setup.
@ibhagwan yes that is what I did, without preview "Move to new file" is working.