#+title: Emacs Programming Language Setup

* Shell Script
Run =eglot= on shell script files.
#+begin_src emacs-lisp
  (add-hook 'sh-mode-hook 'jj/eglot-setup)
#+end_src

* C
Run =eglot= on C and C++ files.
#+begin_src emacs-lisp
  (add-hook 'c-mode-hook 'jj/eglot-setup)
  (add-hook 'c++-mode-hook 'jj/eglot-setup)
  (add-hook 'cc-mode-hook 'jj/eglot-setup)
#+end_src

Run =eglot= on CMake files.
#+begin_src emacs-lisp
  (use-package cmake-mode
    :init
    (add-hook 'cmake-mode-hook 'jj/eglot-setup))
#+end_src

Turn off C mode in =lex= and =yacc= files.
#+begin_src emacs-lisp
  (add-to-list 'auto-mode-alist '("\\.l$" . prog-mode))
  (add-to-list 'auto-mode-alist '("\\.y$" . prog-mode))
#+end_src

* Web
Run =eglot= on HTML files.
#+begin_src emacs-lisp
  (add-hook 'html-mode-hook 'jj/eglot-setup)
#+end_src

Run =eglot= on CSS files.
#+begin_src emacs-lisp
  (add-hook 'css-mode-hook 'jj/eglot-setup)
#+end_src

Run =eglot= on JavaScript files.
#+begin_src emacs-lisp
  (add-hook 'js-json-mode-hook 'jj/eglot-setup)
  (add-hook 'js-mode-hook 'jj/eglot-setup)
#+end_src

* Python
Run =eglot= on Python files.
#+begin_src emacs-lisp
  (add-hook 'python-mode-hook 'jj/eglot-setup)
#+end_src

* Go
Install Go support and run =eglot= on Go files.
#+begin_src emacs-lisp
  (use-package go-mode
    :init
    (add-hook 'go-mode-hook 'jj/eglot-setup))
#+end_src

Get documentation for Go variables, functions, and arguments.
#+begin_src emacs-lisp
  (use-package go-eldoc
    :init
    (add-hook 'go-mode-hook 'go-eldoc-setup))
#+end_src

Automatically generate tests in Go.
#+begin_src emacs-lisp
  (use-package go-gen-test)
#+end_src

Get refactoring tools from =go-guru=.
#+begin_src emacs-lisp
  (use-package go-guru
    :hook (go-mode . go-guru-hl-identifier-mode))
#+end_src

* Lua
Install Lua support and run =eglot= on Lua files.
#+begin_src emacs-lisp
  (use-package lua-mode
    :init
    (add-hook 'lua-mode-hook 'jj/eglot-setup))
#+end_src

Better Lisp editing with =lispy=.
#+begin_src emacs-lisp
  (use-package lispy
    :hook (emacs-lisp-mode . lispy-mode))
  (use-package lispyville
    :after lispy
    :hook (lispy-mode . lispyville-mode))
#+end_src

Better parentheses handling in lisp with =parinfer-rust-mode=.
#+begin_src emacs-lisp
  (use-package parinfer-rust-mode
    :hook (emacs-lisp-mode . parinfer-rust-mode)
    :init
    (setq parinfer-rust-auto-download t))
#+end_src

* Markdown
Install Markdown support and run =eglot= on Markdown files.
#+begin_src emacs-lisp
  (use-package markdown-mode
    :init
    (add-hook 'markdown-mode-hook 'jj/eglot-setup))
  (add-hook 'markdown-mode-hook 'variable-pitch-mode)
  (custom-set-faces
   `(variable-pitch ((t :font ,jj/var-font)))
   `(fixed-pitch ((t :font ,jj/mono-font)))
   '(markdown-header-face ((t (:inherit variable-pitch :weight bold))))
   '(markdown-header-face-1 ((t (:inherit markdown-header-face :height 2.0))))
   '(markdown-header-face-2 ((t (:inherit markdown-header-face :height 1.75))))
   '(markdown-header-face-3 ((t (:inherit markdown-header-face :height 1.5))))
   '(markdown-header-face-4 ((t (:inherit markdown-header-face :height 1.25))))
   '(markdown-header-face-5 ((t (:inherit markdown-header-face :height 1.1))))
   '(markdown-header-face-6 ((t (:inherit markdown-header-face :height 1.1))))
   '(markdown-blockquote-face ((t (:inherit fixed-pitch))))
   '(markdown-code-face ((t (:inherit fixed-pitch))))
   '(markdown-html-attr-name-face ((t (:inherit fixed-pitch))))
   '(markdown-html-attr-value-face ((t (:inherit fixed-pitch))))
   '(markdown-html-entity-face ((t (:inherit fixed-pitch))))
   '(markdown-html-tag-delimiter-face ((t (:inherit fixed-pitch))))
   '(markdown-html-tag-name-face ((t (:inherit fixed-pitch))))
   '(markdown-comment-face ((t (:inherit fixed-pitch))))
   '(markdown-header-delimiter-face ((t (:inherit fixed-pitch))))
   '(markdown-hr-face ((t (:inherit fixed-pitch))))
   '(markdown-inline-code-face ((t (:inherit fixed-pitch))))
   '(markdown-language-info-face ((t (:inherit fixed-pitch))))
   '(markdown-language-keyword-face ((t (:inherit fixed-pitch))))
   '(markdown-link-face ((t (:inherit fixed-pitch))))
   '(markdown-markup-face ((t (:inherit fixed-pitch))))
   '(markdown-math-face ((t (:inherit fixed-pitch))))
   '(markdown-metadata-key-face ((t (:inherit fixed-pitch))))
   '(markdown-metadata-value-face ((t (:inherit fixed-pitch))))
   '(markdown-missing-link-face ((t (:inherit fixed-pitch))))
   '(markdown-plain-url-face ((t (:inherit fixed-pitch))))
   '(markdown-reference-face ((t (:inherit fixed-pitch))))
   '(markdown-table-face ((t (:inherit fixed-pitch))))
   '(markdown-url-face ((t (:inherit fixed-pitch)))))
  (add-hook 'markdown-mode-hook 'visual-line-mode)
  (add-hook 'markdown-mode-hook #'(lambda () (display-line-numbers-mode -1)))
  (defun jj/markdown-mode-visual-fill ()
    (setq visual-fill-column-width 100
          visual-fill-column-center-text t)
    (visual-fill-column-mode 1))
  (add-hook 'markdown-mode-hook #'jj/markdown-mode-visual-fill)
  (setq markdown-hide-markup t)
#+end_src

* LaTeX
Run =eglot= on TeX files.
#+begin_src emacs-lisp
  (add-hook 'tex-mode-hook 'jj/eglot-setup)
#+end_src

Use AUCTeX for extra LaTeX integration.
#+begin_src emacs-lisp
  (use-package auctex
    :config
    (add-hook 'LaTeX-mode-hook 'jj/eglot-setup)
    (add-hook 'LaTeX-mode-hook
            (lambda ()
              (put 'LaTeX-mode 'eglot-language-id "latex"))))
#+end_src

Use CDLaTeX for environment and macro insertion.
#+begin_src emacs-lisp
  (use-package cdlatex
    :config
    (add-hook 'LaTeX-mode-hook #'turn-on-cdlatex))
#+end_src

Use =latex-preview-pane= to see the PDF automatically.
#+begin_src emacs-lisp
  (use-package latex-preview-pane
    :config
    (latex-preview-pane-enable))
#+end_src

* YAML
Install YAML support and run =eglot= on YAML files.
#+begin_src emacs-lisp
  (use-package yaml-mode
    :init
    (add-hook 'yaml-mode-hook 'jj/eglot-setup))
#+end_src

* Nix
Install =nix= support and run =eglot= on =nix= files.
#+begin_src emacs-lisp
  (use-package nix-mode
    :mode "\\.nix\\'")
#+end_src