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.

199 lines
6.0 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. * YAML
  62. Support for YAML files.
  63. #+begin_src emacs-lisp
  64. (use-package yaml-mode)
  65. #+end_src
  66. * C/C++
  67. Add support for the *C/C++* family of languages via the *CCLS*[fn:7] language server.
  68. + Integrate with *LSP*[fn:2]
  69. + Integrate with *DAP*[fn:1]
  70. + Load babel language modules
  71. + Create new structure templates
  72. * ~<cc~ for *C*
  73. * ~<cpp~ for *C++*
  74. #+begin_src emacs-lisp
  75. (use-package ccls
  76. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  77. (lambda ()
  78. (require 'ccls)
  79. (lsp-deferred)))
  80. :config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
  81. (add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
  82. (org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
  83. #+end_src
  84. ** Installing requirements
  85. Some required packages, here's how to install on *Debian/Ubuntu*:
  86. #+begin_src shell
  87. sudo apt install ccls
  88. #+end_src
  89. * Python
  90. 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.
  91. + Load the babel language modules for Python
  92. + Add a structure template with ~<py~
  93. #+begin_src emacs-lisp
  94. (use-package python-mode
  95. :hook (python-mode . lsp-deferred)
  96. :config (require 'dap-python)
  97. (add-to-list 'org-src-lang-modes '("python" . python))
  98. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  99. (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  100. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  101. (dap-python-executable "python3") ;; Same as above.
  102. (dap-python-debugger 'debugpy))
  103. #+end_src
  104. ** Installing the language server
  105. Install the *pyls*[fn:10] language server.
  106. #+begin_src shell
  107. pip3 install --user "python-language-server[all]"
  108. #+end_src
  109. * PlantUML
  110. 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.
  111. + Load the babel module for *PlantUML*[fn:11]
  112. + Create a structure template with ~<pl~
  113. #+begin_src emacs-lisp
  114. (use-package plantuml-mode
  115. :after org
  116. :custom (plantuml-default-exec-mode 'jar)
  117. (plantuml-jar-path "~/.local/bin/plantuml.jar")
  118. (org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
  119. (org-startup-with-inline-images t)
  120. :config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  121. (add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
  122. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
  123. #+end_src
  124. ** View inside of buffers
  125. Toggle inline images with =SPC t i=.
  126. #+begin_src emacs-lisp
  127. (dotfiles/leader
  128. "ti" '(org-toggle-inline-images :which-key "Images"))
  129. #+end_src
  130. * Resources
  131. [fn:1] https://microsoft.github.io/debug-adapter-protocol
  132. [fn:2] https://microsoft.github.io/language-server-protocol
  133. [fn:3] https://golang.org
  134. [fn:4] https://pkg.go.dev/golang.org/x/tools/gopls
  135. [fn:5] https://emacswiki.org/emacs/GoMode
  136. [fn:6] https://github.com/zweifisch/ob-http
  137. [fn:7] https://github.com/MaskRay/ccls
  138. [fn:8] https://python.org
  139. [fn:9] https://emacswiki.org/emacs/PythonProgrammingInEmacs
  140. [fn:10] https://pypi.org/project/python-language-server/
  141. [fn:11] https://plantuml.com
  142. [fn:12] https://github.com/skuro/plantuml-mode