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.

198 lines
5.9 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
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. + Manually set the ~gopls~ application path
  34. #+begin_src emacs-lisp
  35. (use-package go-mode
  36. :hook (go-mode . lsp)
  37. :custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
  38. #+end_src
  39. *** Before save hooks
  40. Apply some custom behaviour prior to saving buffers.
  41. + Format buffers
  42. + Organize imports
  43. #+begin_src emacs-lisp
  44. (defun dotfiles/go-hook ()
  45. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  46. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  47. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  48. #+end_src
  49. *** Babel structure templates
  50. Add a structure template for *Golang*[fn:3] source blocks.
  51. #+begin_src emacs-lisp
  52. (add-to-list 'org-structure-template-alist '("go" . "src go"))
  53. #+end_src
  54. * HTTP
  55. 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.
  56. #+begin_src emacs-lisp
  57. (use-package ob-http
  58. :after org
  59. :config (org-babel-do-load-languages
  60. 'org-babel-load-languages '((http . t))))
  61. #+end_src
  62. * YAML
  63. Support for YAML files.
  64. #+begin_src emacs-lisp
  65. (use-package yaml-mode)
  66. #+end_src
  67. * C/C++
  68. Add support for the *C/C++* family of languages via the *CCLS*[fn:7] language server.
  69. + Install requirements
  70. + Integrate with *LSP*[fn:2]
  71. + Integrate with *DAP*[fn:1]
  72. + Load babel language modules
  73. + Create new structure templates
  74. * ~<cc~ for *C*
  75. * ~<cpp~ for *C++*
  76. #+begin_src emacs-lisp
  77. (use-package ccls
  78. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  79. (lambda ()
  80. (require 'ccls)
  81. (lsp-deferred)))
  82. :config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
  83. (add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
  84. (org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
  85. #+end_src
  86. * Python
  87. 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.
  88. + Load the babel language modules for Python
  89. + Add a structure template with ~<py~
  90. #+begin_src emacs-lisp
  91. (use-package python-mode
  92. :hook (python-mode . lsp-deferred)
  93. :config (require 'dap-python)
  94. (add-to-list 'org-src-lang-modes '("python" . python))
  95. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  96. (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  97. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  98. (dap-python-executable "python3") ;; Same as above.
  99. (dap-python-debugger 'debugpy))
  100. #+end_src
  101. ** Installing the language server
  102. Install the *pyls*[fn:10] language server.
  103. #+begin_src shell
  104. pip3 install --user "python-language-server[all]"
  105. #+end_src
  106. * PlantUML
  107. 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.
  108. + Install requirements
  109. + Load the babel module for *PlantUML*[fn:11]
  110. + Create a structure template with ~<pl~
  111. + Toggle inline imagines with =SPC t i=
  112. #+begin_src emacs-lisp
  113. (use-package plantuml-mode
  114. :after org
  115. :custom (plantuml-default-exec-mode 'jar)
  116. (plantuml-jar-path "~/.local/bin/plantuml.jar")
  117. (org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
  118. (org-startup-with-inline-images t)
  119. :config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  120. (add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
  121. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t)))
  122. (dotfiles/leader "ti" '(org-toggle-inline-images :which-key "Images")))
  123. #+end_src
  124. * Footnotes
  125. [fn:1] https://microsoft.github.io/debug-adapter-protocol
  126. [fn:2] https://microsoft.github.io/language-server-protocol
  127. [fn:3] https://golang.org
  128. [fn:4] https://pkg.go.dev/golang.org/x/tools/gopls
  129. [fn:5] https://emacswiki.org/emacs/GoMode
  130. [fn:6] https://github.com/zweifisch/ob-http
  131. [fn:7] https://github.com/MaskRay/ccls
  132. [fn:8] https://python.org
  133. [fn:9] https://emacswiki.org/emacs/PythonProgrammingInEmacs
  134. [fn:10] https://pypi.org/project/python-language-server/
  135. [fn:11] https://plantuml.com
  136. [fn:12] https://github.com/skuro/plantuml-mode