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

OmniSharp LSP Server does not auto import even if enableImportCompletion is true #2573

Open
AnhQuanTrl opened this issue Oct 6, 2023 · 0 comments

Comments

@AnhQuanTrl
Copy link

For some context, I am using OmniSharp Roslyn in conjunction with Neovim and LspConfig.
Here are my omnisharp.json:

{
  "FormattingOptions": {
    "EnableEditorConfigSupport": true,
    "OrganizeImports": true
  },
  "RoslynExtensionsOptions": {
    "enableImportCompletion": true,
    "enableAnalyzersSupport": false
  }
}

Here is my client completion capabilities:

completion = {
  completionItem = {
    commitCharactersSupport = true,
    deprecatedSupport = true,
    documentationFormat = { "markdown", "plaintext" },
    insertReplaceSupport = true,
    insertTextModeSupport = {
      valueSet = { 1, 2 }
    },
    labelDetailsSupport = true,
    preselectSupport = true,
    resolveSupport = {
      properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "text
Edit", "insertTextFormat", "insertTextMode" }
    },
    snippetSupport = true,
    tagSupport = {
      valueSet = { 1 }
    }
  },
  completionItemKind = {
    valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }
  },
  completionList = {
    itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }
  },
  contextSupport = true,
  dynamicRegistration = false,
  insertTextMode = 1
},

The client did advertise that it support additionalTextEdits which according to the LSP Specification must be specified.

Problem: When I tried to complete item with nvim-cmp, I check the log and indeed there is a textDocument/completion request and there is also a response. As such the editor still can complete the code but it does not auto import missing namespace if the class is not yet imported. Looking at the server response, I saw only textEdit in the response but no additionalTextEdits. For example, here is one of the CompletionItem returned:

 {      commitCharacters = { " ", "{", "}", "[", "]", "(", ")", ".", ",", ":", ";", "+", "-", "*", "/", "%", "&", "|", "^", "!", "~", "=", "<", ">", "?", "@", "#", "'", '"', "\\" },      data = {        ["$$__handler_id__$$"] = "2658541e-6e9d-4e48-804c-73397cf54e23",        Item1 = 11,        Item2 = 3985      },      detail = "NodaTime",      insertTextFormat = 1,      kind = 22,      label = "Instant",      sortText = "1~Instant NodaTime",      textEdit = {        newText = "Instant",        range = {          ["end"] = {            character = 12,            line = 13          },          start = {            character = 11,            line = 13          }        }      }    },

Every other features I tried so far works fine, including the Organize Import feature so it is probably not because of the client configuration. Thank you for taking your time to address this issue.

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