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.

220 lines
6.0 KiB

4 years ago
4 years ago
4 years ago
  1. ;; Projects
  2. ;; :PROPERTIES:
  3. ;; :header-args: :tangle modules/projects.el
  4. ;; :END:
  5. ;; An IDE like experience (or better) can be achieved in Emacs using two *Microsoft* open source initiatives.
  6. ;; + [[https://microsoft.github.io/language-server-protocol/][Language Server Protocol]]
  7. ;; + [[https://microsoft.github.io/debug-adapter-protocol/][Debug Adapter Protocol]]
  8. ;; Add support for language servers with [[https://emacs-lsp.github.io/lsp-mode/][lsp-mode]].
  9. (use-package lsp-mode
  10. :commands (lsp lsp-deferred)
  11. :custom (lsp-idle-delay (* 5 dotfiles/idle)))
  12. ;; [[https://emacs-lsp.github.io/lsp-ui/][lsp-ui]] provides UI improvements for =lsp-mode=.
  13. (use-package lsp-ui
  14. :after lsp
  15. :custom (lsp-ui-doc-position 'at-point)
  16. (lsp-ui-doc-delay 0.500))
  17. ;; [[https://emacs-lsp.github.io/dap-mode/][Dap-mode]] adds support for the debug adapter protocol to Emacs.
  18. (use-package dap-mode
  19. :commands (dap-debug))
  20. ;; Containers
  21. ;; Use ~docker~ for running containers. Download and install https://github.com/Silex/docker.el, allowing us to manage containers within Emacs.
  22. (use-package docker
  23. :commands (docker))
  24. ;; Open the management screen with =SPC k=.
  25. (dotfiles/leader
  26. "k" '(docker :which-key "Docker"))
  27. ;; Management
  28. ;; Configure [[https://projectile.mx][projectile]], a project interaction library for Emacs. It provides a nice set of features for operating on a project level without introducing external dependencies.
  29. (use-package projectile
  30. :custom (projectile-project-search-path '("~/.local/source"))
  31. :config (projectile-mode))
  32. ;; Completion
  33. ;; Text completion framework via =company= aka *Complete Anything*.
  34. ;; http://company-mode.github.io/
  35. ;; + Integrate with =lsp-mode=
  36. (use-package company
  37. :after lsp)
  38. (use-package company-lsp
  39. :after (lsp company)
  40. :custom (company-backend 'company-lsp))
  41. ;; Passwords
  42. ;; Pass makes managing passwords extremely easy, encrypring them in a file structure and providing easy commands for generating, modify, and copying passwords. =password-store.el= provides a wrapper for the functionality within Emacs.
  43. (use-package password-store
  44. :custom (password-store-dir dotfiles/passwords))
  45. ;; Configure keybindings behind =SPC p=.
  46. ;; + Copy with =p=
  47. ;; + Rename with =r=
  48. ;; + Generate with =g=
  49. (dotfiles/leader
  50. "p" '(:ignore t :which-key "Passwords")
  51. "pp" '(password-store-copy :which-key "Copy")
  52. "pr" '(password-store-rename :which-key "Rename")
  53. "pg" '(password-store-generate :which-key "Generate"))
  54. ;; Set the ~GOPATH~ environment variable prior to loading, this allows us to change the default value of ~$HOME/go~ to ~$HOME/.go~.
  55. (setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
  56. ;; Additionally, include the =bin= subdirectory of the ~$GOPATH~ in the ~$PATH~ variable, adding compiled golang programs.
  57. (setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
  58. ;; Finally we can include the =go-mode= package, integrating it with =lsp=.
  59. (use-package go-mode
  60. :hook (go-mode . lsp)
  61. :custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
  62. ;; Apply some custom behaviour before saving:
  63. ;; + Format buffer
  64. ;; + Organize imports
  65. (defun dotfiles/go-hook ()
  66. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  67. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  68. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  69. ;; Add a golang source code block structure template with ~<go~:
  70. (add-to-list 'org-structure-template-alist '("go" . "src go"))
  71. ;; HTTP
  72. ;; Instead of the popular =restclient= package, I use [[https://github.com/zweifisch/ob-http][ob-http]] as a lightweight alternative.
  73. (use-package ob-http
  74. :after org
  75. :config (org-babel-do-load-languages
  76. 'org-babel-load-languages
  77. '((http . t))))
  78. ;; C/C++
  79. ;; #+ATTR_ORG: :width 420px
  80. ;; #+ATTR_HTML: :width 420px
  81. ;; #+ATTR_LATEX: :width 420px
  82. ;; [[./docs/images/2021-02-13-example-ccls.gif]]
  83. ;; Add support for C/C++ languages.
  84. ;; + Configure the [[https://github.com/MaskRay/ccls][ccls]] language server
  85. ;; + Load babel language modules for C/C++
  86. ;; + Create a new structure templates for C/C++
  87. ;; - ~<cc~ for C
  88. ;; - ~<cpp~ for C++
  89. (use-package ccls
  90. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  91. (lambda ()
  92. (require 'ccls)
  93. (lsp-deferred)))
  94. :config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
  95. (add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
  96. (org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
  97. ;; [[https://www.emacswiki.org/emacs/PythonProgrammingInEmacs][Python-mode]] is an Emacs built in mode.
  98. ;; + Load the babel language module for Python
  99. ;; + Add a python source code block structure template with ~<py~
  100. (use-package python-mode
  101. :hook (python-mode . lsp-deferred)
  102. :config (require 'dap-python)
  103. (add-to-list 'org-src-lang-modes '("python" . python))
  104. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  105. (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  106. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  107. (dap-python-executable "python3") ;; Same as above.
  108. (dap-python-debugger 'debugpy))
  109. ;; PlantUML
  110. ;; Download and install [[https://plantuml.com][PlantUML]], a text-based markup language for creating UML diagrams.
  111. ;; + Load the babel language module for PlantUML
  112. ;; + Create a structure template with ~<pl~
  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. ;; Toggle inline images with =SPC t i=.
  123. (dotfiles/leader
  124. "ti" '(org-toggle-inline-images :which-key "Images"))