AnIntelligentPythonIDEWith,python的ide有哪些

有哪些 7
AnIntelligentPythonIDEWithEmacs,Projectile,andJedi DrewWerner May5,2014 Roadmap MotivatingdemoInstallationguideCustomizationtipsTryitout:/wernerandrew/jedi-starter AnEmacsIDE EasilyfindfilesandswitchbetweenprojectsEasynavigationthroughfunctiondefinitionsContextualdocumentationInlinehelpplexfunctioncalls Howitallworks Needaninterfacepletionandshowingalternatives.plete NeedaninterpreterthatknowsthelanguageHere,aserverthatwrapsaPythonparsinglibrary Youneedglue.epc,jedi.el Allthisinvolvessome.emacscustomization. TheJediStarterVM You’llneed:Someunix-yCLIenvironment(OSX,Linux)Thejedi-starterrepo(onGithub)Vagrant(testedwith1.4.3)VirtualBox(testedwith4.2.16) Aftercloning,fromaterminal:cdjedi-startervagrantupvagrantssh Initializationcodeisinjedi-starter.el Structureofjedi-starter.el (add-to-list’load-path"~/.emacs.d")(require’package) ;;Packagesetupcodegoeshere ;;Globalconfigvars,globalhelperfunctions (add-hook’after-init-hook’(lambda();;Packagespecific)) initialization goes here Installation You’llneed:projectilepleteepcjedi Manualinstallationispossible,butannoyingpackage.elismuchbetter PackageManagement BuiltintoEmacs24,availableforEmacs23.(SeeGithubrepoforEmacs23example.) (require’package)(package-initialize)(add-to-list ’package-archives’("melpa"."/packages/")) Onegotcha:don’tetthetrailing“/”ontheURL.Packagesarestoredin/.emacs.d/elpa/ Gettingthepackages Oneway:M-xlist-packagesGivesyouaniceinterfaceButhardtoreproduceyourenvironment Abetterway:Usethepackage.elAPI Simpleauto-installation (defvarlocal-packages’(projectilepleteepcjedi)) (defununinstalled-packages(packages)(delqnil(mapcar(lambda(p)(if(package-installed-ppnil)nilp))packages))) (let((need-to-install(uninstalled-packageslocal-packages))) (whenneed-to-install(progn(package-refresh-contents)(dolist(pneed-to-install)(package-installp))))) WorkingwithProjectile Somemands:C-cpsSwitchtoprojectC-cpfListfilesinprojectC-cpkKillallbuffersforproject Moreinfo:/bbatsov/projectileEasysetup: (require’projectile)(projectile-global-mode) ;;Emacs23hack(when(not(boundp’remote-file-name-inhibit-cache)) (setqremote-file-name-inhibit-cachet)) PackageConfig pleteisalsoeasy: (require’plete-config)(ac-config-default) ;;Ifyoureallylikethemenu(setqpletet) AutomaticallyintegrateswithmonprogrammingmodesButonlyenablespletions Language-specifickeywordsWordsinbufferswithsamemodeDoesn’tknowanythingaboutsyntax Jedi:TheBrains Severalthingshavetoplaynicelyforthisalltowork:JediAPythonlibraryforcontextualparsingoffilesNotspecifictoEmacs/davidhalter/jediEPCSimpleEmacs/PythonRPClibraryJedi.elSmallPythonserverwrappingsomeJedifeaturesElispfrontendtotheserver JediComponents jediepcserver.py%via%EPC%imports% comple;ons,%naviga;on%info,%func;on%info% jedi.el% typing,mands,%etc.% jedi%Library% Your%Emacs%Session% JediDependencies JedidependsonsomePythonpackagesnotinstalledbypackage.el.Youhavetwochoices: LetJedihandleitRequiresvirtualenvandpiptobeinstalledAone-timeM-xjedi:install-serverDependenciesareinstalledinsandboxedenvironmentDoesn’twork(yet)withotherpackagemanagers(e.g.conda) DoityourselfNecessaryifyoucan’tusevirtualenv/pipInstallepcandjedipythonmodulesgloballyNeedtoensuretheyareavailabletoJediserverMayneedtopointJeditoaparticularinstalledPython Configuration Thebareminimum:(require’jedi);;Hookuptoplete(add-to-list’ac-sources’ac-source-jedi-direct);;Enableforpython-mode(add-hook’python-mode-hook’jedi:setup) JediServerOptions Findingyourproject(--sys-path)Findingyourinstalledmodules(--virtual-env) NotethattheactivevirtualenvcanbefoundautomaticallyDetails:C-hvjedi:server-args Configuration(Simplified) (defvarjedi-config:with-virtualenvnil"Settonon-niltopointtoaparticularvirtualenv.") ;;Variablestohelpfindtheprojectroot(defvarjedi-config:vcs-root-sentinel".git")(defvarjedi-config:python-module-sentinel"__init__.py") ;;Functiontofindprojectrootgivenabuffer(defunget-project-root(bufrepo-typeinit-file) (vc-find-root(expand-file-name(buffer-file-namebuf))repo-type)) (defvarjedi-config:find-root-function’get-project-root) ;;Andcallthisoninitialization(defuncurrent-buffer-project-root() (funcalljedi-config:find-root-function(current-buffer)jedi-config:vcs-root-sentineljedi-config:python-module-sentinel)) (Seeonlineforfancier,morerobustversion.) Settheserverargs Alist:(ARG1VALUE1ARG2VALUE2...)Storeinbufferlocalvariablejedi:server-args (defunjedi-config:setup-server-args();;littlehelpermacro(defmacroadd-args(arg-listarg-namearg-value)‘(setq,arg-list(append,arg-list(list,arg-name,arg-value)))) (let((project-root(current-buffer-project-root))) ;;Variableforthisbufferonly(make-local-variable’jedi:server-args) ;;Andsetourvariables(whenproject-root (add-argsjedi:server-args"--sys-path"project-root))(whenjedi-config:with-virtualenv (add-argsjedi:server-args"--virtual-env"jedi-config:with-virtualenv)))) Sidebar:FindingPython Ifyoucan’tusevirtualenv,youmightneedtoexplicitlyselectaPythontorun. Also,onMacOSX(andperhapsotherGUIenvironments),yourPATHmayneedtobesetexplicitly. (defvarjedi-config:use-system-pythont) (defunjedi-config:set-python-executable()(set-exec-path-from-shell-PATH);;forOSX(make-local-variable’jedi:mand)(set’jedi:mand(list(executable-find"python")(cadrmand)))) Puttingeverythingtogether (add-hook’python-mode-hook’jedi-config:setup-server-args) (whenjedi-config:use-system-python(add-hook’python-mode-hook’jedi-config:set-python-executable)) Somemands Description jedi:goto-definitionMovetodefinitionofsymbolatpoint DefaultSuggestC-c.M-. jedi:goto-definition-pop-markerMovetopreviouslocationofpoint C-c,M-, jedi:show-docShowdocstringforsymbolatpointinnewwindow C-c?
M-?
jedi:get-in-function-callPopupsignatureforfunctionatpoint None M-/ LocalJedikeybindings (defunjedi-config:setup-keys()(local-set-key(kbd"M-.")’jedi:goto-definition)(local-set-key(kbd"M-,")’jedi:goto-definition-pop-marker)(local-set-key(kbd"M-?
")’jedi:show-doc)(local-set-key(kbd"M-/")’jedi:get-in-function-call)) (add-hook’python-mode-hook’jedi-config:setup-keys) JediMiscellany Smallhacktonevershowin-functioncallautomatically:(setqjedi:get-in-function-call-delay10000000)mendedifyoubindthistoakey Completewhenyoutypeadot:(setqplete-on-dott)Usefulwhentypingmethodcalls OtherPackages Variousotherpackagesusesimilartechniquestoprovideintelligentdocumentationpletion. robe(Ruby)irony-mode(C/C++)gocode(golang)CEDET(Various)Others?
Questions?
Happyediting!
/wernerdrew/jedi-starter @wernerdrew

标签: #环境 #文件格式 #文件 #文件管理 #文件 #后缀名 #管理体系 #美工