Skip to content

Latest commit

 

History

History
91 lines (62 loc) · 3.46 KB

File metadata and controls

91 lines (62 loc) · 3.46 KB

Java Functional LSP — IntelliJ IDEA Setup

Use LSP4IJ (by Red Hat) to connect java-functional-lsp to IntelliJ IDEA. Works on both Community and Ultimate editions.

Prerequisites

  1. Install the LSP server:

    # Homebrew
    brew install aviadshiber/tap/java-functional-lsp
    
    # pip
    pip install java-functional-lsp
  2. Verify it's on your PATH:

    java-functional-lsp --help

    If not on PATH, note the full path (e.g., which java-functional-lsp).

Step 1: Install LSP4IJ Plugin

  1. Open IntelliJ IDEA
  2. Go to SettingsPluginsMarketplace
  3. Search for "LSP4IJ"
  4. Click Install and restart the IDE

Step 2: Add Language Server

  1. Go to SettingsLanguages & FrameworksLanguage Servers
  2. Click the + button to add a new server
  3. Configure:
Field Value
Name Java Functional LSP
Command java-functional-lsp

PATH issues? If IntelliJ can't find the binary, use the full path:

  • Homebrew: /opt/homebrew/bin/java-functional-lsp
  • pip: ~/.local/bin/java-functional-lsp (or check with which java-functional-lsp)

On macOS, you can also use: sh -c java-functional-lsp

Step 3: Configure File Mappings

In the Mappings tab of the server configuration, add mappings so the LSP server activates for Java files. Set up all three sub-tabs:

Language tab:

  1. Click + → select Java

File type tab:

  1. Click + → select Java

File name patterns tab:

  1. Click + to add a pattern
  2. Set File name patterns: *.java
  3. Set Language Id: java

Step 4: Verify

  1. Open any .java file in your project
  2. Check the bottom status bar — you should see the LSP server connecting
  3. Write code that triggers a rule (e.g., return null;) — a warning should appear

Configuration

Project-level rules are configured via .java-functional-lsp.json in your project root. See the main README for details.

Coexistence with IntelliJ's Java Support

The server automatically detects JetBrains IDEs and disables the jdtls proxy — IntelliJ provides its own Java language features (completions, hover, go-to-definition, compile errors). Only the 17 custom functional programming rules run, and they appear alongside IntelliJ's built-in inspections.

Troubleshooting

Server doesn't start

  • Check SettingsLanguages & FrameworksLanguage Servers → select your server → Traces tab for error logs
  • Verify the binary works: run java-functional-lsp check --help in a terminal

No diagnostics appear

  • Ensure the file mapping is set to Language: Java, Language ID: java
  • Check that .java-functional-lsp.json doesn't have rules set to "off"
  • Try restarting the language server: Language Servers (search it in intellij Actions [Double Shift on keyboard]) → click on java-functional-lsp → Restart
  • If diagnostics worked before but stopped, the jdtls proxy may be interfering. Set JAVA_FUNCTIONAL_LSP_JDTLS=off in the server command environment to force-disable jdtls. The server auto-detects JetBrains IDEs and disables jdtls by default (since IntelliJ provides native Java support), but this can be overridden with JAVA_FUNCTIONAL_LSP_JDTLS=on.

PATH not found

  • IntelliJ may not inherit your shell's PATH. Use the full absolute path to the binary in the server command.