vim-lspの使い方
概要
- vim, neovimで利用可能なlispをバックエンドとした非同期のリンターなどを備える仕組み
- 定義された変数間をジャンプするなどの機能が使える
インストール
" vim-lsp関連
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings' " 各言語のサーバの設定を行う
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'Shougo/ddc.vim'
Plug 'shun/ddc-vim-lsp'
language-serverのインストール
mattn/vim-lsp-settingsをインストールすることでlanguage-serverを半自動でインストールすることができる- 例えば、pythonであると
python-lsp-server[all]をインストールする
機能一覧
:LspRename- リネーム
:LspReferences- 変数がどこで使われているか一覧
:LspPreviousReference- 前の変数へ
:LspNextReference- 次の変数へ
:LspHover- 関数の定義をホバーで表示
:LspStatus- lspサーバが作動しているかどうか
:LspStopServer- lspサーバを停止する
python-lsp-serverの設定
init.vimに以下のような設定を行う- 設定項目が多く公式ドキュメントを参照する
jedi_signature_helpは描画範囲が広く、OFFにしないと邪魔である
let g:lsp_settings = {
\ 'pylsp-all': {
\ 'workspace_config': {
\ 'pylsp': {
\ 'configurationSources': ['flake8'],
\ 'plugins': {
\ 'jedi_completion': {
\ 'cache_for': ['pandas', 'numpy', 'tensorflow', 'matplotlib']
\ },
\ 'jedi_hover': {
\ 'enabled': 0
\ },
\ 'jedi_signature_help': {
\ 'enabled': 0
\ },
\ 'flake8': {
\ 'enabled': 1
\ },
\ 'mccabe': {
\ 'enabled': 0
\ },
\ 'pycodestyle': {
\ 'enabled': 0
\ },
\ 'pyflakes': {
\ 'enabled': 0
\ },
\ }
\ }
\ }
\ }
\}