Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 7d0e3eb

Browse files
author
Mikhail Arkhipov
authored
Merge pull request #216 from espositofulvio/master
Added instructions for using in SublimeText with the LSP plugin
2 parents af77731 + 0b5b15e commit 7d0e3eb

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

Using_in_sublime_text.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Using Microsoft Python Language Server with Sublime Text
2+
3+
## Prerequisites
4+
5+
* A build of the Microsoft Python Language Server (MPLS hereinafter)
6+
* .NET Core 2.1 Runtime installed
7+
* Sublime Text 3 (Tested with build 3176)
8+
* [LSP plugin](https://github.com/tomv564/LSP)
9+
10+
## Sublime Text configuration
11+
12+
This procedure has been tested on Windows 10 April 2018 Update but should also
13+
work on Linux and Mac if you change the paths accordingly. This also assumes
14+
you have a build of MPLS in C:\\python-language-server (again, change the path
15+
on other platforms).
16+
17+
* Edit LSP.sublime-settings - User adding the following:
18+
19+
```json
20+
{
21+
"clients":
22+
{
23+
"mspyls":
24+
{
25+
"command": [ "dotnet.exe", "exec", "C:\\python-language-server\\Microsoft.Python.LanguageServer.dll" ],
26+
"scopes": ["source.python"],
27+
"syntaxes": ["Packages/Python/Python.sublime-syntax"],
28+
"languageId": "python",
29+
"initializationOptions":
30+
{
31+
"interpreter":
32+
{
33+
"properties":
34+
{
35+
"UseDefaultDatabase": true,
36+
"Version": "3.7"
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
```
44+
45+
Remember to set the "command" path accordingly to your setup. Also set the
46+
"Version" field ("3.7" in the example above) to the version of the python
47+
interpreter you have in your path. If you don't have a python interpreter in
48+
your PATH env var, add a "InterpreterPath" field alongside "Version" and set
49+
it to the path of your python installation. At this point you can just enable
50+
the language server (refer to LSP documentation on how to do it) and your good
51+
to go.
52+
53+
## Virtual environments
54+
55+
If you use sublime text projects and have different virtual environment for your
56+
projects you can add the following to your project file (your-project.sublime-
57+
project):
58+
59+
```json
60+
{
61+
"settings":
62+
{
63+
"LSP":
64+
{
65+
"mspyls":
66+
{
67+
"enabled": true,
68+
"initializationOptions":
69+
{
70+
"interpreter":
71+
{
72+
"properties":
73+
{
74+
"InterpreterPath": "path_to_your_virtual_env\\python.exe",
75+
"UseDefaultDatabase": true,
76+
"Version": "the_version_of_python_in_your_virtual_env"
77+
}
78+
}
79+
}
80+
}
81+
}
82+
}
83+
}
84+
85+
```
86+
87+
The language server will then pick the interpreter in your virtual environment.

0 commit comments

Comments
 (0)