roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

TODO: translate lsp snippet into local snippet format, and support completion textedit #130

Open roxma opened 7 years ago

roxma commented 7 years ago

As per https://github.com/autozimu/LanguageClient-neovim/pull/121

Current vim snippet plugin's snippet syntax is different from lsp snippet.

NCM will use the well-defined lsp snippet syntax as the standard, and transform it into local snippet format.

The completion textedit should be useful for completion with auto importing, I guess. Yet I haven't seen a language server with this capability.

euclio commented 6 years ago

FWIW, the Java language server (https://github.com/eclipse/eclipse.jdt.ls) utilizes the completion textedit feature.

autozimu commented 6 years ago

Regarding the additionalTextEdits, I have since exposed another function LanguageClient_workspace_applyEdit() https://github.com/autozimu/LanguageClient-neovim/commit/e5f91c7d9afbc976208d0bbeb2c4f8218052e995

After completion is done, following pseudo code should do the work

# assume the completed item is comp_item
if comp_item.get('additionalTextEdits') and self.nvim.funcs.exists('*LanguageClient_workspace_applyEdit'):
    bufname = self.nvim.current.buffer.name
    self.nvim.funcs.LanguageClient_workspace_applyEdit({bufname: comp_item.additionalTextEdits})

The only issue for me is that I'm not sure where should I put this action to.

euclio commented 6 years ago

@roxma Is anything blocking this issue? Does @autozimu's code work?