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.

191 lines
5.9 KiB

4 years ago
  1. #+TITLE: Development
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle development.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. Support for individual programming languages, has a hard dependency on the [[file:projects.org][Projects]] module for integration with *LSP*[fn:1] / *DAP*[fn:2]
  10. * Go
  11. First class language support for *Golang*[fn:3].
  12. + Full support of *LSP*[fn:1]
  13. + Full support of *DAP*[fn:1]
  14. ** Installing requirements
  15. Get started by installing the *gopls*[fn:4] language server.
  16. #+begin_src shell
  17. GO111MODULE=on go get golang.org/x/tools/gopls@latest
  18. #+end_src
  19. ** Setup the environment
  20. Make some modifications to the environment.
  21. *** Overriding the $GOPATH
  22. Set the =$GOPATH= environment variable prior to loading the module, allowing modification of the default value.
  23. #+begin_src emacs-lisp
  24. (setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
  25. #+end_src
  26. *** Adding $GOBIN to the $PATH
  27. Include the ~bin~ subdirectory of the =$GOPATH= in the =$PATH= variable, adding compiled Golang applications to the system path.
  28. #+begin_src emacs-lisp
  29. (setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
  30. #+end_src
  31. ** Configuration
  32. Include the *go-mode*[fn:5] package for integration with *lsp-mode* from the [[file:projects.org][Projects]] module.
  33. #+begin_src emacs-lisp
  34. (use-package go-mode
  35. :hook (go-mode . lsp)
  36. :custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
  37. #+end_src
  38. *** Before save hooks
  39. Apply some custom behaviour prior to saving buffers.
  40. + Format buffers
  41. + Organize imports
  42. #+begin_src emacs-lisp
  43. (defun dotfiles/go-hook ()
  44. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  45. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  46. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  47. #+end_src
  48. *** Babel structure templates
  49. Add a structure template for *Golang*[fn:3] source blocks.
  50. #+begin_src emacs-lisp
  51. (add-to-list 'org-structure-template-alist '("go" . "src go"))
  52. #+end_src
  53. * HTTP
  54. Interactive with *HTTP* endpoints using the *ob-http*[fn:6] package. You can see how it works in my post [[file:../docs/posts/kanye-as-a-service.org.gpg][Kanye as a Service]]. Essentialy it adds interactive *HTTP* blocks that can output their results in place.
  55. #+begin_src emacs-lisp
  56. (use-package ob-http
  57. :after org
  58. :config (org-babel-do-load-languages
  59. 'org-babel-load-languages '((http . t))))
  60. #+end_src
  61. * C/C++
  62. Add support for the *C/C++* family of languages via the *CCLS*[fn:7] language server.
  63. + Integrate with *LSP*[fn:2]
  64. + Integrate with *DAP*[fn:1]
  65. + Load babel language modules
  66. + Create new structure templates
  67. * ~<cc~ for *C*
  68. * ~<cpp~ for *C++*
  69. #+begin_src emacs-lisp
  70. (use-package ccls
  71. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  72. (lambda ()
  73. (require 'ccls)
  74. (lsp-deferred)))
  75. :config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
  76. (add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
  77. (org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
  78. #+end_src
  79. ** Installing requirements
  80. Some required packages, here's how to install on *Debian/Ubuntu*:
  81. #+begin_src shell
  82. sudo apt install ccls
  83. #+end_src
  84. * Python
  85. Adds support for *Python* and *Python 3*[fn:8] with *DAP*[fn:1] and *LSP*[fn:2] integration. The built in Emacs mode *python-mode*[fn:9] implements the behaviour.
  86. + Load the babel language modules for Python
  87. + Add a structure template with ~<py~
  88. #+begin_src emacs-lisp
  89. (use-package python-mode
  90. :hook (python-mode . lsp-deferred)
  91. :config (require 'dap-python)
  92. (add-to-list 'org-src-lang-modes '("python" . python))
  93. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  94. (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  95. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  96. (dap-python-executable "python3") ;; Same as above.
  97. (dap-python-debugger 'debugpy))
  98. #+end_src
  99. ** Installing the language server
  100. Install the *pyls*[fn:10] language server.
  101. #+begin_src shell
  102. pip3 install --user "python-language-server[all]"
  103. #+end_src
  104. * PlantUML
  105. Download and install *PlantUML*[fn:11], a text-based markup language for creating UML diagrams. You can read my notes about the tool [[file:../docs/notes/plantuml.org.gpg][PlantUML]] here. Support added through the *plantuml-mode*[fn:12] package.
  106. + Load the babel module for *PlantUML*[fn:11]
  107. + Create a structure template with ~<pl~
  108. #+begin_src emacs-lisp
  109. (use-package plantuml-mode
  110. :after org
  111. :custom (plantuml-default-exec-mode 'jar)
  112. (plantuml-jar-path "~/.local/bin/plantuml.jar")
  113. (org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
  114. (org-startup-with-inline-images t)
  115. :config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  116. (add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
  117. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
  118. #+end_src
  119. ** View inside of buffers
  120. Toggle inline images with =SPC t i=.
  121. #+begin_src emacs-lisp
  122. (dotfiles/leader
  123. "ti" '(org-toggle-inline-images :which-key "Images"))
  124. #+end_src
  125. * Resources
  126. [fn:1] https://microsoft.github.io/debug-adapter-protocol
  127. [fn:2] https://microsoft.github.io/language-server-protocol
  128. [fn:3] https://golang.org
  129. [fn:4] https://pkg.go.dev/golang.org/x/tools/gopls
  130. [fn:5] https://emacswiki.org/emacs/GoMode
  131. [fn:6] https://github.com/zweifisch/ob-http
  132. [fn:7] https://github.com/MaskRay/ccls
  133. [fn:8] https://python.org
  134. [fn:9] https://emacswiki.org/emacs/PythonProgrammingInEmacs
  135. [fn:10] https://pypi.org/project/python-language-server/
  136. [fn:11] https://plantuml.com
  137. [fn:12] https://github.com/skuro/plantuml-mode