When developing with Windows + gVim + Poetry, build an environment where library code completion and linters work.
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
Download the version of the python installer you want to use from python official website
This time, download python3.7.5.
Run the downloaded installer.
pip install --user --upgrade pip
pip install poetry
poetry new testproject
cd testproject
poetry add --dev python-language-server
poetry add --dev flake8
cd testproject
poetry shell
gvim main.py
<C-x> <C-o>
, but after entering. (Dot), completion will appear automatically.Recommended Posts