Giter VIP home page Giter VIP logo

company-jedi's Introduction

company-jedi.el

melpa badge melpa stable badge gh actions badge

company-mode completion back-end for Python JEDI.

Installation

company-jedi is available on MELPA.

You can install company-jedi with the following command.

M-x package-install [RET] company-jedi [RET]

Please do not install jedi package for company users, it is an auto-complete plugin of jedi

For el-get users

(el-get-bundle elpa:jedi-core)
(el-get-bundle company-jedi :depends (company-mode))

Setup

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi))

(add-hook 'python-mode-hook 'my/python-mode-hook)

company-jedi's People

Contributors

gonewest818 avatar immerrr avatar marsam avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

company-jedi's Issues

Can not auto complete for PyQt4

It's normal to work like this:

import json
import os
import sys
...

but can not complete for PyQt4:

from PyQt4 import QtGui,QtCore
QtGui.(nothing happend)

my configuration:

(require 'company)

(add-hook 'after-init-hook 'global-company-mode)
(setq company-show-numbers t); display serial number
(setq company-idle-delay 0.2); menu delay
(setq company-minimum-prefix-length 1); start completelyness number
(setq company-idle-delay 0.2;
      company-minimum-prefix-length 1; 
      company-require-match nil
      company-dabbrev-ignore-case nil
      company-dabbrev-downcase nil
      company-show-numbers t; 
      company-transformers '(company-sort-by-backend-importance)
      company-continue-commands '(not helm-dabbrev)
      )



(require 'company-jedi)
(setq jedi:environment-root "jedi")
(setq jedi:server-command (jedi:-env-server-command))
(defun config/enable-jedi ()
  (add-to-list 'company-backends 'company-jedi))
(add-hook 'python-mode-hook 'jedi:setup)
(add-hook 'python-mode-hook 'config/enable-jedi)
(setq jedi:complete-on-dot t)
(setq jedi:use-shortcuts t)

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 0)

Hi,

Using the following configuration, the following message is show: (wrong-number-of-arguments (1 . 2) 0)

(use-package company-jedi
  :ensure t
  :defer t
  :preface
  (add-hook 'python-mode-hook #'company-jedi)
  :config
  ;;(add-to-list 'company-backends 'company-jedi)
  (add-to-list 'company-backends
               (company-mode/backend-with-yas 'company-jedi)))

Here the complete Backtrace

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 0)
  company-jedi()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook python-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook python-mode-hook))
  run-mode-hooks(python-mode-hook)
  python-mode()
  set-auto-mode-0(python-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer basics_test.py> "d:/Developer/21_Python/py35/01_learning/basics_test.py" nil nil "d:/Developer/21_Python/py35/01_learning/basics_test.py" (29554872555126583 3434343376))
  find-file-noselect("d:/Developer/21_Python/py35/01_learning/basics_test.py" nil nil nil)
  find-file("d:/Developer/21_Python/py35/01_learning/basics_test.py")
  dired-find-file()
  funcall-interactively(dired-find-file)
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)

Emacs version: GNU Emacs 26.0.91 (build 1, x86_64-w64-mingw32) of 2018-02-26
OS: Windows 10

Thanks

adding function call tips like in ''emacs-jedi"

Could you add the similar feature to company-jedi? Many thanks!
Like the following figure shows.

You don't have to make it follow the cursor (actually it never works in my emacs, when still using auto-complete. No idea why.). Just show this function call signature in the mini-buffer when the cursor is in the parentheses after the function name. It is a small feature, but really useful. Now I have type jedi:show-doc to check the argument list.
Or just tell me which function in the jedi-core gives this function call signature? then I could bind it to a key to see the signature. Thanks!

8794015799_989e2a7217_o

Error on completion when using import as

I have installed company-jedi and the relevant python packages and for simple scripts, the completion works perfectly.

In various scripts where the imported package name is long, I like to use import as for example:

import matplotlib.pyplot as plt

When I do this, on typing 'plt.' I am presented with the error in the epc buffer as:
'ERROR:epc:KeyError(<Name: deprecate@244,11>,)'

Apologies if I am being stupid.

Unexpected behavior with Python3

How do I install this package with python3? Would be good to have this in the README. I'm using use-package and so far this is my setup:

  (use-package company
    :ensure t
    :config
    (add-hook 'after-init-hook 'global-company-mode))
(use-package company-jedi
  :after company
  :ensure t)

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi))

(add-hook 'python-mode-hook 'my/python-mode-hook)

(use-package elpy
  :ensure-system-package
  ((flake8 . "pip install flake8")
   (autopep8 . "pip install autopep8")
   (jedi . "pip install jedi"))
  :ensure t)

;; https://github.com/jorgenschaefer/elpy/issues/530
(setq elpy-modules (delq 'elpy-module-company elpy-modules))
(elpy-enable)

(add-hook 'python-mode-hook
	  (lambda ()
	    ;; explicitly load company for the occasion when the deferred
	    ;; loading with use-package hasn't kicked in yet
	    (company-mode)
	    (add-to-list 'company-backends
			 (company-mode/backend-with-yas 'elpy-company-backend))))

;; solving company, yasnippet conflicts
;; refer to https://www.emacswiki.org/emacs/Elpy
(defun company-yasnippet-or-completion ()
  "Solve company yasnippet conflicts."
  (interactive)
  (let ((yas-fallback-behavior
	 (apply 'company-complete-common nil)))
    (yas-expand)))

(add-hook 'company-mode-hook
	  (lambda ()
	    (substitute-key-definition
	     'company-complete-common
	     'company-yasnippet-or-completion
	     company-active-map)))

screen shot 2019-01-30 at 3 43 35 pm

Am I getting correct output? Would be good to have a picture in the README to compare results. Would appreciate help.

Incompatibility with company-quickhelp

I've intalled company-jedi, company, company-quickhelp, and pos-tip from melpa.
Auto completion and displaying quickhelp are working well.
However, soon after company-quickhelp displays a tooltip, the tooltip hides,
and instead a tooltip for function arguments is displayed if the cursor is on the function.
I guess the cause is that jedi:tooltip-show is invoked while company-quickhelp is displaying the tooltip.

Would you please disable jedi:tooltip-show when company-quickhelp is displaying the tooltip?

Documentation may be confusing for some users

I'm a newcomer to both company-mode and jedi-mode, so please excuse (and correct) any misunderstandings I may have here. I was confused by the documentation for company-jedi that I found both in ELPA and in the readme here, and from a bit of searching on this issue, I think others are too.

To me the description for the project read as if company-jedi should be installed in addition to jedi instead of in lieu of jedi. I initially assumed that company-jedi was an extension that should be added to an existing install of the jedi package. This obviously led to weird problems with both autocomplete-mode and company-mode competing for completion.

My first instinct was to just disable autocomplete-mode by M-x autocomplete-mode and that did solve the problem of autocomplete-mode stealing focus from company-mode. After I noticed that, I did some investigation and discovered that I didn't need the jedi package at all.

A modification to the main description may be helpful (if not some more detailed installation docs), perhaps something like:

company-jedi is a replacement for the jedi package using company-mode for autocompletion instead of autocomplete-mode.

And maybe a warning in the readme:

You can install company-jedi with the following command.
M-x package-install [RET] company-jedi [RET]
Note: company-jedi is not compatible with the jedi package, you should only install one of the two.

company-jedi does not show completion

I'm using the configuration as following

(use-package company-jedi
  :bind ("C-c d" . jedi:show-doc)
  :init
  (add-hook 'python-mode-hook 'jedi:setup)
  (push 'company-jedi company-backends)
  :config
  (setq jedi:complete-on-dot t))

with the latest version of company-mode. But I got nothing when I programming in python unless I called company-jedi function manually at the completion point. Is company-jedi not compatible with new company-mode? How can I fix this issue? Thanks.

Function Signatures are not displayed in mini-buffer

Could not get function signatures to be displayed in mini buffer as shown here

Some points of concern

  • I am using the latest emacs-27
  • I run emacs inside the terminal using the -nw option

My .emacs

(add-hook 'python-mode-hook 'company-mode)
(company-quickhelp-mode 1)

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi))
(add-hook 'python-mode-hook 'my/python-mode-hook)
(setq jedi:complete-on-dot t) 
(setq jedi:tooltip-method 'pos-tip)
;; (setq jedi:tooltip-method nil) 

I tried setting jedi:tooltip-method to both nil and pos-tip, nothing changed.

The output of jedi:show-setup-info is as follows

; Emacs Lisp version: (:emacs-version "27.0.50" :jedi-version "0.2.7" :python-environment-version "0.0.2alpha0") ;; Python version: ((:version "3.5.3 (default, Jan 19 2017, 14:11:04) \n[GCC 6.3.0 20170118]" :file nil :name "sys") (:version "0.12.0" :file "/home/svi/.emacs.d/.python-environments/default/lib/python3.5/site-packages/jedi/__init_\ _.py" :name "jedi") (:version "0.0.5" :file "/home/svi/.emacs.d/.python-environments/default/lib/python3.5/site-packages/epc/__init__.\ py" :name "epc") (:version "0.0.3" :file "/home/svi/.emacs.d/.python-environments/default/lib/python3.5/site-packages/sexpdata.py" \ :name "sexpdata")) ;; Command line: (:virtualenv "/home/svi/.virtualEnvs/python3/bin/virtualenv" :virtualenv-version "15.2.0\n") ;; Customization: ((jedi:complete-on-dot . t) (jedi:doc-display-buffer . display-buffer) (jedi:doc-hook view-mode) (jedi:doc-mode . rst-mode) (jedi:environment-root) (jedi:environment-virtualenv) (jedi:get-in-function-call-delay . 1000) (jedi:get-in-function-call-timeout . 3000) (jedi:goto-definition-config (nil nil nil) (t nil nil) (nil definition nil) (t definition nil) (nil nil t) (t nil t) (nil definition t) (t definition t)) (jedi:goto-definition-marker-ring-length . 16) (jedi:imenu-create-index-function . jedi:create-nested-imenu-index) (jedi:import-python-el-settings . t) (jedi:install-imenu) (jedi:install-python-jedi-dev-command "pip" "install" "--upgrade" "git+https://github.com/davidhalter/jedi.git@dev\ #egg=jedi") (jedi:key-complete . [C-tab]) (jedi:key-goto-definition . [67108910]) (jedi:key-goto-definition-pop-marker . [67108908]) (jedi:key-related-names . "^Cr") (jedi:key-show-doc . "^Cd") (jedi:server-args) (jedi:server-command "/home/svi/.emacs.d/.python-environments/default/bin/jediepcserver") (jedi:setup-keys) (jedi:tooltip-method pos-tip popup) (jedi:use-shortcuts) (python-environment-default-root-name . "default") (python-environment-directory . "~/.emacs.d/.python-environments") (python-environment-virtualenv "virtualenv" "--system-site-packages" "--quiet"))

When I open a python file i receive a warning and Eldoc is loaded as shown below

screen shot 2018-05-08 at 20 01 10

Once it starts autocomplete, Eldoc disappears (probably due to limited space)

screen shot 2018-05-08 at 19 53 22

Finally no signatures completion when inside function paranthesis

screen shot 2018-05-08 at 20 05 42

I love this feature and would be great if if works. Any help is highly appreciated.

Deferred error

Summary

Not working

Steps to reproduce

$ emacs
M-x jedi:install-server
C-x C-c
$ emacs a.py
M-x company-mode
imp
C-x b *Message* RET

deferred error : (error ""TypeError('init() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given')""

My configuration

env

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/13/bin:/home/user/.local/bin
PYTHONPATH=/home/user/.local/lib/python3.9/dist-packages/:/home/user/.local/lib/python3.9/site-packages/

OS

GNU/Linux 5.10.76-gentoo x86_64

.emacs

(require 'package)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

(require 'jedi-core)
(require 'epc)
(require 'company)
(require 'company-jedi)

(with-eval-after-load "company-jedi"
  ;;standard-jedi-settings
  (add-hook 'python-mode-hook 'jedi:setup)
  (setq jedi:complete-on-dot t)
  (setq jedi:use-shortcuts t)
  ;;company-jedi-settings
  (setq jedi:environment-virtualenv (list (expand-file-name "~/.emacs.d/.python-environments/")))
  (defun my/python-mode-hook ()
    (add-to-list 'company-backends 'company-jedi))
  (add-hook 'python-mode-hook 'my/python-mode-hook)
  
  ;; backend-settings
  (setq elpy-rpc-backend "jedi")

)

message buffer

For information about GNU Emacs and the GNU system, type C-h C-a.
a.py has auto save data; consider M-x recover-this-file
Waiting for git... [2 times]
Making completion list... [2 times]
Company mode enabled in current buffer
deferred error : (error "\"TypeError('__init__() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given')\"")

pip freeze

backports.entry-points-selectable==1.1.1
certifi==10001
charset-normalizer==2.0.6
distlib==0.3.4
docutils==0.17.1
epc==0.0.5
filelock==3.4.0
gdbus_codegen==2.68.4
gemato==16.2
gentoolkit==0.5.1.post1
idna==3.3
Jinja2==3.0.2
Mako==1.1.5
MarkupSafe==2.0.1
meson==0.59.4
packaging==21.0
platformdirs==2.4.0
portage==3.0.28
Pygments==2.10.0
pyparsing==2.4.7
PySocks==1.7.1
requests==2.26.0
setuptools-scm==6.3.2
sexpdata==0.0.3
six==1.16.0
tomli==1.2.2
urllib3==1.26.7
virtualenv==20.10.0

~/.emacs.d/.python-environments $ ls ////*


~/.emacs.d/.python-environments $ ls */*/*/*/*
default/lib/python3.9/site-packages/_virtualenv.pth
default/lib/python3.9/site-packages/_virtualenv.py
default/lib/python3.9/site-packages/argparse.py
default/lib/python3.9/site-packages/distutils-precedence.pth
default/lib/python3.9/site-packages/jediepcserver.py
default/lib/python3.9/site-packages/pip-21.3.1.virtualenv
default/lib/python3.9/site-packages/setuptools-59.3.0.virtualenv
default/lib/python3.9/site-packages/wheel-0.37.0.virtualenv

default/lib/python3.9/site-packages/__pycache__:
_virtualenv.cpython-39.pyc  jediepcserver.cpython-39.pyc
argparse.cpython-39.pyc

default/lib/python3.9/site-packages/_distutils_hack:
__init__.py  __pycache__  override.py

default/lib/python3.9/site-packages/argparse-1.4.0.dist-info:
DESCRIPTION.rst  METADATA  WHEEL          top_level.txt
INSTALLER        RECORD    metadata.json

default/lib/python3.9/site-packages/jedi:
__init__.py  _compatibility.py  common.py   inference        settings.py
__main__.py  api                debug.py    parser_utils.py  third_party
__pycache__  cache.py           file_io.py  plugins          utils.py

default/lib/python3.9/site-packages/jedi-0.18.1.dist-info:
AUTHORS.txt  INSTALLER  LICENSE.txt  METADATA  RECORD  WHEEL  top_level.txt

default/lib/python3.9/site-packages/jediepcserver-0.2.8.dist-info:
INSTALLER  RECORD     WHEEL            entry_points.txt
METADATA   REQUESTED  direct_url.json  top_level.txt

default/lib/python3.9/site-packages/parso:
__init__.py        cache.py    normalizer.py  py.typed  utils.py
__pycache__        file_io.py  parser.py      python
_compatibility.py  grammar.py  pgen2          tree.py

default/lib/python3.9/site-packages/parso-0.8.3.dist-info:
AUTHORS.txt  INSTALLER  LICENSE.txt  METADATA  RECORD  WHEEL  top_level.txt

default/lib/python3.9/site-packages/pip:
__init__.py  __main__.py  __pycache__  _internal  _vendor  py.typed

default/lib/python3.9/site-packages/pip-21.3.1.dist-info:
INSTALLER    METADATA  WHEEL             top_level.txt
LICENSE.txt  RECORD    entry_points.txt

default/lib/python3.9/site-packages/pkg_resources:
__init__.py  __pycache__  _vendor  extern  tests

default/lib/python3.9/site-packages/setuptools:
 __init__.py               cli-arm64.exe   glob.py         package_index.py
 __pycache__               cli.exe         gui-32.exe      py34compat.py
 _deprecation_warning.py   command         gui-64.exe      sandbox.py
 _distutils                config.py       gui-arm64.exe  'script (dev).tmpl'
 _imp.py                   dep_util.py     gui.exe         script.tmpl
 _vendor                   depends.py      installer.py    unicode_utils.py
 archive_util.py           dist.py         launch.py       version.py
 build_meta.py             errors.py       monkey.py       wheel.py
 cli-32.exe                extension.py    msvc.py         windows_support.py
 cli-64.exe                extern          namespaces.py

default/lib/python3.9/site-packages/setuptools-59.3.0.dist-info:
INSTALLER  LICENSE  METADATA  RECORD  WHEEL  entry_points.txt  top_level.txt

default/lib/python3.9/site-packages/wheel:
__init__.py  bdist_wheel.py     metadata.py  vendored
__main__.py  cli                pkginfo.py   wheelfile.py
__pycache__  macosx_libfile.py  util.py

default/lib/python3.9/site-packages/wheel-0.37.0.dist-info:
INSTALLER    METADATA  WHEEL             top_level.txt
LICENSE.txt  RECORD    entry_points.txt

Completion attempt gets wrong-type-argument (epc:manager nil)

GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)

Using miniconda3 virtual environments

Company and company-jedi installed from Melpa:

  company            20201014.2251 installed 
  company-jedi       20200324.25   installed
  pyvenv             20191202.1039 installed 

Prereqs installed:

$ conda list | grep 'epc\|jedi'
epc                       0.0.5                    pypi_0    pypi
jedi                      0.17.2                   pypi_0    pypi

Config:

;; company
(eval-after-load "company"
  '(add-to-list 'company-backends 'company-jedi))
(add-hook 'after-init-hook 'global-company-mode)
(setq jedi:server-command '("~/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py"))

jediepcserver.py works at that path:

$ ~/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py --help
usage: jediepcserver.py [-h] [--address ADDRESS] [--port PORT]
                        [--port-file PORT_FILE] [--sys-path SYS_PATH]
                        [--sys-path-append SYS_PATH_APPEND]
                        [--virtual-env VIRTUAL_ENV] [--log LOG]
                        [--log-level {CRITICAL,ERROR,WARN,INFO,DEBUG}]
                        [--log-rotate-max-size LOG_ROTATE_MAX_SIZE]
                        [--log-rotate-max-count LOG_ROTATE_MAX_COUNT]
                        [--log-traceback] [--pdb] [--ipdb]

Jedi EPC server.

Completion fails with:

*** jedi-mode is disabled in #<buffer hello.py> ***
Fix the problem and re-enable it.

*** You may need to run "M-x jedi:install-server". ***
This could solve the problem especially if you haven't run the command yet
since Jedi.el installation or update and if the server complains about
Python module imports.

I enabled debug on error and get this traceback:

Debugger entered--Lisp error: (wrong-type-argument epc:manager nil)
  signal(wrong-type-argument (epc:manager nil))
  jedi:epc--start-epc("~/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py" nil)
  jedi:server-pool--start(("~/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py"))
  jedi:start-server()
  jedi:get-epc()
  jedi:call-deferred(complete)
  company-jedi-candidates(#f(compiled-function (candidates) #<bytecode 0x2a33485>))
  company--fetch-candidates(#("impo" 0 4 (fontified t)))
  company-calculate-candidates(#("impo" 0 4 (fontified t)) nil)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer hello.py> #<window 3 on hello.py> 75 5)
  apply(company-idle-begin (#<buffer hello.py> #<window 3 on hello.py> 75 5))
  timer-event-handler([t 24471 6093 761307 nil company-idle-begin (#<buffer hello.py> #<window 3 on hello.py> 75 5) nil 0])

This happens nomatter what I put in jedi:server-args.

Company completion seems to be working fine for elisp. I haven't tried any other backends. I appreciate this isn't a standard config, but it is difficult to have multiple venv setups in a Conda environment.

How in the world you setup this thing

Here's my config

(use-package company
  :ensure t
  :config
  (add-hook 'after-init-hook 'global-company-mode)
  (setq company-idle-delay 0)
  (setq company-minimum-prefix-length 3))

 (use-package company-jedi
  :ensure t
  :config
  (with-eval-after-load 'company
    (add-hook 'python-mode-hook
              (lambda ()
                (add-to-list 'company-backends 'company-jedi))))
  (add-hook 'python-mode-hook 'jedi:setup)
  (setq jedi:complete-on-dot t))

What's wrong with it?
Editing a python file I get no autocompletion and have this epc on 3 buffer appearing

image

I use pyvenv for my virtualenvs and miniconda.

I have jedi and epc installed on my miniconda base environment and I want this to be picked up by company-jedi.

Later if I activate some environment using pyvenv which for instance has matplotlib, I want company-jedi to give me autocompletion for that package while using jedi and epc installed on my miniconda base environment?

Fresh install with issues.

Two small issues.

  1. For a reason that I haven't looked into, installing company-jedi via package-install does not download the dependency of jedi-core.
  2. Once installed I have (company-mode)(company-jedi) called for the python mode hook, but I get this error:
File mode specification error: (wrong-number-of-arguments ((t) (command &optional arg &rest ignored) "`company-mode' completion back-end for `jedi-code.el'.
Provide completion info according to COMMAND and ARG.  IGNORED, not used." (interactive (list (quote interactive))) (cond ((eql command (quote interactive)) (company-begin-backend (quote company-jedi))) ((eql command (quote prefix)) (and (derived-mode-p (quote python-mode)) (not (company-in-string-or-comment)) (or (company-jedi-prefix) (quote stop)))) ((eql command (quote candidates)) (cons :async (quote company-jedi-candidates))) ((eql command (quote meta)) (company-jedi-meta arg)) ((eql command (quote annotation)) (company-jedi-annotation arg)) ((eql command (quote doc-buffer)) (company-jedi-doc-buffer arg)) ((eql command (quote location)) nil) ((eql command (quote sorted)) t))) 0)

Completion attempt with company-jedi backend says "An error occured in auto-begin Wrong type argument: stringp, 126"

GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)

Using miniconda3 virtual environments

Company and company-jedi installed from Melpa:

  company            20201014.2251 installed 
  company-jedi       20200324.25   installed
  pyvenv             20191202.1039 installed 

Prereqs installed:

$ conda list | grep 'epc\|jedi'
epc                       0.0.5                    pypi_0    pypi
jedi                      0.17.2                   pypi_0    pypi

Config:

;; company
(eval-after-load "company"
  '(add-to-list 'company-backends 'company-jedi))
(add-hook 'after-init-hook 'global-company-mode)
(setq jedi:server-command "~/.emacs.d/elpa/jedi-core-20191011.1750/jediepcserver.py")

No completion ever happens: instead this error occurs:

Company: An error occurred in auto-begin
Wrong type argument: stringp, 126

Completion seems to be working fine for elisp. I haven't tried any other backends. This is also reported in the company-mode github project.

completion on point

When i complete on point I get the completions window, but for someone the completions window INCLUDES the period character at the beignning of all completion, which means I cannot continue to type and search!

How to not include the perioud character?

I deisalbe auto completion I like it to just be on a key press.

It looks like this:
Uploading Untitled.png…

not recognizing virtualenv?

I'm using virtualenvwrapper.el
After venv-workon a venv, it still attemping to complete the global site-packages, but not the packages in the virtualenv

related config:

;;; Virtualenvwrapper:
(require 'virtualenvwrapper)
(venv-initialize-eshell)
(venv-initialize-interactive-shells)
(setq-default mode-line-format (cons '(:exec venv-current-name) mode-line-format))

;;; Company
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
(require 'company-jedi)
(setq company-show-numbers 1)
(setq company-minimum-prefix-length 2)
(require 'jedi-core)
(company-quickhelp-mode 1)
(add-hook 'python-mode-hook (lambda () (add-to-list 'company-backends 'company-jedi)))
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:tooltip-method nil)

Autocomplete for self in class

Each time I write some method or attribute of class I get this message. Very hard to write python code without class completion.

Company: backend (company-jedi company-elisp company-yasnippet company-semantic company-capf company-files company-etags company-keywords company-dabbrev-code company-dabbrev) error "Cannot find types for ‘"self"’" with args (require-match)

My emacs config

Can't handle large packages.

company-jedi is giving me errors for completing on large package, for example pandas.

"Company: backend company-jedi async timeout with args (candidates )"

Problems when group company-jedi with other backend

Hi,

I find that when I use a grouped backend like '((company-jedi company-files company-gtags company-etags company-keywords) company-dabbrev), the company candidate menu flashes quite often each time I type a single char. But ((company-jedi company-gtags company-etags company-keywords) company-dabbrev) or use the single backend company-jedi perform just quite well.

I first guess that company-jedi conflicts with the company-files. But soon after I find that '((company-jedi company-yasnippet company-gtags company-etags company-keywords) company-dabbrev) causes the same problem.

Is that a company-jedi issue ?

Any help will be appreciated :)

Verbose output of function signature

I see some verbose output when the point is at a function, see screenshot pointing at a print function in a python buffer. The last line seems like a signature, but what is the rest? Can it be supressed?

GNU Emacs 26.1 (build 1, x86_64-apple-darwin17.6.0, Carbon Version 158 AppKit 1561.4) of 2018-06-04

emacs_jedi

Can not auto complete for SQLAlchemy

Other packages can be auto complete(like render_templates):
fdda30d00eb4f371a098c012209c81aa5deb5304

But SQLAlchemy can't(when I type id = db.Column):
799114b606e995561c1d003f5eb771aa2ce84e86

Here's my setup in ~/.spacemacs.d/init.el

(defun dotspacemacs/user-config ()
  ;; python configurations:
  (require 'pyvenv)
  (add-to-list 'company-backends 'company-anaconda)
  (add-to-list 'company-backends 'company-jedi)
  (add-to-list 'company-backends 'company-web)
  (add-hook 'python-mode-hook 'anaconda-mode)
  (add-hook 'python-mode-hook (lambda () (pyvenv-activate (concat (projectile-project-root) "/venv"))))
  (setq web-mode-engines-alist
        '(("django"    . "\\.html\\'")))
  (setq tab-width 4)
  (setq py-indent-offset 4)
  (setq python-spacemacs-indent-guess nil)
  (setq python-indent-guess-indent-offset nil)
  (setq org-confirm-babel-evaluate nil)
)

And here's the pipfile:

Package          Version
---------------- -------
alembic          1.0.11
argh             0.26.2
Click            7.0
Flask            1.1.0
Flask-CKEditor   0.4.3
Flask-Migrate    2.5.2
Flask-SQLAlchemy 2.4.0
Flask-WTF        0.14.2
itsdangerous     1.1.0
jedi             0.14.0
Jinja2           2.10.1
Mako             1.0.13
MarkupSafe       1.1.1
parso            0.5.0
pathtools        0.1.2
pip              19.1.1
python-dateutil  2.8.0
python-dotenv    0.10.3
python-editor    1.0.4
PyYAML           5.1.1
setuptools       39.0.1
six              1.12.0
SQLAlchemy       1.3.5
watchdog         0.9.0
Werkzeug         0.15.4
WTForms          2.2.1

Emacs version:

- OS: darwin
- Emacs: 26.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 5df46b200)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm

company-backends:

Value:
((company-anaconda . #1=(:with company-yasnippet))
 (company-semantic company-dabbrev-code company-gtags company-etags company-keywords . #1#)
 (company-files . #1#)
 (company-dabbrev . #1#))
Original value was 
(company-bbdb company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files
              (company-dabbrev-code company-gtags company-etags company-keywords)
              company-oddmuse company-dabbrev)
Local in buffer app.py; global value is 
(company-web company-jedi company-anaconda company-bbdb company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files
             (company-dabbrev-code company-gtags company-etags company-keywords)
             company-oddmuse company-dabbrev)

[help] Is it possible to to use `jedi:goto-definition` along with `company-jedi`?

I have to use jedi:goto-definition to jump into definitions. But when I do (add-hook 'python-mode-hook 'jedi:setup) jedi's and company's completions are get conflict. Is it possible to to use jedi:goto-definition along with company-jedi?


my setup:

(global-set-key "\C-x\C-j" 'jedi:goto-definition)
(global-set-key "\C-x\C-k" 'jedi:goto-definition-pop-marker)

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi))

(add-hook 'python-mode-hook 'my/python-mode-hook)

Error using company-jedi

Here is my setup:

(prolusion-require-package 'company-jedi)

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Completion configuration
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(autoload 'jedi:setup "jedi" nil t)

(add-hook 'python-mode-hook 'jedi:setup)

(setq jedi:environment-root prolusion-jedi-dir)
(setq python-environment-directory prolusion-jedi-dir)
(setq python-environment-default-root-name "root")
(setq jedi:complete-on-dot t)

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Completion setup
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(eval-after-load 'company '(add-to-list 'company-backends 'company-jedi))

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Completion hooks
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-hook     'python-mode-hook 'company-mode)

However I got the following errors:

Error (jedi): Failed to start Jedi EPC server.
*** You may need to run "M-x jedi:install-server". ***
This could solve the problem especially if you haven't run the command yet
since Jedi.el installation or update and if the server complains about
Python module imports.

And:

File \"/Users/jwintz/.emacs.d/prolusion-elpa/jedi-core-20160709.722/jediepcserver.py\", line 228, in jedi_epc_server
    import_jedi()
  File \"/Users/jwintz/.emacs.d/prolusion-elpa/jedi-core-20160709.722/jediepcserver.py\", line 274, in import_jedi
    import jedi
ImportError: No module named jedi
")

However, I have run M-x jedi:install-server multiple times.

Any hints ? I got it working for some seconds but still I have many machines I wanted to have a generic solution.

Cheers,

  • ju

Support for type hints?

I'm not very sure, but it seems that YouCompleteMe(vim) uses jedi too? And it can autocomplete for the following code:

def test(s: str):
    s. # autocomplete here

but company-jedi can't.

Get a function definition/implementation hint similar to the one shown in pycharm.

I test the lsp-python-ms with the following python code snippet:

import numpy as np
from numpy import pi, sin

a = np.array([1], dtype=bool)
if np.in|vert(a) == ~a:
    print('ok')

When putting the point in the above code snippet at the position denoted by |, I would like to see information similar to that provided by pycharm, as shown below:

image
image

Any hints for achieving this purpose with the help of company-jedi?

Regards,
HZ

Depdency for Jedi

I described the issue here & HERE, I've tried reinstalling <company-jedi>,<company-mode>,<jedi> for several times, still couldn't solve this issue.

How to setup jedi to recognise user package and auto complete them

I'm using company-mode and company-jedi, they both work good when complete the package provide by the system (sit-packages). Although when I import the class written by myself, company does not complete it for me and shows deferred error : (error "\"AttributeError(\\\"'ValueError' object has no attribute 'message'\\\",)\""). I have tested python in the terminal and the path was right configured. I don't know how to configure jedi in the right way to make it aware user path and auto complete it.

company-jedi vs jedi

So I first installed jedi and found it very useful and nice, it includes full function arguments.

Then I read that if I have company already then I should install company-jedi. I already use company/irony/clang for C++. So I deleted jedi and jedi-core and installed company-jedi instead. Unfortunately, all I see now with completion is function names and no full parameters like when jedi was installed. Am I missing something?

I am also pleased with eldoc integration with irony/company. But I can't seem to make it work with python. Is there special setup I need to include?

Completion and arguments display

Hello, I just tried to install company-jedi. Here is the relevant part of the code

(require 'company-jedi)
(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)
(add-to-list 'company-backends 'company-jedi)

So, I'm having the following question. When you're using auto-complete package you have the function and the description of the function. Then when you're inside the arguments, the proper arguments that you have to put inside the functions are displayed. Nonetheless, here I can only see the completion, without any knowledge if it's a function, variable or whatsoever, and I cannot see the the arguments while I'm inside the function. Is this normal?

Error when add company-jedi to company-backends

File mode specification error: (invalid-function (company-jedi company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf  company-files (company-dabbrev-code company-gtags company-etags company-keywords) company-oddmuse company-dabbrev))

My el-get recipe

(:name company-jedi
    :description "Company backend for Python jedi."
    :website "https://github.com/syohex/emacs-company-jedi"
    :type github
    :pkgname "syohex/emacs-company-jedi"
    :post-init (with-eval-after-load 'company
                    (add-hook 'python-mode-hook
                        (add-to-list 'company-backends 'company-jedi))))

Completion of whole string path

I just installed jedi-core and then company-jedi. When I tried to use the completion, I found something wierd happening in interactive mode. In the python script buffer, the completion seems to only have the string before the first "dot" in consideration for completion - thus the function "abs", which is a member of numpy is given as a completion for "np.linalg.", which is wrong.
On the inferior python buffer on the other hand, this error is not present since it seems to complete the whole string. (I understand that inferior python does not use company-jedi for completion, but ipython's completion since I use ipython for "run-python").

company-jedi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.