Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several issues with fzf-lua integration #478

Closed
asmodeus812 opened this issue May 1, 2023 · 5 comments
Closed

Several issues with fzf-lua integration #478

asmodeus812 opened this issue May 1, 2023 · 5 comments

Comments

@asmodeus812
Copy link

asmodeus812 commented May 1, 2023

LSP client configuration

Hi, wanted to share how great nvim-jdtls has been recently, but i have noticed that two issues have popped up recently i think are related to the de compilation of the class files with fzf-lua's default builtin previewer. One of the issues is related to missing / invalid window handle error when working with lsp_workspace_symbols the other one is related to lsp_document symbols. Below i have tried to explain the issues and referenced the issue in the fzf-lua repo to reproduce it. I suspect the issue has something to do with the way we handle the jdt:// resources in the current buffer but not well versed with jdtls to know exactly what is going on.

                        cmd =  {
        executable,
        "-Declipse.application=org.eclipse.jdt.ls.core.id1",
        "-Dosgi.bundles.defaultStartLevel=4",
        "-Declipse.product=org.eclipse.jdt.ls.core.product",
        "--add-modules=ALL-SYSTEM",
        "--add-opens",
        "java.base/java.util=ALL-UNNAMED",
        "--add-opens",
        "java.base/java.lang=ALL-UNNAMED",
        "--add-opens",
        "java.base/sun.nio.fs=ALL-UNNAMED",
        "-javaagent:" .. SERVER_BUNDLES[1],
        "-jar",
        SERVER_BUNDLES[2],
        "-configuration",
        CONFIG_BUNDLES[1],
        "-data",
        data },
            -- See: https:/eclipse/eclipse.jdt.ls#running-from-the-command-line for jdtls configuration
            filetypes = {
                "java"
            },
            init_options = {
                bundles = ext.get_pkg_bundles({
                    ["java-test"] = "extension/server/*",
                    ["java-debug-adapter"] = "extension/server/*",
                }),
            },
            -- See https:/eclipse/eclipse.jdt.ls/wiki/running-the-java-ls-server-from-the-command-line#initialize-request
            settings = {
                java = {
                    trace = {
                        server = "message",
                    },
                    autobuild = {
                        enabled = true
                    },
                    configuration = {
                        updateBuildConfiguration = "interactive",
                    },
                    contentProvider = {
                        preferred = "fernflower"
                    },
                    references = {
                        includeDecompiledSources = true,
                    },
                    signatureHelp = {
                        enabled = true,
                        description = {
                            enabled = true
                        }
                    },
                    referencesCodeLens = {
                        enabled = false,
                    },
                    implementationsCodeLens = {
                        enabled = false,
                    },
                    format = {
                        -- See https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml for code style
                        enabled = true,
                    },
                    saveActions = {
                        organizeImports = true
                    },
                    sources = {
                        organizeImports = {
                            starThreshold = 9999,
                            staticStarThreshold = 9999
                        }
                    },
                    favoriteStaticMembers = {
                        "org.junit.jupiter.api.DynamicTest.*",
                        "org.junit.jupiter.api.Assertions.*",
                        "org.junit.jupiter.api.Assumptions.*",
                        "org.junit.jupiter.api.DynamicContainer.*",
                        "org.junit.Assert.*",
                        "org.junit.Assume.*",
                        "java.util.Objects.*",
                        "org.mockito.ArgumentMatchers.*",
                        "org.mockito.Mockito.*",
                        "org.mockito.Answers.*",
                    },
                    filteredTypes = {
                        "java.awt.*",
                        "com.sun.*",
                        "jdk.*",
                        "sun.*",
                    },
                    completion = {
                        importOrder = {
                            "javax",
                            "java",
                            "com",
                            "org"
                        }
                    },
                    codeGeneration = {
                        tostring = {
                            skipNullValues = true,
                            listArrayContents = true,
                            template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
                        },
                        useBlocks = true,
                        hashCodeEquals = {
                            useInstanceof = true,
                            useJava7Objects = true
                        },
                        generateComments = false,
                        insertLocation = true
                    },
                    eclipse = {
                        downloadSources = true
                    },
                    maven = {
                        downloadSources = true,
                        updateSnapshots = true
                    },
                }
            },

Eclipse.jdt.ls version

1.22

Steps to Reproduce

lsp_workspace_symbols

  1. Open/browse lsp_workspace_symbols
  2. For query enter with empty string
  3. Start writing immediately, (e.g hashmap)
  4. Observe error with the preview window
Error executing vim.schedule lua callback: .../nvim/site/pack/packer/start/fzf-lua/lua/fzf-lua/win.lua:288: Invalid
 window id: 1007
stack traceback:
        [C]: in function 'nvim_win_set_option'
        .../nvim/site/pack/packer/start/fzf-lua/lua/fzf-lua/win.lua:288: in function 'reset_win_highlights'
        ...k/packer/start/fzf-lua/lua/fzf-lua/previewer/builtin.lua:272: in function 'populate_preview_buf'
        ...k/packer/start/fzf-lua/lua/fzf-lua/previewer/builtin.lua:286: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

lsp_document_symbols

  1. Open regular java file from your project
  2. Open in a v/split window, java.util.Hashmap
  3. Open lsp_document_symbols in HashMap
  4. Filter to a symbol, enter to move to it
  5. All other split windows get closed

NOTE: if instead of filtering, we select the first entry the other split windows are not getting closed, the
issue was discussed here ibhagwan/fzf-lua#728 (comment)

Expected Result

No issues from both use cases should be observed. I can confirm that other language servers do not exhibit this issue. Tagging @ibhagwan for reference.

Actual Result

Described above, but the basic gist - document_symbols fails to navigate to the selected symbol, workspace_symbols throws error with invalid window handle.

@mfussenegger
Copy link
Owner

mfussenegger commented Jun 22, 2023

I don't really see how this could be an jdtls issue.

All nvim-jdtls is define a BufReadCmd:

au BufReadCmd jdt://* lua require('jdtls').open_classfile(vim.fn.expand('<amatch>'))
au BufReadCmd *.class lua require("jdtls").open_classfile(vim.fn.expand("<amatch>"))

and open_classfile queries the language server for the content and adds it to the buffer.

If that doesn't work with fzf-lua, I assume it in general has problems with custom BufReadCmd autocmds.

@asmodeus812
Copy link
Author

asmodeus812 commented Jun 22, 2023

Indeed probably something to do with the way the class contents are populated or the view buffer is used, @ibhagwan and i talked about in the linked issue above, and that is why as he suggested i cross posted the issue, so we can take a look at what is going on, it is certainly an interaction between both, but i can't tell why either.

@mfussenegger
Copy link
Owner

Does the problem also reproduce with something like this:

api.nvim_create_autocmd("BufReadCmd", {
  pattern = "foo://*",
  callback = function()
    local bufnr =  api.nvim_get_current_buf()
    vim.bo[bufnr].modifiable = true
    vim.bo[bufnr].swapfile = false
    vim.bo[bufnr].buftype = 'nofile'
    api.nvim_buf_set_lines(bufnr, 0, -1, true, {"dummy", "content"})
    vim.bo[bufnr].modifiable = false
  end
})

And then opening foo://dummy?

@ibhagwan
Copy link

Unfortunately I am unable to attempt to fix this issue due to a startup crash of jdtls as described here
#459 (comment)

It seems I’m not the only one experiencing this, never used Java before just installed it in order to tackle this issue but can’t get any further. It’s worth mentioning that the same setup worked in the past, when first adding support for nvim-jdtls previews.

@ibhagwan
Copy link

After fixing my jdtls setup I believe was able to fix the issues described in the OP in ibhagwan/fzf-lua@9d9eea4.

@asmodeus812 try the latest commit and let me know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants