Search code examples
pythonemacsspacemacsyasnippet

Programming in Python, tab completion in spacemacs not right


the question as follow:

enter image description here

the screen record might be too short, so I upload a longer one: enter image description here

when I enter the code and press tab, there was print($0) on screen. And the cursor isn't at the right place which should follow the ( , I guess I have the wrong config in yas-snippet, please give me some support. Thanks.

the dotspacemacs-configuration-layers as follow:

;; 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;;
     multiple-cursors
     ;;
     org;;
     ;; (shell :variables
     ;;        shell-default-height 30
     ;;        shell-default-position 'bottom)
     spell-checking;;
     syntax-checking;;
     ;; version-control
     treemacs
     latex;;
)


Solution

  • I edit the config as follow. It helps, but I need to input "(". Any good solution? Thanks.

    (python :variables
                 python-backend 'lsp
                 python-indent-offset 4
                 python-format-on-save t;;
                 python-sort-imports-on-save t;
                 lsp-enable-snippet nil;
                 )