spacemacs中使用python时出现tab补全不能自动定位到参数位置

问题表述: 在python中输入几个字符,按tab补全时,不能自动定位到参数位置,而是显示作 print($0) 。请问各位大佬有何解决良策?

bug

我怀疑可能的原因是与yas-snippet冲突,使用M-x yas-visit-snippet-file 查询到print的片段为:

# -*- mode: snippet -*-
# name: print
# key: p
# --
print($0)

layers配置如下:

   ;; List of configuration layers to load.
   dotspacemacs-configuration-layers
   '(
     ;; ----------------------------------------------------------------
     ;; Example of useful layers you may want to use right away.
     ;; Uncomment some layer names and press `SPC f e R' (Vim style) or
     ;; `M-m f e R' (Emacs style) to install them.
     ;; ----------------------------------------------------------------
     chinese(chinese :variables chinese-default-input-method 'pinyin
                     chinese-enable-youdao-dict t)
     (auto-completion :variables company-idle-delay 0.1
                      auto-completion-enable-sort-by-usage t
                      auto-completion-enable-snippets-in-popup t
                      auto-completion-tab-key-behavior 'cycle
                      :disabled-for org);;
     better-defaults;;
     emacs-lisp
     git;; 开启git支持
     helm
     lsp
     (python :variables
             python-backend 'lsp
             python-indent-offset 4
             python-format-on-save t;;保存时自动格式化
             python-sort-imports-on-save t;;保存时自动将导入的包排序
             )
     java;;
     markdown;; 开启markdown支持
     multiple-cursors
     ;;
     org;;
     ;; (shell :variables
     ;;        shell-default-height 30
     ;;        shell-default-position 'bottom)
     spell-checking;; 开启拼写检查
     syntax-checking;; 开启语法检查
     ;; version-control
     treemacs
     latex;;
)

这是时间更长版本的问题复现: bug

(setq lsp-enable-snippet t) 就会有这种情况,所以我都是关闭这个选项,括号手打也不麻烦

1 个赞

非常感谢你的回复,我测试了一下,这样的确会好很多。

还有一个小问题想请教,请问你是把这个设置放在哪里?

按照我目前的掌握程度,我只能把它放在dotspacemacs/user-config ()

但是我不清楚 lsp-enable-snippet的作用范围有多少?我不希望这个设置影响到我其他的major mode。

希望能向你学习,谢谢。