mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1.05k stars 61 forks source link

Correct completion starts on second char #480

Closed cshjsc closed 1 year ago

cshjsc commented 1 year ago

LSP client configuration

local opts = {
    cmd = {},
    settings = {
        java = {
            format = {
                settings = {
                    url = home .. "/work/config/format.xml",
                },
            },
            signatureHelp = { enabled = true },
            contentProvider = { preferred = 'fernflower' },
            completion = {
                enabled = true,
                guessMethodArguments = true,
            },
            sources = {
                organizeImports = {
                    starThreshold = 9999,
                    staticStarThreshold = 9999,
                },
            },
            codeGeneration = {
                toString = {
                    template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
                },
                useBlocks = true,
            },
            configuration = {
                runtimes = {
                    {
                        name = "JavaSE-17",
                        path = "/usr/lib/jvm/java-17-openjdk",
                    },
                    {
                        name = "JavaSE-11",
                        path = "/usr/lib/jvm/java-11-openjdk/",
                    },
                },
            },
        },
    },
}

Eclipse.jdt.ls version

1.23.0

Steps to Reproduce

Empty project using maven e.g:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>your-project-name</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>your-project-name</name>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

A simple class like this One

package com.example;
public class Another{
    private String another;
    private void something(){
        Another another = new Another();
       another.
    }
    public String getAnother() {
        return another;
    }
    public void setAnother(String another) {
        this.another = another;
    }
}

Expected Result

when I type another.se the setMethod should appear as a suggestion

Actual Result

equals(); appears as a suggestion which is not quite what I want. It just works when i type a character first, which will get appended after selecting the desired completion.

https://user-images.githubusercontent.com/47149574/236687434-b3e2be20-1e42-45a3-aac0-8e47649c799f.mp4

mfussenegger commented 1 year ago

This is probably an issue with your completion plugin. nvim-jdtls contains 0 logic in regards to completion. It's all stock neovim and eclipse.jdt.ls itself.