-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Transform completion items to snippets #465
Comments
You can use https://github.com/L3MON4D3/LuaSnip And define you own snippets , that can do the job too. |
I understand, but I want to make function items from lsp auto becomes snippet e.g.
|
Not sure if this is what you want, but here's a thing that I do for Pyright to return snippets which insert the call parentheses for functions: lspconfig['pyright'].setup({
on_init = function(client)
local orig_rpc_request = client.rpc.request
function client.rpc.request(method, params, handler, ...)
local orig_handler = handler
if method == 'textDocument/completion' then
-- Idiotic take on <https://github.com/fannheyward/coc-pyright/blob/6a091180a076ec80b23d5fc46e4bc27d4e6b59fb/src/index.ts#L90-L107>.
handler = function(...)
local err, result = ...
if not err and result then
local items = result.items or result
for _, item in ipairs(items) do
if not (item.data and item.data.funcParensDisabled) and (
item.kind == lsp.protocol.CompletionItemKind.Function or
item.kind == lsp.protocol.CompletionItemKind.Method or
item.kind == lsp.protocol.CompletionItemKind.Constructor
) then
item.insertText = item.label .. '($1)$0'
item.insertTextFormat = lsp.protocol.InsertTextFormat.Snippet
end
end
end
return orig_handler(...)
end
end
return orig_rpc_request(method, params, handler, ...)
end
end;
}) |
Hello there, I'd like to edit a source to return a snippet for methods that has the method name and paramters as snippet. Any ideas?
Thanks
The text was updated successfully, but these errors were encountered: