Christopher James Hayward
4 years ago
5 changed files with 151 additions and 119 deletions
-
2elisp/options.el
-
110modules/development.org
-
16modules/fonts.org
-
75modules/go.org
-
67modules/python.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 |
@ -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 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue