hrsh7th / nvim-compe

Auto completion Lua plugin for nvim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swift methods are only partially completed using Sourcekit-lsp

Tylerc230 opened this issue · comments

Checkhealth

Put result of :checkhealth compe.

health#compe#check
========================================================================
## compe:snippet
  - INFO: snippet engine is not detected.

## compe:mapping
  - INFO: `compe#complete` is not mapped
  - INFO: `compe#confirm` is not mapped
  - INFO: `compe#close` is not mapped
  - INFO: `compe#scroll` is not mapped

Describe the bug

I've noticed that when using sourcekit-lsp, when I try to complete a method with signature func aMethod(param1: Int, param2: Int) -> Int { it only inserts aMethod. It would be nice if it inserted aMethod(param1: , param2: ).
I've narrowed down the issue to Helper.convert_lsp. It seems that these lines trim off the parameters:

  local leading = string.sub(context.before_line, keyword_pattern_offset, args.keyword_pattern_offset - 1)
  for _, completion_items in ipairs(completion_items) do
    completion_items.word = String.get_word(completion_items.word, leading)
  end

When I remove these lines, the completion works as expected.

To Reproduce

Steps to reproduce the behavior with the minimal config:

  1. Install https://github.com/apple/sourcekit-lsp
  2. Put the following swift code in a buffer and open the completion menu
struct MyStruct {
    func aMethod(param1: Int, param2: Int) -> Int {
        return 1
    }
}
let mystruct = MyStruct(aThing:2)
mystruct.<open autocomplete here>

Actual behavior

aMethod(param1: Int, param2: Int) is shown in the menu, but pressing inserts aMethod into the buffer.

Expected behavior

On pressing enter, aMethod(param1:, param2:) should be inserted.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.