branch: externals/matlab-mode commit c24b2670632f567fe19e5854d01cbc4759a1c4d9 Author: John Ciolfi <john.ciolfi...@gmail.com> Commit: John Ciolfi <john.ciolfi...@gmail.com>
Improved doc on matlab and lsp-mode and added pictures --- doc/matlab-language-server-lsp-mode-files/func2.m | 3 + doc/matlab-language-server-lsp-mode-files/func3.m | 3 + .../lsp-mode-annotated-pictures.pptx | Bin 0 -> 159572 bytes .../lspExample.m | 21 +++++++ .../matlab-and-lsp-mode-flycheck.png | Bin 0 -> 61900 bytes .../matlab-and-lsp-ui-imenu.png | Bin 0 -> 70848 bytes .../matlab-and-lsp-ui-sideline-mode.png | Bin 0 -> 76955 bytes .../matlab-lsp-mode-jump-to-definition.gif | Bin 0 -> 51049 bytes doc/matlab-language-server-lsp-mode.org | 62 +++++++++++++++++++-- 9 files changed, 85 insertions(+), 4 deletions(-) diff --git a/doc/matlab-language-server-lsp-mode-files/func2.m b/doc/matlab-language-server-lsp-mode-files/func2.m new file mode 100644 index 0000000000..dfc700af24 --- /dev/null +++ b/doc/matlab-language-server-lsp-mode-files/func2.m @@ -0,0 +1,3 @@ +function out = func2(in) + out = in + 2; +end diff --git a/doc/matlab-language-server-lsp-mode-files/func3.m b/doc/matlab-language-server-lsp-mode-files/func3.m new file mode 100644 index 0000000000..0590790c71 --- /dev/null +++ b/doc/matlab-language-server-lsp-mode-files/func3.m @@ -0,0 +1,3 @@ +function out=func3(in) + out = in * 3; +end diff --git a/doc/matlab-language-server-lsp-mode-files/lsp-mode-annotated-pictures.pptx b/doc/matlab-language-server-lsp-mode-files/lsp-mode-annotated-pictures.pptx new file mode 100644 index 0000000000..4826c0fd7b Binary files /dev/null and b/doc/matlab-language-server-lsp-mode-files/lsp-mode-annotated-pictures.pptx differ diff --git a/doc/matlab-language-server-lsp-mode-files/lspExample.m b/doc/matlab-language-server-lsp-mode-files/lspExample.m new file mode 100644 index 0000000000..89489b1867 --- /dev/null +++ b/doc/matlab-language-server-lsp-mode-files/lspExample.m @@ -0,0 +1,21 @@ +function out = lspExample(a, b) +% LSPEXAMPLE - Language Server Protocol example +% +% + + f1 = func1(a); + f2 = func2(b); + + f3 = func3(a+b); + + out = f1 + f2 + f3; +end + +function out = func1(in) + out = in + 1; +end + +function out = func2(in) + out = in + 2; +end + diff --git a/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-mode-flycheck.png b/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-mode-flycheck.png new file mode 100644 index 0000000000..85a7d3eae1 Binary files /dev/null and b/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-mode-flycheck.png differ diff --git a/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-ui-imenu.png b/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-ui-imenu.png new file mode 100644 index 0000000000..29c2bb059c Binary files /dev/null and b/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-ui-imenu.png differ diff --git a/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-ui-sideline-mode.png b/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-ui-sideline-mode.png new file mode 100644 index 0000000000..5ac121c577 Binary files /dev/null and b/doc/matlab-language-server-lsp-mode-files/matlab-and-lsp-ui-sideline-mode.png differ diff --git a/doc/matlab-language-server-lsp-mode-files/matlab-lsp-mode-jump-to-definition.gif b/doc/matlab-language-server-lsp-mode-files/matlab-lsp-mode-jump-to-definition.gif new file mode 100644 index 0000000000..21f8953a6f Binary files /dev/null and b/doc/matlab-language-server-lsp-mode-files/matlab-lsp-mode-jump-to-definition.gif differ diff --git a/doc/matlab-language-server-lsp-mode.org b/doc/matlab-language-server-lsp-mode.org index d7e6559e0c..d8d57f46d2 100644 --- a/doc/matlab-language-server-lsp-mode.org +++ b/doc/matlab-language-server-lsp-mode.org @@ -1,10 +1,30 @@ # File: doc/remote-matlab-shell.org +# | Copyright 2025 Free Software Foundation, Inc. +# | +# | This program is free software: you can redistribute it and/or modify +# | it under the terms of the GNU General Public License as published by +# | the Free Software Foundation, either version 3 of the License, or +# | (at your option) any later version. +# | +# | This program is distributed in the hope that it will be useful, +# | but WITHOUT ANY WARRANTY; without even the implied warranty of +# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# | GNU General Public License for more details. +# | +# | You should have received a copy of the GNU General Public License +# | along with this program. If not, see <http://www.gnu.org/licenses/>. +# | +# | Commentary: +# | +# | Use this as a template for creating org-files with MATLAB and other language code blocks. +# | The '#+COMMENT' lines configure org-mode. + + #+startup: showall +#+startup: inlineimages // C-c C-x C-v to toggle, C-c C-x C-M-v to redisplay #+options: toc:nil -# Copyright 2025 Free Software Foundation, Inc. - The [[https://github.com/mathworks/MATLAB-language-server][MATLAB Language Server]], matlabls, is used for code navigation, code completion, go to definition, find references, and more. To use matlabls, @@ -19,9 +39,11 @@ go to definition, find references, and more. To use matlabls, : M-x list-packages - and click on lsp-mode and install it. + and click on =lsp-mode= and install it. You may also want to install - You may also want to install =company= for completions. + - =company= for completions. + - =lsp-ui= for improved visualization of information provided by lsp-mode. See + https://github.com/emacs-lsp/lsp-ui. 2. Download and install the MATLAB language server @@ -76,3 +98,35 @@ go to definition, find references, and more. To use matlabls, : M-. Find the definition of the identifier at point (xref-find-definitions) : M-? Find references to the identifier at point (xref-find-references) : M-, Go back to the previous position in xref history (xref-go-back) + +* Windows Emacs with LSP + +The examples below were created on Windows 11 using Emacs 30.1. The setup I used (May-29-2025): + +1. Install Emacs from [[https://www.gnu.org/software/emacs/download.html]] +2. Install MSYS2 from [[https://www.msys2.org/]] +3. Install gpg from https://www.gpg4win.org/. Note there is a version gpg.exe in MSYS2 that does + not work with the Emacs package manager. Therefore, install gpg4win and place that gpg on the + PATH before the gpg from MSYS2. +4. Install the Emacs packages listed above. +5. Install the MATLAB Lanugage Server as shown above. + +* Code Navigation - Jump to Definition and Back + +Below we are in =lspExample.m= and then type =M-.= to jump to the definition in =func3.m=. We then +type =M-,= to jump back. + +[[file:matlab-language-server-lsp-mode-files/matlab-lsp-mode-jump-to-definition.gif]] + + +* Viewing Issues Without the lsp-ui Package + +[[file:matlab-language-server-lsp-mode-files/matlab-and-lsp-mode-flycheck.png]] + +* Viewing Issues With the lsp-ui Package + +[[file:matlab-language-server-lsp-mode-files/matlab-and-lsp-ui-sideline-mode.png]] + +* Navigation with lsp-ui-imenu + +[[file:matlab-language-server-lsp-mode-files/matlab-and-lsp-ui-imenu.png]]