简体   繁体   中英

add snippets to language server

I want to add more keywords & snippets to autocomplete service.

eg; If I type FooBar it will suggest

var FooBar = function (args) {
  return `foo ${args.length}`;
};

how do I extend Language Server ?

If it matters, I'm using vim-lsp .

ref

You can write your own snippets using a snippets plugin. Vim-lsp recommends a few in :h vim-lsp . However, I do not believe there's any way to add snippets to a language server directly without modifying that server directly.

That being said, it may not be that hard to modify the server and add a few snippets. vim-language-server , for instance, seems to keep its snippets defined in a snippets.ts file here . Modifying this file might interfere with automatically updating the server, but it shouldn't cause any real problems unless you mess up the syntax. And then when you do want to update the server, just save your changes somewhere and undo them on this file and let it update, then add them back.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM