imc-trading / svlangserver

MIT License
95 stars 13 forks source link

How to use snippets in emacs with lsp-mode? #15

Closed nowislewis closed 2 years ago

nowislewis commented 2 years ago

Thanks for your great work. I've configured emacs with readme.md and downloaded snippets, but I don't know how to make these snippets work.

kkanhere commented 2 years ago

Have you tried yasnippets?

nowislewis commented 2 years ago

Yes, I installed yasnippsets and lsp-mode. Cpp and Python work well. But it seems that the server can’t find the sv snippets, where should I put the snippets?

Do I need to manually configure the search options of lsp for svlangserver?

kkanhere commented 2 years ago

The language server doesn't interact with the snippets. They are meant only for snippet extension such as yasnippet. Can you please try saving the snippets under ~/.emacs.d/snippets/verilog-mode and see if that works?

nowislewis commented 2 years ago

I tried it a few minutes ago and I moved the systemverilog.json under the git repository to " ~/.emacs.d/snippets/verilog-mode/".

image What really happened is that after clicking, the contents of the entire json file will be inserted into the file

Maybe I should read yasnippets document to let it work with json files. Thanks for your work!

kkanhere commented 2 years ago

oh yeah. The format that yasnippet expects is different I guess. The json based snippets work with VSCode and coc-snippets (vim) I believe

nowislewis commented 2 years ago

It seems that yas cannot work with json, I will try to rewrite the systemverilog.json file into yas format.