Browse Source

Separate development / projects

main
parent
commit
f3e162c297
  1. 192
      modules/development.org
  2. 180
      modules/projects.org

192
modules/development.org

@ -0,0 +1,192 @@
#+TITLE: Development
#+AUTHOR: Christopher James Hayward
#+EMAIL: chris@chrishayward.xyz
#+PROPERTY: header-args:emacs-lisp :tangle development.el :comments org
#+PROPERTY: header-args:shell :tangle no
#+PROPERTY: header-args :results silent :eval no-export :comments org
#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
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]
* Go
First class language support for *Golang*[fn:3].
+ Full support of *LSP*[fn:1]
+ Full support of *DAP*[fn:1]
** Installing requirements
Get started by installing the *gopls*[fn:4] language server.
#+begin_src shell
GO111MODULE=on go get golang.org/x/tools/gopls@latest
#+end_src
** Setup the environment
Make some modifications to the environment.
*** Overriding the $GOPATH
Set the =$GOPATH= environment variable prior to loading the module, allowing modification of the default value.
#+begin_src emacs-lisp
(setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
#+end_src
*** Adding $GOBIN to the $PATH
Include the ~bin~ subdirectory of the =$GOPATH= in the =$PATH= variable, adding compiled Golang applications to the system path.
#+begin_src emacs-lisp
(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
#+end_src
** Configuration
Include the *go-mode*[fn:5] package for integration with *lsp-mode* from the [[file:projects.org][Projects]] module.
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp)
:custom (lsp-go-gopls-server-path
(expand-file-name "~/.go/bin/gopls")))
#+end_src
*** Before save hooks
Apply some custom behaviour prior to saving buffers.
+ Format buffers
+ Organize imports
#+begin_src emacs-lisp
(defun dotfiles/go-hook ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'dotfiles/go-hook)
#+end_src
*** Babel structure templates
Add a structure template for *Golang*[fn:3] source blocks.
#+begin_src emacs-lisp
(add-to-list 'org-structure-template-alist '("go" . "src go"))
#+end_src
* HTTP
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.
#+begin_src emacs-lisp
(use-package ob-http
:after org
:config (org-babel-do-load-languages
'org-babel-load-languages '((http . t))))
#+end_src
* C/C++
Add support for the *C/C++* family of languages via the *CCLS*[fn:7] language server.
+ Integrate with *LSP*[fn:2]
+ Integrate with *DAP*[fn:1]
+ Load babel language modules
+ Create new structure templates
* ~<cc~ for *C*
* ~<cpp~ for *C++*
#+begin_src emacs-lisp
(use-package ccls
:hook ((c-mode c++-mode objc-mode cuda-mode) .
(lambda ()
(require 'ccls)
(lsp-deferred)))
:config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
(add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
(org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
#+end_src
** Installing requirements
Some required packages, here's how to install on *Debian/Ubuntu*:
#+begin_src shell
sudo apt install ccls
#+end_src
* Python
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.
+ Load the babel language modules for Python
+ Add a structure template with ~<py~
#+begin_src emacs-lisp
(use-package python-mode
:hook (python-mode . lsp-deferred)
:config (require 'dap-python)
(add-to-list 'org-src-lang-modes '("python" . python))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
:custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
(dap-python-executable "python3") ;; Same as above.
(dap-python-debugger 'debugpy))
#+end_src
** Installing the language server
Install the *pyls*[fn:10] language server.
#+begin_src shell
pip3 install --user "python-language-server[all]"
#+end_src
* PlantUML
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.
+ Load the babel module for *PlantUML*[fn:11]
+ Create a structure template with ~<pl~
#+begin_src emacs-lisp
(use-package plantuml-mode
:after org
:custom (plantuml-default-exec-mode 'jar)
(plantuml-jar-path "~/.local/bin/plantuml.jar")
(org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
(org-startup-with-inline-images t)
:config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
(add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
#+end_src
** View inside of buffers
Toggle inline images with =SPC t i=.
#+begin_src emacs-lisp
(dotfiles/leader
"ti" '(org-toggle-inline-images :which-key "Images"))
#+end_src
* Resources
[fn:1] https://microsoft.github.io/debug-adapter-protocol
[fn:2] https://microsoft.github.io/language-server-protocol
[fn:3] https://golang.org
[fn:4] https://pkg.go.dev/golang.org/x/tools/gopls
[fn:5] https://emacswiki.org/emacs/GoMode
[fn:6] https://github.com/zweifisch/ob-http
[fn:7] https://github.com/MaskRay/ccls
[fn:8] https://python.org
[fn:9] https://emacswiki.org/emacs/PythonProgrammingInEmacs
[fn:10] https://pypi.org/project/python-language-server/
[fn:11] https://plantuml.com
[fn:12] https://github.com/skuro/plantuml-mode

180
modules/projects.org

@ -3,8 +3,8 @@
#+EMAIL: chris@chrishayward.xyz
#+PROPERTY: header-args:emacs-lisp :tangle projects.el :comments org
#+PROPERTY: header-args:shell :tangle no
#+PROPERTY: header-args :results silent :eval no-export :comments org
#+PROPERTY: header-args:shell :tangle no
#+PROPERTY: header-args :results silent :eval no-export :comments org
#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
@ -19,7 +19,7 @@ An *IDE*[fn:1] like experience or better can be achieved within Emacs using two
+ *Debug Adapter Protocol*[fn:3]
+ *Language Server Protocol*[fn:4]
* LSP
* Language servers
Support for the *Language Server Protocol*[fn:4] is added to Emacs through the *Lsp mode*[fn:5] package.
@ -29,7 +29,7 @@ Support for the *Language Server Protocol*[fn:4] is added to Emacs through the *
:custom (lsp-idle-delay (* 5 dotfiles/idle)))
#+end_src
** UI improvements
** UI integration
*Lsp ui*[fn:6] provides user interface improvements for *Lsp mode*[fn:5].
@ -57,7 +57,7 @@ Integrate with *Lsp mode*[fn:5] to provide completion candidates through the *La
:custom (company-backend 'company-lsp))
#+end_src
* DAP
* Debug adapters
*Dap mode*[fn:7] provides support for the *Debug Adapter Protocol*[fn:3] inside of Emacs.
@ -66,7 +66,7 @@ Integrate with *Lsp mode*[fn:5] to provide completion candidates through the *La
:commands (dap-debug))
#+end_src
* Docker
* Docker containers
Manage *Docker*[fn:8] containers with *Docker.el*[fn:9].
@ -82,7 +82,7 @@ Open the container management screen with =SPC k=.
"k" '(docker :which-key "Docker"))
#+end_src
* Management
* Project management
Configure *Projectile*[fn:11], a project interaction library for Emacs. It provides a nice set of features for operating on a project level without introducing external dependencies.
@ -92,163 +92,6 @@ Configure *Projectile*[fn:11], a project interaction library for Emacs. It provi
:config (projectile-mode))
#+end_src
* Languages
Support for individual programming languages are implemented here. They can be either:
+ LSP / DAP compliant
+ Emacs-mode compliant
+ Third-party module
** Go
Golang is supported using the *Debug Adapter Protocol*[fn:3] and *Language Server Protocol*[fn:4].
*** Setup
Get started by installing *gopls*[fn:14].
#+begin_src shell
GO111MODULE=on go get golang.org/x/tools/gopls@latest
#+end_src
**** Overriding the =$GOPATH=
Set the =$GOPATH= environment variable prior to loading, this is to allow modification of the default value from ~$HOME/go~ to ~$HOME/.go~.
#+begin_src emacs-lisp
(setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
#+end_src
**** Adding =$GOBIN= to the =$PATH=
Additionally, include the ~bin~ subdirectory of the =$GOPATH= in the =$PATH= variable, adding compiled golang programs to the systems path.
#+begin_src emacs-lisp
(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
#+end_src
*** Configuration
Finally we can include the *Go-mode*[fn:15] package, adding integration with *Lsp-mode*[fn:5].
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp)
:custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
#+end_src
Apply some custom behaviour before saving buffers:
+ Format buffer
+ Organize imports
#+begin_src emacs-lisp
(defun dotfiles/go-hook ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
#+end_src
#+begin_src emacs-lisp
(add-hook 'go-mode-hook #'dotfiles/go-hook)
#+end_src
Add a golang source code block structure template with ~<go~:
#+begin_src emacs-lisp
(add-to-list 'org-structure-template-alist '("go" . "src go"))
#+end_src
** HTTP
Interact with HTTP/HTTPS endpoints using the *Ob-http*[fn:16] package. See how it works in my post *Kanye as a Service*[fn:17].
#+begin_src emacs-lisp
(use-package ob-http
:after org
:config (org-babel-do-load-languages
'org-babel-load-languages
'((http . t))))
#+end_src
** C/C++
Add support for the C/C++ family of languages.
+ Configure the *CCLS*[fn:18] language server
+ Load babel language modules for C/C++
+ Create new structure templates for C/C++
* ~<cc~ for C
* ~<cpp~ for C++
#+begin_src emacs-lisp
(use-package ccls
:hook ((c-mode c++-mode objc-mode cuda-mode) .
(lambda ()
(require 'ccls)
(lsp-deferred)))
:config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
(add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
(org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
#+end_src
** Python
Add support for Python / Python 3 with full support for *DAP*[fn:3] and *LSP*[fn:4].
*** Setup
Install the *pyls*[fn:19] language server.
#+begin_src shell
pip3 install --user "python-language-server[all]"
#+end_src
*Python mode*[fn:20] is an Emacs built in mode for working with Python buffers.
+ Load the babel language modules for Python
+ Add a structure template with ~<py~
#+begin_src emacs-lisp
(use-package python-mode
:hook (python-mode . lsp-deferred)
:config (require 'dap-python)
(add-to-list 'org-src-lang-modes '("python" . python))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
:custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
(dap-python-executable "python3") ;; Same as above.
(dap-python-debugger 'debugpy))
#+end_src
** PlantUML
Download and install *PlantUML*[fn:21], a text-based markup language for creating UML diagrams.
+ Load the babel language module for *PlantUML*
+ Create a structure template with ~<pl~
#+begin_src emacs-lisp
(use-package plantuml-mode
:after org
:custom (plantuml-default-exec-mode 'jar)
(plantuml-jar-path "~/.local/bin/plantuml.jar")
(org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
(org-startup-with-inline-images t)
:config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
(add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
#+end_src
*** View inside of buffers
Toggle inline images with =SPC t i=.
#+begin_src emacs-lisp
(dotfiles/leader
"ti" '(org-toggle-inline-images :which-key "Images"))
#+end_src
* Resources
[fn:1] https://en.wikipedia.org/wiki/Integrated_development_environment
@ -264,12 +107,3 @@ Toggle inline images with =SPC t i=.
[fn:11] https://projectile.mx
[fn:12] https://passwordstore.org
[fn:13] https://git.zx2c4.com/password-store/tree/contrib/emacs
[fn:14] https://pkg.go.dev/golang.org/x/tools/gopls
[fn:15] https://emacswiki.org/emacs/GoMode
[fn:16] https://github.com/zweifisch/ob-http
[fn:17] https://chrishayward.xyz/posts/kanye-as-a-service/
[fn:18] https://github.com/MaskRay/ccls
[fn:19] https://pypi.org/project/python-language-server/
[fn:20] https://emacswiki.org/emacs/PythonProgrammingInEmacs
[fn:21] https://plantuml.com
[fn:22] https://github.com/skuro/plantuml-mode
Loading…
Cancel
Save