Browse Source

anaconda

master
Marc Pohling 6 years ago
parent
commit
dc53cb1865
2 changed files with 96 additions and 20 deletions
  1. 110
      config.org
  2. 6
      init.el

110
config.org

@ -326,11 +326,11 @@ Activate company and make it react nearly instantly
:ensure t :ensure t
:config :config
(add-to-list 'company-backends 'company-elisp) (add-to-list 'company-backends 'company-elisp)
(setq company-minimum-prefix-length 2
company-tooltip-align-annotation t
company-tooltop-flip-when-above t
company-show-numbers t)
(setq company-idle-delay 0.1)
(setq-default company-minimum-prefix-length 2
company-tooltip-align-annotation t
company-tooltop-flip-when-above t
company-show-numbers t
company-idle-delay 0.1)
(add-hook 'after-init-hook 'global-company-mode) (add-hook 'after-init-hook 'global-company-mode)
;; (global-company-mode t) ;; (global-company-mode t)
) )
@ -341,17 +341,18 @@ Addon to sort suggestions by usage
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package company-statistics (use-package company-statistics
:ensure t :ensure t
:after company
:config :config
(company-statistics-mode 1) (company-statistics-mode 1)
) )
#+end_src #+end_src
Get a popup with documentation of the completion candidate. Get a popup with documentation of the completion candidate.
I have to test if it even works.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package company-quickhelp (use-package company-quickhelp
:ensure t :ensure t
:after company
:config :config
(company-quickhelp-mode 1) (company-quickhelp-mode 1)
) )
@ -363,12 +364,23 @@ Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's
** Python ** Python
Systemwide following packages need to be installed: Systemwide following packages need to be installed:
- virtualenv
- venv
The virtual environments need to have following modules installed: The virtual environments need to have following modules installed:
- jedi - jedi
- epc - epc
- flake8
- pylint
#+begin_src emacs-lisp
(use-package flycheck
:ensure t
:init
(add-hook 'after-init-hook #'global-flycheck-mode)
(add-hook 'python-mode-hook (lambda ()
(semantic-mode 1)
(setq flycheck-checker 'python-pylint)))
)
#+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.
@ -379,6 +391,8 @@ The custom function is to run inferiour processes (do I really need that?), see
(use-package python (use-package python
:mode ("\\.py\\'" . python-mode) :mode ("\\.py\\'" . python-mode)
:interpreter ("python" . python-mode) :interpreter ("python" . python-mode)
:init
(add-hook 'python-mode-hook 'eldoc-mode)
:config :config
(setq python-shell-completion-native-enable nil) (setq python-shell-completion-native-enable nil)
;; (defun my/run-python () ;; (defun my/run-python ()
@ -389,31 +403,43 @@ The custom function is to run inferiour processes (do I really need that?), see
) )
#+end_src #+end_src
~TEST~ ELPY
Anaconda test
begin_src emacs-lisp
(use-package elpy
#+begin_src emacs-lisp
(use-package anaconda-mode
:ensure t :ensure t
;; :pin elpy
:defer t
:init
(add-hook 'python-mode-hook 'anaconda-mode)
;; (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
:config :config
(elpy-enable)
(add-hook 'python-mode-hook 'elpy-mode)
(setq elpy-rpc-backend "jedi")
(pyvenv-mode 1)
(setq anaconda-eldoc-mode 1)
) )
end_src
#+end_src
#+begin_src emacs-lisp
(use-package company-anaconda
:ensure t
:defer t
:init
(defun my/company-anaconda-hook()
(add-to-list 'company-backends 'company-anaconda))
(add-hook 'python-mode-hook 'my/company-anaconda-hook)
)
#+end_src
Jedi is a backend for python autocompletion and needs to be installed on the server: Jedi is a backend for python autocompletion and needs to be installed on the server:
- pip install jedi - pip install jedi
Code checks need to be installed, too: Code checks need to be installed, too:
- pip install flake8 - pip install flake8
#+begin_src emacs-lisp
begin_src emacs-lisp
(use-package company-jedi (use-package company-jedi
:defer t :defer t
;; :after company
:ensure t :ensure t
:config :config
(setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))) (setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
(setq jedi:python-environment-directory (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
(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)
@ -425,8 +451,54 @@ Code checks need to be installed, too:
A wrapper to handle virtual environments. A wrapper to handle virtual environments.
I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine. I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine.
pyvenv might need virtualenvwrapper, I have to test this.
apt install
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package pyvenv
:ensure t
:init
(setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
:config
(pyvenv-mode t)
(defun my/post-activate-hook()
(setq jedi:environment-root pyvenv-virtual-env)
(setq jedi:environment-virtualenv pyvenv-virtual-env)
(setq python-shell-virtualenv-root pyvenv-virtual-env)
;; default traceback, other option M-x jedi:toggle-log-traceback
;; traceback is in jedi:pop-to-epc-buffer
(jedi:setup)
(setq jedi:server-args '("--log-traceback"))
(add-to-list 'company-backends 'company-jedi)
(add-to-list 'company-backends 'company-anaconda)
;; (setq flycheck-checker 'python-pylint))
(flycheck-select-checker 'python-pylint))
;; (setq flycheck-checker 'python-flake8)
(add-hook 'pyvenv-post-activate-hooks 'my/post-activate-hook)
)
#+end_src
I want Emacs to automatically start the proper virtual environment.
Required is a .python-version file with, content in the first line being /path/to/virtualenv/
[[https://github.com/marcwebbie/auto-virtualenv][Github source]]
Depends on pyvenv
#+begin_src emacs-lisp
(use-package auto-virtualenv
:ensure t
;; :after pyvenv
;; :defer t
:init
(add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
;; activate on changing buffers
;; (add-hook 'window-configuration-change-hook 'auto-virtualenv-set-virtualenv)
;; activate on focus in
;; (add-hook 'focus-in-hook 'auto-virtualenv-set-virtualenv)
)
#+end_src
begin_src emacs-lisp
(use-package virtualenvwrapper (use-package virtualenvwrapper
:ensure t :ensure t
:init :init
@ -439,7 +511,7 @@ I strongly recommend to install virtual environments on the terminal, not throug
(add-hook 'venv-postactivate-hook 'jedi:stop-server) (add-hook 'venv-postactivate-hook 'jedi:stop-server)
(add-hook 'venv-postdeactivate-hook 'jedi:stop-server) (add-hook 'venv-postdeactivate-hook 'jedi:stop-server)
) )
#+end_src
end_src

6
init.el

@ -18,7 +18,11 @@
;; Setup package ;; Setup package
(require 'package) (require 'package)
(add-to-list 'package-archives (add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
'("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
(add-to-list 'package-archives
'("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives (add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/") t) '("org" . "http://orgmode.org/elpa/") t)
(when (boundp 'package-pinned-packages) (when (boundp 'package-pinned-packages)

Loading…
Cancel
Save