X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..52469072ce9042d0f373bb3cc73563c7c722f2ab:/.vim/ftplugin/python.vim?ds=sidebyside diff --git a/.vim/ftplugin/python.vim b/.vim/ftplugin/python.vim index e8634578..ff848f9b 100644 --- a/.vim/ftplugin/python.vim +++ b/.vim/ftplugin/python.vim @@ -11,3 +11,48 @@ setlocal formatoptions+=bl imap t import ipdb; ipdb.set_trace() # noqa:E402,E702 # fmt: skip imap m if __name__ == "__main__":import syssys.exit()i + +if executable('ruffxx') + au User lsp_setup call lsp#register_server({ + \ 'name': 'ruff', + \ 'cmd': {server_info->['ruff', 'server']}, + \ 'allowlist': ['python'], + \ 'workspace_config': {}, + \ }) +endif + +if executable('pylsp') + au User lsp_setup call lsp#register_server({ + \ 'name': 'pylsp', + \ 'cmd': {server_info->['pylsp']}, + \ 'allowlist': ['python'], + \ 'workspace_config': {}, + \ }) +endif + +let b:ale_linters = ["mypy", "vim-lsp", "ruff"] +let b:ale_fixers = [ + \ "add_blank_lines_for_python_control_statements", + \ "ruff", + \ "ruff_format" + \] + +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' + +imap :ALELint +nmap :ALELint +imap :ALEFix +nmap :ALEFix + +nmap (ale_previous_wrap) +nmap (ale_next_wrap) + +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? asyncomplete#close_popup() : "\" + +let g:asyncomplete_auto_popup = 1 + +imap (asyncomplete_force_refresh) + +setlocal scl=no