From 52469072ce9042d0f373bb3cc73563c7c722f2ab Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Thu, 10 Apr 2025 13:03:26 +0200 Subject: [PATCH 1/1] LSP config --- .vim/ftplugin/python.vim | 45 ++++++++++++++++++++++++++++++++++++++++ .vimrc | 12 ++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) 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 diff --git a/.vimrc b/.vimrc index cc3aad51..81d94633 100644 --- a/.vimrc +++ b/.vimrc @@ -209,7 +209,7 @@ set nowrap " sidescrolloff " minimal number of columns to keep left and right of the cursor " set siso=0 -set siso=0 +set siso=1 " display " include "lastline" to show the last line even if it doesn't fit @@ -685,6 +685,7 @@ let &flp='^\v\s*(((#|\a|\d{,4}|[ivx]{,4})[]:.)}/])+|[-\*.·→+])\s+' " completeopt " whether to use a popup menu for Insert mode completion " set cot=menu,preview +set cot=menu,noinsert,popup,preview,fuzzy " pumheight " maximum height of the popup menu @@ -1527,6 +1528,15 @@ iab → ➬ iab :thumbsup: 👍️ +let g:ale_completion_enabled = 0 +let g:ale_fixers = { '*': [ "remove_trailing_lines", "trim_whitespace" ] } +let g:ale_sign_error = '>>' +let g:ale_sign_warning = '--' +let g:ale_set_loclist = 1 +let g:ale_open_list = 1 +let g:ale_virtualtext_cursor = 'current' +let g:ale_floating_window_border = repeat([''], 8) + try execute pathogen#infect() catch -- 2.39.5