From b2368527d3da05df8f45d206f34c5d3251660fad Mon Sep 17 00:00:00 2001 From: AlexLewandowski Date: Wed, 8 Apr 2020 14:33:27 -0600 Subject: [PATCH 1/7] Julia:added LSP and repl buffername uses workspace --- modules/lang/julia/README.org | 50 ++++++++++++++++++++++++++++++++++ modules/lang/julia/config.el | 29 +++++++++++++++++++- modules/lang/julia/packages.el | 3 ++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 modules/lang/julia/README.org diff --git a/modules/lang/julia/README.org b/modules/lang/julia/README.org new file mode 100644 index 000000000..91f0d9d28 --- /dev/null +++ b/modules/lang/julia/README.org @@ -0,0 +1,50 @@ +#+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]] +- [[#features][Features]] + - [[#language-server][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. + +* Features + # An in-depth list of features, how to use them, and their dependencies. +** Language Server + ~lsp-julia~ comes with an installation of ~LanguageServer.jl~ currently compatible with Julia v1.0.5 (current LTS) and Julia v1.3. +* Configuration +~lsp-julia~ requires a variable be set for the Julia environment. This is set to v1.0 by default. + +#+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..5c225050c 100644 --- a/modules/lang/julia/config.el +++ b/modules/lang/julia/config.el @@ -1,9 +1,17 @@ ;;; lang/julia/config.el -*- lexical-binding: t; -*- + (use-package! julia-mode :interpreter "julia" :config + + (when (featurep! +lsp) + (add-hook 'julia-mode-hook #'lsp!) + (setq lsp-julia-default-environment "~/.julia/environments/v1.0") + ) + (set-repl-handler! 'julia-mode #'+julia/open-repl) + (add-hook 'julia-mode-hook #'julia-repl-mode) ;; Borrow matlab.el's fontification of math operators ;; From @@ -31,4 +39,23 @@ (after! julia-repl - (add-hook 'julia-repl-hook #'julia-repl-use-emacsclient)) + (add-hook 'julia-repl-hook #'julia-repl-use-emacsclient) + + (defadvice! julia-repl--buffer-name (&optional executable-key suffix) + :override #'julia-repl--inferior-buffer-name + "Name for a Julia REPL inferior buffer. Uses workspace name for doom emacs" + (concat julia-repl-inferior-buffer-name-base ":" (+workspace-current-name))) + + (set-popup-rule! "^\\*julia.*\\*$" :ttl nil) + + (defadvice! after-julia-repl-advice (inferior-buffer) + :after #'julia-repl--setup-term + (with-current-buffer inferior-buffer + (term-set-escape-char ?\C-c) ; override default of C-x.. + )) + ) + +(use-package! lsp-julia + :when (featurep! +lsp) + :after lsp-clients + ) diff --git a/modules/lang/julia/packages.el b/modules/lang/julia/packages.el index 1c6ad1e40..607569f70 100644 --- a/modules/lang/julia/packages.el +++ b/modules/lang/julia/packages.el @@ -3,3 +3,6 @@ (package! julia-mode :pin "1c122f1dff") (package! julia-repl :pin "5fa04de4e7") + +(when (featurep! +lsp) + (package! lsp-julia :recipe (:host github :repo "non-jedi/lsp-julia") :pin "9f158a2")) From 9568023b83b8359022d16f3b5ba6f0fb91827d44 Mon Sep 17 00:00:00 2001 From: AlexLewandowski Date: Wed, 8 Apr 2020 14:52:45 -0600 Subject: [PATCH 2/7] Remove default installation of lsp-julia --- modules/lang/julia/README.org | 20 +++++++++++++++++--- modules/lang/julia/packages.el | 3 --- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/lang/julia/README.org b/modules/lang/julia/README.org index 91f0d9d28..dd014f630 100644 --- a/modules/lang/julia/README.org +++ b/modules/lang/julia/README.org @@ -8,8 +8,9 @@ - [[#module-flags][Module Flags]] - [[#plugins][Plugins]] - [[#prerequisites][Prerequisites]] -- [[#features][Features]] - [[#language-server][Language Server]] +- [[#features][Features]] + - [[#language-server-1][Language Server]] - [[#configuration][Configuration]] * Description @@ -31,12 +32,24 @@ Adds Julia support to Doom Emacs * 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-julia~ comes with an installation of ~LanguageServer.jl~ currently compatible with Julia v1.0.5 (current LTS) and Julia v1.3. + ~lsp-julia~ comes with an installation of ~LanguageServer.jl~ currently + compatible with Julia v1.0.5 (current LTS) and Julia v1.3. + * Configuration -~lsp-julia~ requires a variable be set for the Julia environment. This is set to v1.0 by default. +~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 @@ -44,6 +57,7 @@ This module has no direct prerequisites. #+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) diff --git a/modules/lang/julia/packages.el b/modules/lang/julia/packages.el index 607569f70..1c6ad1e40 100644 --- a/modules/lang/julia/packages.el +++ b/modules/lang/julia/packages.el @@ -3,6 +3,3 @@ (package! julia-mode :pin "1c122f1dff") (package! julia-repl :pin "5fa04de4e7") - -(when (featurep! +lsp) - (package! lsp-julia :recipe (:host github :repo "non-jedi/lsp-julia") :pin "9f158a2")) From 82a659c1d3bde909231437207e8478f03d9ac9fe Mon Sep 17 00:00:00 2001 From: AlexLewandowski Date: Wed, 8 Apr 2020 14:54:18 -0600 Subject: [PATCH 3/7] Add +lsp flag to Julia in docs --- docs/modules.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 69f557831986ce2aba64917764f65b1b18703bae Mon Sep 17 00:00:00 2001 From: AlexLewandowski Date: Wed, 8 Apr 2020 14:56:31 -0600 Subject: [PATCH 4/7] rm newline --- modules/lang/julia/config.el | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/lang/julia/config.el b/modules/lang/julia/config.el index 5c225050c..ecc0c17fe 100644 --- a/modules/lang/julia/config.el +++ b/modules/lang/julia/config.el @@ -1,6 +1,5 @@ ;;; lang/julia/config.el -*- lexical-binding: t; -*- - (use-package! julia-mode :interpreter "julia" :config From d6fe5dad6504b7d872d4dc3d10d9d41e10c4bf01 Mon Sep 17 00:00:00 2001 From: AlexLewandowski Date: Wed, 8 Apr 2020 15:01:25 -0600 Subject: [PATCH 5/7] Update Julia README.org --- modules/lang/julia/README.org | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/lang/julia/README.org b/modules/lang/julia/README.org index dd014f630..45d073b34 100644 --- a/modules/lang/julia/README.org +++ b/modules/lang/julia/README.org @@ -26,7 +26,7 @@ Adds Julia support to Doom Emacs + [[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/non-jedi/lsp-julia][lsp-julia]]* + [[https://github.com/emacs-lsp/lsp-mode][lsp]] * Prerequisites @@ -45,18 +45,21 @@ packaged version of ~LanguageServer.jl~ and its dependencies. * Features # An in-depth list of features, how to use them, and their dependencies. ** Language Server - ~lsp-julia~ comes with an installation of ~LanguageServer.jl~ currently - compatible with Julia v1.0.5 (current LTS) and Julia v1.3. + ~+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. +~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~. +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 From cd156fcc0aa8a13316de30072e5c0f08bd50b077 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 8 Apr 2020 17:34:53 -0400 Subject: [PATCH 6/7] Refactor julia module --- modules/lang/julia/config.el | 45 +++++++++++++++++------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/modules/lang/julia/config.el b/modules/lang/julia/config.el index ecc0c17fe..b00ffebbc 100644 --- a/modules/lang/julia/config.el +++ b/modules/lang/julia/config.el @@ -3,28 +3,21 @@ (use-package! julia-mode :interpreter "julia" :config - - (when (featurep! +lsp) - (add-hook 'julia-mode-hook #'lsp!) - (setq lsp-julia-default-environment "~/.julia/environments/v1.0") - ) - (set-repl-handler! 'julia-mode #'+julia/open-repl) - (add-hook 'julia-mode-hook #'julia-repl-mode) - ;; 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 @@ -37,24 +30,28 @@ 1 font-lock-type-face))))) -(after! julia-repl - (add-hook 'julia-repl-hook #'julia-repl-use-emacsclient) - - (defadvice! julia-repl--buffer-name (&optional executable-key suffix) - :override #'julia-repl--inferior-buffer-name - "Name for a Julia REPL inferior buffer. Uses workspace name for doom emacs" - (concat julia-repl-inferior-buffer-name-base ":" (+workspace-current-name))) - +(use-package! julia-repl + :hook (julia-repl-mode . julia-repl-use-emacsclient) + :config (set-popup-rule! "^\\*julia.*\\*$" :ttl nil) - (defadvice! after-julia-repl-advice (inferior-buffer) + (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--override-repl-escape-char-a (inferior-buffer) + "Use C-c instead of C-x for escaping." :after #'julia-repl--setup-term (with-current-buffer inferior-buffer - (term-set-escape-char ?\C-c) ; override default of C-x.. - )) - ) + (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!))) From eec3968802a8dacf4289f22f0956ed85f2431c12 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 8 Apr 2020 17:43:42 -0400 Subject: [PATCH 7/7] Defer julia REPL --- modules/lang/julia/config.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/lang/julia/config.el b/modules/lang/julia/config.el index b00ffebbc..b9190ec1c 100644 --- a/modules/lang/julia/config.el +++ b/modules/lang/julia/config.el @@ -31,7 +31,10 @@ (use-package! julia-repl - :hook (julia-repl-mode . julia-repl-use-emacsclient) + :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) @@ -41,11 +44,15 @@ :override #'julia-repl--inferior-buffer-name (concat julia-repl-inferior-buffer-name-base ":" (+workspace-current-name)))) - (defadvice! +julia--override-repl-escape-char-a (inferior-buffer) - "Use C-c instead of C-x for escaping." + (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 - (term-set-escape-char ?\C-c)))) + (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