palantir / python-language-server

An implementation of the Language Server Protocol for Python
MIT License
2.61k stars 283 forks source link

How to create a plugin for code lenses #516

Open DonJayamanne opened 5 years ago

DonJayamanne commented 5 years ago

I'm having trouble adding a new plugin for code_lenses, here's what I've done:

@hookimpl def pyls_code_lens(config, workspace, document): return []



Unfortunately this function doesn't get executed.
If however, I were to add the above method into an existing file such as `plugins/definition.py`, then it works.
gatesn commented 5 years ago

You might need to add an entry point into setup.py

DonJayamanne commented 5 years ago

No joy, Here's my entry in setup.py

'code_lens' = 'pyls.plugins.code_lens'

I can see the the code_lens in python.ls.py is not but not my hook implementation

gatesn commented 5 years ago

This branch has an example of getting this to work: https://github.com/palantir/python-language-server/tree/ngates/code-lens-support

Screenshot 2019-03-27 at 09 47 46

DonJayamanne commented 5 years ago

Will try tonight, thanks