LoginSignup
1
1

More than 5 years have passed since last update.

sublime + venv + pylsで入力補完

Last updated at Posted at 2018-03-11

pylsとは

pylsはpython向けのlanguage-server-protocol (lsp)実装です。
リポジトリはこちら
https://github.com/palantir/python-language-server

lspは簡単に言うとエディタ支援の共通規格みたいなもの?らしいです。

python側の準備

今回はpylsをグローバルではなくvenv環境にインストールします。

python -m venv .venv
. .venv/bin/activate
pip install python-language-server
deactivate

sublime側の準備

まず、sublimeにlspのpackageをインストールします。
Package Controlで下記をインストールすれば完了です。
https://github.com/tomv564/LSP

次に、lspの設定ファイルを編集します。
今回はグローバルにpylsをインストールする訳ではないのでfalseにしてます。

{
    "clients":
    {
        "pyls":
        {
            "enabled": false
        }
    }
}

最後に、projectの設定ファイルを編集してpylsを起動できるようにします。

hoge.sublime-project
{
    "folders":
    [
        {
            "path": "/hoge"
        }
    ],
    "settings":
    {
        "LSP":
        {
            "pyls":
            {
                "command":
                [
                    "/hoge/.venv/bin/pyls"
                ],
                "enabled": true
            }
        }
    }
}

補完が効くようになりました。

image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1