I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

  1. #+TITLE: Python
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle python.el :comments org
  5. #+PROPERTY: header-args:shell :tangle no
  6. #+PROPERTY: header-args :results silent :eval no-export :comments org
  7. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  8. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  9. Python is an interpreted high-level general-purpose programming language[fn:1].
  10. * Setup
  11. Ensure ~python3~[fn:1] is installed on the system, and the ~lsp~ and ~dap~ modules have been loaded before loading this module.
  12. #+begin_src shell
  13. RUN apt install -y python3 python3-pip
  14. #+end_src
  15. ** Install the language server
  16. Install the ~pyls~[fn:2] language server.
  17. #+begin_src shell
  18. RUN pip3 install --user "python-lsp-server[all]"
  19. #+end_src
  20. * Config
  21. Add support for ~python3~[fn:1], including ~dap~ and ~lsp~ integration. The built-in Emacs mode ~python-mode~[fn:3] handles the rest of the integration.
  22. #+begin_src emacs-lisp
  23. (use-package python-mode
  24. :hook (python-mode . lsp-deferred)
  25. :config (require 'dap-python)
  26. (add-to-list 'org-src-lang-modes '("python" . python))
  27. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  28. (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  29. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  30. (org-babel-python-command "python3") ;; Same as above.
  31. (dap-python-executable "python3") ;; Same as above.
  32. (lsp-pyls-server-command "pylsp")
  33. (dap-python-debugger 'debugpy))
  34. #+end_src
  35. ** Code symbols
  36. Programming buffers can be made prettier with ~pretty-mode~[fn:4], this is complimentary to ~prettify-symbols-mode~[fn:5], a built-in package containing similar (but lacking) functionality.
  37. #+begin_src emacs-lisp
  38. (use-package pretty-mode
  39. :hook (python-mode . turn-on-pretty-mode))
  40. #+end_src
  41. * Footnotes
  42. [fn:1] https://python.org
  43. [fn:2] https://pypi.org/project/python-language-server/
  44. [fn:3] https://emacswiki.org/emacs/PythonProgrammingInEmacs
  45. [fn:4] https://emacswiki.org/emacs/pretty-mode.el
  46. [fn:5] https://emacswiki.org/emacs/PrettySymbol