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

Java: Get documentation in preview window #684

Open
mb720 opened this issue Feb 20, 2025 · 0 comments
Open

Java: Get documentation in preview window #684

mb720 opened this issue Feb 20, 2025 · 0 comments

Comments

@mb720
Copy link

mb720 commented Feb 20, 2025

Hi and thanks a lot for Coq!

I'm trying to display Java documentation when in in Coq's autocompletion. I'm using nvim-jdtls to connect to the LSP server.

While in autocompletion, I get signature information but no documentation:

Coq showing signature information

Mind that documentation is available using hover:

Showing documentation via hover in nvim-jdtls

What I'd like to have is this, either automatically or when pressing a key combination while in Coq's autocompletion:

Documentation in nvim-cmp's autocompletion


This is my init.lua:

-- Default is "~/.config/nvim/", can be changed with $XDG_CONFIG_HOME or NVIM_APPNAME
local config_dir = vim.fn.stdpath("config")

local vim_plug_file = config_dir .. "/autoload/plug.vim"

function file_exists(name)
  local f = io.open(name, "r")
  return f ~= nil and io.close(f)
end

-- Install vim-plug if it doesn't exist
if not file_exists(vim_plug_file) then
    local vim_plug_url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
    vim.fn.system({ "curl", "-fLo", vim_plug_file, "--create-dirs", vim_plug_url })

    vim.api.nvim_create_autocmd("VimEnter", {
        callback = function()
            vim.cmd("PlugInstall")
        end,
    })
end

local vim = vim
local Plug = vim.fn['plug#']
vim.call('plug#begin')
Plug('https://github.com/mfussenegger/nvim-jdtls')
Plug('https://github.com/ms-jpq/coq_nvim')
vim.call('plug#end')

This is ftplugin/java.lua:

local jdtls = require('jdtls')

local coq = require('coq')

local config = {
  cmd = {'/usr/bin/jdtls'},
  root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'mvnw', "README.md"}, { upward = true })[1]),
  capabilities = coq.lsp_ensure_capabilities(),
  settings = {
    java = {
      signatureHelp = {enabled = true}, contentProvider = {preferred = 'fernflower'},
      }
    }
}

jdtls.start_or_attach(config)
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

1 participant