kovisoft / slimv

Official mirror of Slimv versions released on vim.org
454 stars 60 forks source link

Set classpath delimiter as per OS to run Clojure #89

Closed susam closed 4 years ago

susam commented 4 years ago

Prior to this change, even if Clojure is available at one of the auto-detected paths on Linux or Unix, e.g., ~/clojure/clojure.jar, the normal mode command ,c fails to start Swank server with Clojure. This issue occurs because semicolon (;) is used as the delimiter in the classpath value for java -cp option. Here is an example classpath value that is used prior to this change:

/home/x/clojure/clojure.jar;/home/x/.vim/bundle/slimv/swank-clojure

Semicolon (;) is the right delimiter for Java running on Windows but it should be colon (:) on a Linux or Unix system. This change ensures that the correct delimiter is chosen as per the current operating system.

susam commented 4 years ago

I have tested that this change works fine on Debian, macOS, and Windows.

Testing Steps on Debian and macOS

  1. Install Maven.

    # On Debian, Ubuntu, etc.
    apt-get update
    apt-get install maven
    
    # On macOS
    brew install openjdk maven
    export JAVA_HOME=/usr/local/opt/openjdk
    export PATH="$JAVA_HOME/bin:$PATH"
  2. Install Clojure.

    git clone https://github.com/clojure/clojure.git ~/clojure
    git -C ~/clojure checkout clojure-1.10.1
    mvn -f ~/clojure/pom.xml -Plocal -Dmaven.test.skip=true package
    java -jar ~/clojure/clojure.jar -e '(clojure-version)'
  3. Install Slimv.

    git clone https://github.com/kovisoft/slimv.git ~/.vim/bundle/slimv
    echo 'set runtimepath^=~/.vim/bundle/slimv' >> ~/.vimrc
    vim +'helptags ~/.vim/bundle/slimv/doc' +q
  4. Run Vim within tmux, GNU Screen, or a desktop environment to create a new Clojure source file.

    vim foo.clj
  5. Press ,c to start Swank server with Clojure. Without this change, Swank server fails to start.

  6. Apply this change.

    cd ~/.vim/bundle/slimv
    git checkout -b clojure-classpath
    git pull https://github.com/susam/slimv clojure-classpath
  7. Repeat steps 4 and 5 again. Swank server should start successfully now and the REPL buffer should appear.

Testing Steps on Windows

  1. Install 64-bit Vim using 64-bit installer available at https://github.com/vim/vim-win32-installer/releases.

  2. Install 64-bit Python 3.7 using Windows x86-64 executable installer available at https://www.python.org/downloads/release/python-375/. Note: It is important that the Python version be 3.7 because the latest Vim available at the previous URL at this time is compiled with support for Python 3.7.

  3. Install 64-bit Git from https://git-scm.com/download/win.

  4. Install JDK from https://jdk.java.net/13/.

  5. Install Maven from https://maven.apache.org/download.cgi.

  6. Add the paths to Vim, Python, Git, JDK, and Maven binaries to PATH environment variable.

  7. Install Clojure.

    git clone https://github.com/clojure/clojure.git C:\clojure
    git -C C:\clojure checkout clojure-1.10.1
    mvn -f C:\clojure\pom.xml -Plocal -Dmaven.test.skip=true package
    java -jar C:\clojure\clojure.jar -e "(clojure-version)"
  8. Install Slimv.

    git clone https://github.com/kovisoft/slimv.git %HOMEPATH%\.vim\bundle\slimv
    echo set runtimepath^^=~/.vim/bundle/slimv >> %HOMEPATH%\.vimrc
    vim +"helptags ~\.vim\bundle\slimv\doc" +q
  9. Create a new Clojure source file with Vim.

    vim foo.clj
  1. Press ,c to start Swank server with Clojure. It should start successfully even without this change. This issue did not affect Windows.

  2. Now we need to ensure that we can start Swank server even after applying this change.

    cd %HOMEPATH%\.vim\bundle\slimv
    git checkout -b clojure-classpath
    git pull https://github.com/susam/slimv clojure-classpath
  3. Kill Swank server running in a separate console window. Then repeat steps 9 and 10 again. Swank server should start successfully again.