Browse Source

python with limited company backends

master
Marc Pohling 6 years ago
parent
commit
2cbe1f94d7
1 changed files with 24 additions and 6 deletions
  1. 30
      config.org

30
config.org

@ -152,6 +152,7 @@ Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-
* Org Mode * Org Mode
** Installation ** Installation
Although org mode ships with Emacs, the latest version can be installed externally. The configuration here follows the [[http://orgmode.org/elpa.html][Org mode ELPA Installation instructions.]] Although org mode ships with Emacs, the latest version can be installed externally. The configuration here follows the [[http://orgmode.org/elpa.html][Org mode ELPA Installation instructions.]]
Added a hook to complete org functions, company-capf is necessary for this
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package org (use-package org
@ -421,7 +422,7 @@ Colorize colors as text with their value
) )
#+end_src #+end_src
*** Company Mode
** Company Mode
Complete Anything! Complete Anything!
Activate company and make it react nearly instantly Activate company and make it react nearly instantly
@ -438,6 +439,21 @@ Activate company and make it react nearly instantly
) )
#+end_src #+end_src
*** Company backend hooks
Backend configuration for python-mode
#+begin_src emacs-lisp
(defun company/python-mode-hook()
(lambda ()
(set (make-local-variable 'company-backends)
'((company-jedi company-dabbrev) company-capf company-files))
(company-mode t))
)
#+end_src
*** Misc Company packages
Addon to sort suggestions by usage Addon to sort suggestions by usage
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -484,10 +500,10 @@ The virtual environments need to have following modules installed:
(add-hook 'python-mode-hook (lambda () (add-hook 'python-mode-hook (lambda ()
(semantic-mode 1) (semantic-mode 1)
(flycheck-select-checker 'python-pylint))) (flycheck-select-checker 'python-pylint)))
;; (setq flycheck-checker 'python-pylint)))
) )
#+end_src #+end_src
Automatically start python-mode when opening a .py-file. Automatically start python-mode when opening a .py-file.
Not sure if python.el is better than python-mode.el. Not sure if python.el is better than python-mode.el.
See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~. See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~.
@ -499,10 +515,10 @@ Also limit the completion backends to those which make sense in Python.
:mode ("\\.py\\'" . python-mode) :mode ("\\.py\\'" . python-mode)
:interpreter ("python" . python-mode) :interpreter ("python" . python-mode)
:init :init
(add-hook 'python-mode-hook
(add-hook 'python-mode-hook ;;'company/python-mode-hook)
(lambda () (lambda ()
;; (set (make-local-variable 'company-backends)
;; '((company-jedi company-dabbrev-code company-capf company-files)))
(set (make-local-variable 'company-backends)
'((company-jedi company-dabbrev-code) company-capf company-files))
(company-mode t))) (company-mode t)))
:config :config
(setq python-shell-completion-native-enable nil) (setq python-shell-completion-native-enable nil)
@ -531,6 +547,7 @@ Code checks need to be installed, too:
(add-hook 'python-mode-hook 'jedi:setup) (add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t) (setq jedi:complete-on-dot t)
(setq jedi:use-shortcuts t) (setq jedi:use-shortcuts t)
(add-hook 'python-mode-hook 'company/python-mode-hook)
;; (defun my/python-mode-hook() ;; (defun my/python-mode-hook()
;; (lambda () ;; (lambda ()
;; (set (make-local-variable 'company-backends) ;; (set (make-local-variable 'company-backends)
@ -561,8 +578,9 @@ apt install
;; default traceback, other option M-x jedi:toggle-log-traceback ;; default traceback, other option M-x jedi:toggle-log-traceback
;; traceback is in jedi:pop-to-epc-buffer ;; traceback is in jedi:pop-to-epc-buffer
(jedi:setup) (jedi:setup)
(company/python-mode-hook)
(setq jedi:server-args '("--log-traceback"))) (setq jedi:server-args '("--log-traceback")))
(add-to-list 'company-backends 'company-jedi)
;; (add-to-list 'company-backends 'company-jedi)
;; (add-to-list 'company-backends 'company-anaconda) ;; (add-to-list 'company-backends 'company-anaconda)
;; (lambda () ;; (lambda ()
;; (set (make-local-variable 'company-backends) ;; (set (make-local-variable 'company-backends)

Loading…
Cancel
Save