-
Description
When editing Python files under LSP with Reproduction guide 🪲
list = ['a', 'list', 'of', 'words']
print(list.sort(reverse=True)) Observed behaviour: 👀 💔
Expected behaviour: ❤️ 😄
System Info 💻
(asm
(c-c++ :variables c-c++-adopt-subprojects t c-c++-backend 'lsp-clangd
c-c++-dap-adapters '(dap-lldb dap-gdb-lldb dap-cpptools)
c-c++-lsp-enable-semantic-highlight 'rainbow)
csv (dart :variables dart-backend 'lsp lsp-enable-on-type-formatting t)
emacs-lisp
(go :variables go-backend 'lsp go-format-before-save t go-use-golangci-lint t
go-use-test-args "-race -timeout 10s" godoc-at-point-function
'godoc-gogetdoc gofmt-command "gofumpt")
(html :variables web-fmt-tool 'prettier) (java :variables java-backend 'lsp)
(javascript :variables javascript-backend 'lsp javascript-fmt-on-save t
javascript-fmt-tool 'prettier javascript-import-tool 'import-js
js-indent-level 4 js2-basic-offset 4 js2-include-node-externs t
js2-mode-show-parse-errors nil js2-mode-show-strict-warnings nil)
(json :variables json-fmt-on-save t json-fmt-tool 'prettier)
(kotlin :variables kotlin-backend 'lsp) major-modes
(php :variables php-backend 'ac-php-core) protobuf
(python :variables python-backend 'lsp python-lsp-server 'pyright
python-sort-imports-on-save t python-test-runner '(pytest))
(ruby :variables ruby-backend 'lsp ruby-enable-enh-ruby-mode t
ruby-prettier-on-save t ruby-version-manager 'nil)
(rust :variables rust-backend 'lsp rustic-format-on-save t)
(sql :variables sql-capitalize-keywords t sql-lsp-sqls-workspace-config-path
'workspace)
(typescript :variables typescript-backend 'lsp typescript-fmt-on-save t
typescript-fmt-tool 'prettier)
(zig :variables zls-backend 'lsp) react (vue :variables vue-backend 'lsp)
graphql markdown nginx (shell-scripts :variables shell-scripts-backend 'lsp)
toml windows-scripts (yaml :variables yaml-enable-lsp t)
(auto-completion :variables auto-completion-enable-help-tooltip t
auto-completion-enable-snippets-in-popup t
auto-completion-enable-sort-by-usage t
auto-completion-use-company-posframe t)
better-defaults dtrt-indent
(geolocation :variables geolocation-enable-automatic-theme-changer t
geolocation-enable-location-service t)
(helm :variables spacemacs-helm-rg-max-column-number 1024) helpful
(ibuffer :variables ibuffer-group-buffers-by 'projects) imenu-list
(lsp :variables lsp-lens-enable t lsp-ui-remap-xref-keybindings t
lsp-ui-sideline-show-symbol t)
multiple-cursors nav-flash
(org :variables org-enable-github-support t org-enable-hugo-support t
org-enable-jira-support t org-enable-valign t
org-todo-dependencies-strategy 'naive-auto)
(osx :variables osx-command-as 'super osx-control-as 'control osx-function-as
'none osx-option-as 'meta osx-right-command-as 'control
osx-right-control-as 'control osx-right-option-as 'none
osx-swap-option-and-command nil)
pdf
(shell :variables close-window-with-terminal t multi-term-program
"/usr/local/bin/zsh" shell-default-height 28 shell-default-position
'bottom shell-default-shell 'vterm shell-default-term-shell
"/usr/local/bin/zsh" spacemacs-vterm-history-file-location
"$HOME/.zsh_history")
(spell-checking :variables enable-flyspell-auto-completion t
spell-checking-enable-auto-dictionary t
spell-checking-enable-by-default nil)
(treemacs :variables treemacs-use-all-the-icons-theme t
treemacs-use-collapse-dirs 3 treemacs-use-follow-mode 'tag
treemacs-use-git-mode 'deferred treemacs-use-scope-type 'Perspectives)
(unicode-fonts :variables unicode-fonts-force-multi-color-on-mac t)
(cmake :variables cmake-backend 'lsp cmake-enable-cmake-ide-support t) dap
debug (docker :variables docker-dockerfile-backend 'lsp)
(git :variables git-enable-magit-delta-plugin t git-enable-magit-gitflow-plugin
t git-enable-magit-svn-plugin t git-enable-magit-todos-plugin t)
gtags import-js pandoc prettier
(syntax-checking :variables syntax-checking-auto-hide-tooltips 3) templates
(version-control :variables version-control-diff-tool 'diff-hl)
(xclipboard :variables xclipboard-enable-cliphist t) colors
(llm-client :variables llm-client-enable-ellama t llm-client-enable-gptel t)
openai)
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This seems to be a limitation of pyright, see emacs-lsp/lsp-pyright#32, for example. One could try a hack like this, but it will probably not do the right thing in all cases: (defun fn/pyright-completion-maybe-insert-parens (completion)
(when (and
(stringp completion)
(memq (plist-get
(get-text-property 0 'lsp-completion-item completion)
:kind)
'(2 3)))
(insert "()")
(backward-char)))
(when (eq python-lsp-server 'pyright)
(add-hook 'python-mode-hook
(lambda ()
(add-hook 'company-after-completion-hook
'fn/pyright-completion-maybe-insert-parens nil t))))
This does sound strange. Unfortunately, I cannot reproduce it. |
Beta Was this translation helpful? Give feedback.
-
Fair enough, chief. However, thanks for looking into it. |
Beta Was this translation helpful? Give feedback.
This seems to be a limitation of pyright, see emacs-lsp/lsp-pyright#32, for example.
One could try a hack like this, but it will probably not do the right thing in all cases: