visual studio code - language server extension that written in python - python

I would like to write a visual studio code extension that parse and analyse large log files.
I thought to start with language server extension.
I would like the server to be written in python.
Below, there is an example to server that is written in TypeScript
https://code.visualstudio.com/docs/extensions/example-language-server
it uses the library "vscode-languageserver".
Is there any module in python equivalent to "vscode-languageserver"?
Do you know any example language server extension that is written in python?

It looks like there are at least two to take a look at:
python-langserver by Sourcegraph
python-language-server by Palantir
Unfortunately, I’m not familiar enough with Python to know which of these are the better choice.

I realize this is an old question but in case someone else is looking for this information:
I'm working on a project that implements an LSP server in Python. To accomplish writing the language server in Python we are using a library called pygls.
As with anything, it has its good and bad points but I can say that it has gotten the job done for the aforementioned project, so far.

Related

Developing an app in visual studio code using python

I’m kinda new to programming and the only programming language I'm kinda familiar with at the moment is python. I heard visual studio code can develop an app for both ios and android devices. However, can the visual studio code accept any programming language? Like, let's say I created a code using python, can the visual studio code develop it right away?
VS Code has an official Python module that works very well so no problems on that front. However, developing for either iOS or Android comes with some additional concerns: in both cases, Python is not "native" on those platforms, so you have to include Python with your app, and there are no "official" Pythons for either platform. You can do it (read up, for example, on a platform/framework called Kivy), but quite frankly if those two specifially are your target you might be better off picking a different language. It's not really an ideal starter project. However you can have a lot of fun just developing your Python skills and run it on platforms where it's better supported - like the one where you plan to run VS Code
!
I explained majority of what I thought in comment, but I'll just duplicate and add some key concepts you need to study.
Visual studio code is a software app that allows you to edit text. It
is not tide to any language. Developing for IOS or Android depends on
language, but not on the editor that you're using. From your question
it seems like you don't understand primary concepts of app development
or programming, so you better study this first.
Things you should study:
What is an application/program?
What is Python application (since you showed your interest in language)?
How basic apps run?
What is IDE and why do you need it?
Your question got many "downvotes" because you don't quite know what you're asking.
Hope this will help!

Control Visual Studio using python

I am building an application in which I would like to control Visual Studio, or at least have access to its compilation and build functionalities using (hopefully) python. I know Visual Studio macros are possible and available but it appears they are in .NET (see doc). Since I would like to automate what I want to do with VS in python I'm looking more for something along the lines of:
import vs2016 as controller
controller.build()
controller.compile()
Please note I am not looking to run python code in Visual Studio. This is an altogether different problem that is already widely documented by Microsoft.
Is it possible to control Visual Studio within Python?
if so, how?
if not, what is a viable alternative? let's say I accept that it can only be done with dotnet. In this case how can I relay back to python while keeping it debuggable from a python script?
Thanks!
This sounds like a pretty big undertaking, but I would look in to a win32com.client.dispatch or comtypesto plug in to the COM object(there are several from a quick search and I dont know what any of them do)

Python embedded in RubyOnRails

I am trying to make a site like Codeacademy. Where users can learn Python online,
solve problems and master theory.
Framework for the server is Ruby On Rails
I am trying to understand how can I translate python's code to the server, then execute this code on the server? Any python's interpreters created in Ruby? I totally can not understand how this should work.
Python's version: 2.7 or 3.5 (Not fundamentally)
Thank you for attention
As other have stated, there are serious security implications for letting users blindly run things on your server, but if you really wanted to, you could write the python to a file and then execute the python using system "python #{file_path}".
I'm not too familiar with python, but you could probably switch stdout and stderr to write to files and then read those files to get any print statements.

Would it be possible to integrate Python or Perl with Ruby?

Would it be possible to integrate Python (and/or Perl) and Ruby? I've looked at http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/ and http://code.google.com/p/ruby-perl/ , but they both seem rather outdated.
Has someone generated a Ruby interface for Python's C API?
Edit: Python can be integrated with many other languages according to http://wiki.python.org/moin/IntegratingPythonWithOtherLanguages . However, that list doesn't include Ruby.
My school (Georgia Tech), along with Bryn Mawr and Microsoft Research, are doing a project right now called Pyjama. Basically, it uses the Microsoft DLR to allow you to freely mix Python and Ruby. I haven't tried it, but it sounds pretty cool.
Here's an example from the website. You enter the class in "Python mode". Then it gets compiled, and you run the command in "Ruby mode".
class PythonClass:
def hello(self, value):
print "Python says hello to", value
pc = python_class().new
pc.hello "Ruby"
Which produces "Python says hello to Ruby".
Integrating dynamic languages is one of the goals of the Parrot project. It's a virtual machine that dynamic language compilers target. Once compiled to the same virtual machine, you should be able to used the "object" form in any of the languages no matter the object's source.
The issue at the moment, however, is stabilizing the virtual machine and finishing off the mostly done compilers. However, that's been the state for a long time. :)
You can write extensions for Ruby in C.
So, if Python has a C API, you can write a C extension for Ruby which uses this API.
I know nothing about the Python API or how large of a piece you want to integrate with, but if it is not too big, this could (possibly) give you a way to run Python code from Ruby.
For a research project I wanted to use the fabulous matplotlib that's available for Python. I also found that library that you referred to. However, it doesn't look like something popular and well tested. So I decided to write the script that generated graphs using pure Python and called it from Ruby via popen. That worked very well for me.
It might by possible, but not very practical. It would be significantly easier to port whatever modules you need from one to the other than it would be to embed one of the interpreters within the other.
If you absolutely have to use both languages in a project, your best option would probably the combination of Jython and Jruby, or IronPython and IronRuby. I'm not sure if you could get them to talk to each other, but at the very least you could host them on the same virtual machine.
Another strategy, as used by Facebook, is to expose APIs via Thrift. You define lightweight service APIs and the RPCs are inter-process.

Python code generator for Visual Studio?

I had an idea, if I add a python .py file to my C# project, and tag the file with a custom generator that would execute the python file, and treat the output as the result of the code generation, ie. put it into a C# file, that would allow me to do quite a lot of code generation as part of the build process.
Does anyone know if such a custom generator for Visual Studio 2008 exists?
I think Cog does what you want.
OK, I see. Well, as far as I know there isn't any code generator for Python. There is a good introduction on how to roll your own here.
Actually, that's quite an under-used part of the environment, I suppose it's so because it needs you to use the IDE to compile the project, as it'd seem only the IDE knows about these "generators", but MSBuild ignores them.
I recall that in previous versions of VS, there was a way to add custom build steps to the build process. I used that a lot to do exactly the kind of automated code generation you describe.
I imagine the custom build step feature is still there in 2008.
I don't understand what you are trying to do here. Are you trying to execute a Python script that generates a C# file and then compile that with the project? Or are you trying to compile a Python script to C#?
I dug through my old bookmarks (I love Del.icio.us!) and found this article: Code Generation with Python, Cog, and Nant. Keep in mind that anything you can do in NAnt can probably be done in MSBuild as well. This should be enough to get you started.

Categories

Resources