Skip to content

Add instructions #2

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

Closed
bedware opened this issue Oct 17, 2023 · 3 comments
Closed

Add instructions #2

bedware opened this issue Oct 17, 2023 · 3 comments

Comments

@bedware
Copy link

bedware commented Oct 17, 2023

Can you provide how to install and how to use your extension?

@JavaHello
Copy link
Owner

The current plugin is not yet complete, only ensuring that it opens without errors.

I've added the instructions to the Readme.

  • lazy.nvim
{
    "JavaHello/java-deps.nvim",
    lazy = true,
    ft = "java",
    dependencies = "mfussenegger/nvim-jdtls",
    config = function()
      require("java-deps").setup({})
    end,
  }

-- jdtls lsp attach
require("java-deps").attach(client, buffer, root_dir)

@bedware
Copy link
Author

bedware commented Oct 17, 2023

Yes, I see - plugin is not so useful at the moment (mostly because of some inconsistencies in tree structure). But it's a great beginning! I can assume you know that most of Java developers like and use that feature in other IDE. So keep on going!

This is valid config for packer:

    use('mfussenegger/nvim-jdtls')
    use({
        'JavaHello/java-deps.nvim',
        requires = {
            {'mfussenegger/nvim-jdtls'},
            {'simrat39/symbols-outline.nvim'}
        },
        config = function() require('java-deps').setup({}) end
    })
    use({
        'simrat39/symbols-outline.nvim',
        config = function() require('symbols-outline').setup() end
    })

Some modifications I made to my jdtls config to start it working.

I use Mason, but it doesn't have needed bundles, so you have to manually clone a repo and build it.
After that you can add it bundles like this:

local home = vim.fn.getenv("HOME")

local java_dependency_bundle = vim.split(
        vim.fn.glob(home .. '/.local/share/nvim/mason/packages/vscode-java-dependency/jdtls.ext/com.microsoft.jdtls.ext.core/target/com.microso
ft.jdtls.ext.core-*.jar'),
        '\n'
)

if java_dependency_bundle[1] ~= '' then
       vim.list_extend(path.bundles, java_dependency_bundle)
end

Lastly you need to add plugin logic on every attach:

local function jdtls_on_attach(client, bufnr)
    local root_dir = require('jdtls').setup.find_root(root_files)
    require("java-deps").attach(client, bufnr, root_dir)

To use plugin I found several commands:

:lua require('java-deps').toggle_outline()
:lua require('java-deps').open_outline()
:lua require('java-deps').close_outline()

If there is nothing wrong here, please add this to the plugin description. I just want more people use your plugin. After that I will close this thread.

@JavaHello
Copy link
Owner

Thank you for the steps you provided, it is correct, I added it to the Readme
#4

@bedware bedware closed this as completed Oct 18, 2023
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

2 participants