Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion M2/Macaulay2/packages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ foreach(package IN LISTS PACKAGES)
file(COPY ${package} DESTINATION ${M2_DIST_PREFIX}/${M2_INSTALL_DATADIR})
endif()


## Configuring the command strings
_M2_STRING_CONFIGURE(M2_INSTALL_TEMPLATE M2_INSTALL_STRING TRUE)
_M2_STRING_CONFIGURE(M2_CHECK_TEMPLATE M2_CHECK_STRING)
Expand Down Expand Up @@ -256,3 +255,7 @@ endforeach()

file(COPY LanguageServer/M2-language-server
DESTINATION ${M2_DIST_PREFIX}/${M2_INSTALL_BINDIR})

install(PROGRAMS LanguageServer/M2-language-server
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT ALL)
Comment on lines 256 to +261

@mahrud mahrud Jun 26, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines should not be here. This file is for packages only.

I still think adding --language-server option in startup.m2 is the best option, but another alternative is adding a target under Macaulay2/editors/language-server. e.g. prism and generate-symbols.m2 interact with the Style package, but we don't write those targets in packages/CMakeFiles.txt just because Style is in this directory.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the language server is a package... It's an unusual package in that it has an accompanying script and folks would rarely if ever ever load it by hand, but all the related code is here in the packages directory.

I'd rather avoid touching startup.m2. Keeping the script in the package's auxiliary directory keeps everything close together, and also doesn't require recompiling M2.

I think the comparison to prism actually supports the current proprosal. For prism, the build system targets live in the editors directory since that's where the source code is even though the files get installed alongside the packages. Same idea here -- the source code is in packages but we're installing it alongside the binary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For prism, the build system targets live in the editors directory since that's where the source code is even though the files get installed alongside the packages.

The template is there but the file is generated by generateSymbols which lives in the Style package, so these two seem contradictory:

  • we should keep the script in the package's aux directory to keep things together
  • we should keep the script in the directory where it gets installed

Either move it to Macaulay2/bin if it needs to be installed on path next to M2 and M2-binary (the main file could live in bin and have a symlink from the aux directory), or to Macaulay2/editors/language-server and put the path in editor configuration.

9 changes: 8 additions & 1 deletion M2/Macaulay2/packages/LanguageServer/M2-language-server
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/sh

M2 --silent --stop \
dir=$(dirname "$0")
if [ -x "$dir/M2" ]; then
M2="$dir/M2"
else
M2=M2
fi

"$M2" --silent --stop \
-e 'clearEcho stdio' \
-e 'needsPackage "LanguageServer"' \
-e 'server = new LSPServer' \
Expand Down
Loading