diff --git a/docs/modules.org b/docs/modules.org index 477b2e5ae..d06998879 100644 --- a/docs/modules.org +++ b/docs/modules.org @@ -113,7 +113,7 @@ Modules that bring support for a language or group of languages to Emacs. + [[file:../modules/lang/idris/README.org][idris]] - TODO + java =+meghanada +lsp= - TODO + [[file:../modules/lang/javascript/README.org][javascript]] =+lsp= - JavaScript, TypeScript, and CoffeeScript support -+ julia - TODO ++ julia =+lsp= - TODO + kotlin =+lsp+= - TODO + [[file:../modules/lang/latex/README.org][latex]] =+latexmk +cdlatex +fold= - TODO + lean - TODO diff --git a/modules/lang/julia/README.org b/modules/lang/julia/README.org new file mode 100644 index 000000000..45d073b34 --- /dev/null +++ b/modules/lang/julia/README.org @@ -0,0 +1,67 @@ +#+TITLE: lang/julia +#+DATE: April 8, 2020 +#+SINCE: {replace with next tagged release version} +#+STARTUP: inlineimages nofold + +* Table of Contents :TOC_3:noexport: +- [[#description][Description]] + - [[#module-flags][Module Flags]] + - [[#plugins][Plugins]] +- [[#prerequisites][Prerequisites]] + - [[#language-server][Language Server]] +- [[#features][Features]] + - [[#language-server-1][Language Server]] +- [[#configuration][Configuration]] + +* Description +Adds Julia support to Doom Emacs + ++ Syntax highlighting and latex symbols from ~julia-mode~ ++ REPL integration from ~julia-repl~ ++ Code completion and syntax checking, requires ~:tools lsp~ and ~+lsp~ + +** Module Flags ++ =+lsp= Language Server Protocol support +** Plugins ++ [[https://github.com/tpapp/julia-repl][julia-mode]] ++ [[https://github.com/JuliaEditorSupport/julia-emacs/][julia-repl]] ++ =+lsp= and =:tools lsp= + + [[https://github.com/non-jedi/lsp-julia][lsp-julia]]* + + [[https://github.com/emacs-lsp/lsp-mode][lsp]] + +* Prerequisites +This module has no direct prerequisites. + +** Language Server + +~+lsp~ requires the a manual installation of ~lsp-julia~ as it comes with a +packaged version of ~LanguageServer.jl~ and its dependencies. + +#+BEGIN_SRC elisp +;; ~/.doom.d/packages.el +(package! lsp-julia :recipe (:host github :repo "non-jedi/lsp-julia")) +#+END_SRC + +* Features + # An in-depth list of features, how to use them, and their dependencies. +** Language Server + ~+lsp~ adds code completion, syntax checking, formatting and other ~lsp-mode~ + features. This requires a manual installation of ~lsp-julia~ as it bundles + ~LanguageServer.jl~ and its dependencies. + +* Configuration +~lsp-julia~ requires a variable be set for the Julia environment. This is set to +v1.0 by default as it is the current LTS. + +#+BEGIN_SRC elisp +;; ~/.doom.d/config.el +(setq lsp-julia-default-environment "~/.julia/environments/v1.0") +#+END_SRC + +If you would like to use your own installation of ~LanguageServer.jl~, put the +following in your personal ~config.el~. + +#+BEGIN_SRC elisp +;; ~/.doom.d/config.el +(setq lsp-julia-package-dir nil) +#+END_SRC diff --git a/modules/lang/julia/config.el b/modules/lang/julia/config.el index 8ec3e18ff..b9190ec1c 100644 --- a/modules/lang/julia/config.el +++ b/modules/lang/julia/config.el @@ -5,19 +5,19 @@ :config (set-repl-handler! 'julia-mode #'+julia/open-repl) - ;; Borrow matlab.el's fontification of math operators - ;; From + ;; Borrow matlab.el's fontification of math operators. From + ;; (dolist (mode '(julia-mode ess-julia-mode)) (font-lock-add-keywords mode `((,(let ((OR "\\|")) - (concat "\\(" ;; stolen `matlab.el' operators first + (concat "\\(" ; stolen `matlab.el' operators first "[<>!]=?" OR "\\.[/*^']" OR "==" OR "=>" OR "\\" OR - "[-+*\\/^&|$]=?" OR ;; this has to come before next (updating operators) + "[-+*\\/^&|$]=?" OR ; this has to come before next (updating operators) "[-!^&|*+\\/~:]" OR ;; more extra julia operators follow "[%$]" OR @@ -30,5 +30,35 @@ 1 font-lock-type-face))))) -(after! julia-repl - (add-hook 'julia-repl-hook #'julia-repl-use-emacsclient)) +(use-package! julia-repl + :preface (defvar +julia-repl-start-hook nil) + :hook (julia-mode . julia-repl-mode) + :hook (+julia-repl-start . +julia-override-repl-escape-char-h) + :hook (+julia-repl-start . julia-repl-use-emacsclient) + :config + (set-popup-rule! "^\\*julia.*\\*$" :ttl nil) + + (when (featurep! :ui workspaces) + (defadvice! +julia--namespace-repl-buffer-to-workspace-a (&optional executable-key suffix) + "Name for a Julia REPL inferior buffer. Uses workspace name for doom emacs" + :override #'julia-repl--inferior-buffer-name + (concat julia-repl-inferior-buffer-name-base ":" (+workspace-current-name)))) + + (defadvice! +julia--run-start-hook-a (inferior-buffer) + "Run `+julia-repl-start-hook' before displaying the REPL." + :after #'julia-repl--setup-term + (with-current-buffer inferior-buffer + (run-hooks '+julia-repl-start-hook))) + + (defun +julia-override-repl-escape-char-h () + "Use C-c instead of C-x for escaping." + (term-set-escape-char ?\C-c))) + + +(use-package! lsp-julia + :when (featurep! +lsp) + :after lsp-clients + :preface + (setq lsp-julia-default-environment "~/.julia/environments/v1.0") + (when (featurep! +lsp) + (add-hook 'julia-mode-local-vars-hook #'lsp!)))