Browse Source

development -> (go, python)

main
parent
commit
d2fe548027
  1. 2
      elisp/options.el
  2. 110
      modules/development.org
  3. 16
      modules/fonts.org
  4. 75
      modules/go.org
  5. 67
      modules/python.org

2
elisp/options.el

@ -4,7 +4,7 @@
gpg pass x11 exwm roam agenda gpg pass x11 exwm roam agenda
spelling grammar reveal hugo spelling grammar reveal hugo
capture projects docker lsp dap capture projects docker lsp dap
development
development go python
fonts ivy themes modeline dashboard) fonts ivy themes modeline dashboard)
"All of the available modules.") "All of the available modules.")

110
modules/development.org

@ -11,75 +11,6 @@
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] 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.
+ Manually set the ~gopls~ application path
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp)
:custom (lsp-go-gopls-server-path "~/.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 * 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. 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.
@ -122,41 +53,12 @@ Add support for the *C/C++* family of languages via the *CCLS*[fn:7] language se
(org-babel-do-load-languages 'org-babel-load-languages '((C . t)))) (org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
#+end_src #+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.
(org-babel-python-command "python3") ;; Same as above.
(dap-python-executable "python3") ;; Same as above.
(lsp-pyls-server-command "pylsp")
(dap-python-debugger 'debugpy))
#+end_src
** Installing the language server
Install the *pyls*[fn:10] language server.
#+begin_src shell
pip3 install --user "python-lsp-server[all]"
#+end_src
* PlantUML * 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.
Download and install *PlantUML*[fn:8], 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:9] package.
+ Install requirements + Install requirements
+ Load the babel module for *PlantUML*[fn:11]
+ Load the babel module for *PlantUML*[fn:8]
+ Create a structure template with ~<pl~ + Create a structure template with ~<pl~
+ Toggle inline imagines with =SPC t i= + Toggle inline imagines with =SPC t i=
@ -189,12 +91,12 @@ Download and install *PlantUML*[fn:11], a text-based markup language for creatin
[fn:7] https://github.com/MaskRay/ccls [fn:7] https://github.com/MaskRay/ccls
[fn:8] https://python.org
[fn:8] https://plantuml.com
[fn:9] https://emacswiki.org/emacs/PythonProgrammingInEmacs
[fn:9] https://github.com/skuro/plantuml-mode
[fn:10] https://pypi.org/project/python-language-server/ [fn:10] https://pypi.org/project/python-language-server/
[fn:11] https://plantuml.com
[fn:11] https://emacswiki.org/emacs/PythonProgrammingInEmacs
[fn:12] https://github.com/skuro/plantuml-mode
[fn:12] https://python.org

16
modules/fonts.org

@ -54,18 +54,10 @@ It's finally here, first class support for Emojis in Emacs via the ~emacs-emojif
:hook (after-init . global-emojify-mode)) :hook (after-init . global-emojify-mode))
#+end_src #+end_src
** Symbols
Programming buffers can be made prettier with ~pretty-mode~[fn:5], this is complimentary to ~prettify-symbols-mode~[fn:6], a built-in package containing similar (but lacking) functionality.
#+begin_src emacs-lisp
(use-package pretty-mode
:hook (python-mode . turn-on-pretty-mode))
#+end_src
** Ligatures ** Ligatures
Enable ~firacode~[fn:1] font ligatures with the ~fira-code-mode~[fn:7] package. Only perform this action when ~firacode~[fn:1] is the current font, and Emacs isn't running on the TTY.
Enable ~firacode~[fn:1] font ligatures with the ~fira-code-mode~[fn:5] package. Only perform this action when ~firacode~[fn:1] is the current font, and Emacs isn't running on the TTY.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package fira-code-mode (use-package fira-code-mode
@ -118,8 +110,4 @@ Scale the text inside of buffers using the custom transient binding, behind =SPC
[fn:4] https://github.com/Fanael/rainbow-delimiters [fn:4] https://github.com/Fanael/rainbow-delimiters
[fn:5] https://emacswiki.org/emacs/pretty-mode.el
[fn:6] https://emacswiki.org/emacs/PrettySymbol
[fn:7] https://github.com/jming422/fira-code-mode
[fn:5] https://github.com/jming422/fira-code-mode

75
modules/go.org

@ -0,0 +1,75 @@
#+TITLE: Go
#+AUTHOR: Christopher James Hayward
#+EMAIL: chris@chrishayward.xyz
#+PROPERTY: header-args:emacs-lisp :tangle go.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
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software[fn:1]
* Setup
Install ~golang~[fn:1] on your system, and configure your environment prior to loading this module.
#+begin_src shell
RUN apt install -y golang
#+end_src
** Language server
Get started by installing the ~gopls~[fn:2] 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. Set the =$GOPATH= variable prior to loading, allowing modification of the default value. Include the =bin= subdirectory of the =$GOPATH= in the =$PATH= variable, adding compiled golang applications to the system path.
#+begin_src emacs-lisp
(setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
#+end_src
* Config
Use the ~go-mode~[fn:3] package for integration with ~lsp-mode~, manually setting the path to ~gopls~[fn:2] before loading.
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp)
:custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
#+end_src
** Before save hooks
Apply some custom behaviour when saving ~golang~[fn:1] buffers. Format and organize the imports before saving.
#+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
Configure the ~babel~ engine to support ~golang~[fn:1] source blocks.
#+begin_src emacs-lisp
(add-to-list 'org-structure-template-alist '("go" . "src go"))
#+end_src
* Footnotes
[fn:1] https://golang.org
[fn:2] https://pkg.go.dev/golang.org/x/tools/gopls
[fn:3] https://emacswiki.org/emacs/GoMode

67
modules/python.org

@ -0,0 +1,67 @@
#+TITLE: Python
#+AUTHOR: Christopher James Hayward
#+EMAIL: chris@chrishayward.xyz
#+PROPERTY: header-args:emacs-lisp :tangle python.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
Python is an interpreted high-level general-purpose programming language[fn:1].
* Setup
Ensure ~python3~[fn:1] is installed on the system, and the ~lsp~ and ~dap~ modules have been loaded before loading this module.
#+begin_src shell
RUN apt install -y python3 python3-pip
#+end_src
** Install the language server
Install the ~pyls~[fn:2] language server.
#+begin_src shell
RUN pip3 install --user "python-lsp-server[all]"
#+end_src
* Config
Add support for ~python3~[fn:1], including ~dap~ and ~lsp~ integration. The built-in Emacs mode ~python-mode~[fn:3] handles the rest of the integration.
#+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.
(org-babel-python-command "python3") ;; Same as above.
(dap-python-executable "python3") ;; Same as above.
(lsp-pyls-server-command "pylsp")
(dap-python-debugger 'debugpy))
#+end_src
** Code symbols
Programming buffers can be made prettier with ~pretty-mode~[fn:4], this is complimentary to ~prettify-symbols-mode~[fn:5], a built-in package containing similar (but lacking) functionality.
#+begin_src emacs-lisp
(use-package pretty-mode
:hook (python-mode . turn-on-pretty-mode))
#+end_src
* Footnotes
[fn:1] https://python.org
[fn:2] https://pypi.org/project/python-language-server/
[fn:3] https://emacswiki.org/emacs/PythonProgrammingInEmacs
[fn:4] https://emacswiki.org/emacs/pretty-mode.el
[fn:5] https://emacswiki.org/emacs/PrettySymbol
Loading…
Cancel
Save