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

Add code action to generate doc comments #91

Closed
minhduc0711 opened this issue Jun 2, 2021 · 9 comments
Closed

Add code action to generate doc comments #91

minhduc0711 opened this issue Jun 2, 2021 · 9 comments

Comments

@minhduc0711
Copy link

Hi, is it possible to add a code action for generating Java doc comments like this?

image

@mfussenegger
Copy link
Owner

See #76 - it is possible via snippet. There is no dedicated code action for it as far as I'm aware.

@minhduc0711
Copy link
Author

Ah sorry for not catching that issue. The auto-indent does not work for me for some reason though...
image

@mfussenegger
Copy link
Owner

Could be that the indentation settings of the editor weren't picked up because of a missing didChangeConfiguration.

Could you try again with #92 being merged?

@minhduc0711
Copy link
Author

Hmm #92 does not seem to fix it.

@mfussenegger
Copy link
Owner

Which eclipse.jdt.ls version are you using? eclipse-jdtls/eclipse.jdt.ls#1657 is required for it to pick up indentation/tab settings.

@minhduc0711
Copy link
Author

I'm using jdtls-1.1.2-1, the latest one I think.

@mfussenegger
Copy link
Owner

You could try setting the format options explicitly in your config:

local config = {
  settings = {
    java = {
      format = {
        insertSpaces = vim.api.nvim_buf_get_option(bufnr, 'expandtab'),
        tabSize = vim.lsp.util.get_effective_tabstop(bufnr)
      }
    }
  }
}

These options are automatically added by nvim-jdtls if they are absent. Not sure why it isn't working for you.

Maybe your neovim expandtab/tabstop settings don't match the indentation style of your java file?

@minhduc0711
Copy link
Author

When I hit TAB, indentation is correct so I guess the neovim settings are fine.

The explicit config does not fix it still. Am I doing this correctly?

local config = {
  cmd = {'java-lsp', workspace_folder},
  settings = {
    java = {
      format = {
        insertSpaces = vim.api.nvim_buf_get_option(bufnr, 'expandtab'),
        tabSize = vim.lsp.util.get_effective_tabstop(bufnr)
      }
    }
  }
}
require('jdtls').start_or_attach(config)

@lidulibai
Copy link
Contributor

Try setting the snippetSupport option after settings in your config:

local config = {
  settings = {
    java = {...}
  },
  capabilities = {
    textDocument = {
      completion = {
        completionItem = {
          snippetSupport = true
        }
      },
    },

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