Windows + gVim + Poetry python development environment construction

Target

When developing with Windows + gVim + Poetry, build an environment where library code completion and linters work.

gVim installation

image.png

Install git for windows

image.png

Install vim plugin

cd ~
New-Item vimfiles/pack/mypackage/opt -ItemType Directory
cd vimfiles/pack/mypackage/opt
git clone https://github.com/prabirshrestha/vim-lsp.git
git clone https://github.com/prabirshrestha/async.vim.git
git clone https://github.com/dense-analysis/ale.git

Added the following to ~ / _vimrc

let g:ale_completion_enabled = 1
packadd ale 
let g:ale_lint_on_save = 1
let g:ale_sign_column_always = 1
packadd async.vim
packadd vim-lsp
let g:lsp_diagnostics_enabled = 0 "Error display is done with ALE
function! s:configure_lsp() abort
  setlocal omnifunc=lsp#complete
  nnoremap <buffer> <C-]> :<C-u>LspDefinition<CR>
  nnoremap <buffer> gd :<C-u>LspDefinition<CR>
  nnoremap <buffer> gD :<C-u>LspReferences<CR>
  nnoremap <buffer> gs :<C-u>LspDocumentSymbol<CR>
  nnoremap <buffer> gS :<C-u>LspWorkspaceSymbol<CR>
  nnoremap <buffer> gQ :<C-u>LspDocumentFormat<CR>
  vnoremap <buffer> gQ :LspDocumentRangeFormat<CR>
  nnoremap <buffer> K :<C-u>LspHover<CR>
  nnoremap <buffer> <F1> :<C-u>LspImplementation<CR>
  nnoremap <buffer> <F2> :<C-u>LspRename<CR>
endfunction

"Settings for python
if executable('pyls')
    augroup lsp_pyls_enable
        autocmd!
        autocmd User lsp_setup call lsp#register_server({
                    \ 'name': 'pyls',
                    \ 'cmd': {server_info->['pyls']},
                    \ 'whitelist': ['python'],
                    \ })
        autocmd FileType python call s:configure_lsp()
        autocmd FileType python imap <expr> . ".\<C-X>\<C-O>"
    augroup end
endif

python installation

image.png image.png

Installing the Visual C ++ redistributable package

image.png

installation of poetry

pip install --user --upgrade pip
pip install poetry

Creating a Poetry project

poetry new testproject
cd testproject
poetry add --dev python-language-server
poetry add --dev flake8

start gVim

cd testproject
poetry shell
gvim main.py

Recommended Posts

Windows + gVim + Poetry python development environment construction
python windows environment construction
Python development environment construction
python2.7 development environment construction
Python environment construction (Windows10 + Emacs)
Python environment construction under Windows7 environment
[MEMO] [Development environment construction] Python
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Python development environment construction 2020 [From Python installation to poetry introduction]
Python environment construction memo on Windows 10
Anaconda python environment construction on Windows 10
Python development environment construction on macOS
Python environment construction (pyenv + poetry + pipx)
Install Python development environment on Windows 10
Emacs Python development environment construction memo
Python environment construction
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
Python project environment construction procedure (for windows)
Python3 + venv + VSCode + macOS development environment construction
About Python development environment
Development environment in Python
Mac environment construction Python
Python environment construction @ Win7
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
Create a Python virtual development environment on Windows
Get a quick Python development environment with Poetry
Python + Anaconda + Pycharm environment construction
Django development environment construction memo
Python + Kivy development on Windows
CI environment construction ~ Python edition ~
Create a comfortable Python 3 (Anaconda) development environment on windows
Python environment construction For Mac
Build a GVim-based Python development environment on Windows 10 (1) Installation
Anaconda3 python environment construction procedure
Build Python environment on Windows
Google App Engine / Python development environment construction procedure (late 2014)
Organize your Python development environment
Python environment construction and TensorFlow
Django environment development on Windows 10
[ev3dev × Python] Build ev3dev development environment
Python development environment with Windows + Anaconda3 + Visual Studio Code
Build python environment on windows
QGIS3 Python plugin development environment construction with VSCode (macOS)
Manage Python runtime packages and development environment packages with Poetry
Python development environment with Windows + Python + PipEnv + Visual Studio Code
[For organizing] Python development environment
[Tensorflow] Tensorflow environment construction on Windows 10
django project development environment construction
Environment construction of python2 & 3 (OSX)
[MEMO] [Development environment construction] wine
OpenJTalk on Windows10 (Speak Japanese with Python from environment construction)
Construction of Python local development environment Part 2 (pyenv-virtualenv, pip usage)
Prepare Python development environment with Mac + Windows + VisualStudio Code (Windows version)
Prepare Python development environment with Mac + Windows + VisualStudio Code (Mac version)
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
Python environment construction procedure memo using Docker on Windows10 Home