[Emacs] Basic python lsp support

This commit is contained in:
Ivan Malison 2019-01-11 13:40:03 -08:00
parent 77a92ce21c
commit 8687bc3518
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -2205,35 +2205,38 @@ I don't use auto-complete at all, so I have set up a hook to automatically disab
<<programminglanguages>> <<programminglanguages>>
*** python *** python
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defvar imalison:use-lsp-python t)
(use-package python (use-package python
:commands python-mode :commands python-mode
:mode ("\\.py\\'" . python-mode) :mode ("\\.py\\'" . python-mode)
:preface :preface
(defun imalison:python-mode () (progn
(setq show-trailing-whitespace t) (defun imalison:jedi-setup ()
;; TODO: This was likely fixed and can probably be removed ;; TODO: This was likely fixed and can probably be removed
;; Somehow this is sometimes set to jedi:ac-setup which we ;; Somehow this is sometimes set to jedi:ac-setup which we
;; don't want. This binding avoids starting auto-complete mode. ;; don't want. This binding avoids starting auto-complete mode.
(let ((jedi:setup-function nil)) (let ((jedi:setup-function nil))
(jedi:setup)) (jedi:setup))
;; XXX: This has become pretty annoying ;; XXX: This has become pretty annoying
;; (add-hook 'before-save-hook 'pyimport-remove-unused t t) ;; (add-hook 'before-save-hook 'pyimport-remove-unused t t)
;; Ensure company is active ;; Only use company-jedi for completion
(company-mode +1) (set (make-local-variable 'company-backends) '(company-jedi)))
;; Only use company-jedi for completion
(set (make-local-variable 'company-backends) '(company-jedi))
;; Remove default python completion, as we are going to rely on (defun imalison:python-mode ()
;; company-jedi. (setq show-trailing-whitespace t)
(remove-hook 'completion-at-point-functions ;; Remove default python completion, as we are going to rely on
'python-completion-complete-at-point 'local)) ;; company-jedi or company-lsp.
;; (remove-hook 'completion-at-point-functions
;; 'python-completion-complete-at-point 'local)
(unless imalison:use-lsp-python
(imalison:jedi-setup))))
:config :config
(progn (progn
(use-package sphinx-doc) (use-package sphinx-doc)
(unbind-key "C-j" python-mode-map) (unbind-key "C-j" python-mode-map)
(add-hook 'python-mode-hook #'imalison:python-mode))) (add-hook 'python-mode-hook #'imalison:python-mode)))
#+END_SRC #+END_SRC
**** pippel **** pippel
pippel lets one manage pip packages pippel lets one manage pip packages