Skip to content

CPP language should include .m and .mm file extensions for Objective-C/Objective-C++ support #1259

@freelf

Description

@freelf

Problem

The cpp language's FilenameMatcher in solidlsp/ls_config.py only matches C/C++ extensions:

case self.CPP | self.CPP_CCLS:
    return FilenameMatcher("*.cpp", "*.h", "*.hpp", "*.c", "*.hxx", "*.cc", "*.cxx")

This means .m (Objective-C) and .mm (Objective-C++) files are not associated with clangd, even though clangd fully supports these file types.

Currently .m is mapped to MATLAB, which makes Objective-C source files inaccessible through the cpp language server.

Impact

For iOS/macOS projects, get_symbols_overview, find_symbol, and find_referencing_symbols all fail on .m and .mm files with:

ValueError - Cannot extract symbols from file xxx.m. Active languages: ['cpp']

While .h header files work fine (since they match *.h), the implementation files are completely excluded.

Suggested Fix

Add "*.m" and "*.mm" to the CPP FilenameMatcher:

case self.CPP | self.CPP_CCLS:
    return FilenameMatcher("*.cpp", "*.h", "*.hpp", "*.c", "*.hxx", "*.cc", "*.cxx", "*.m", "*.mm")

Note: *.m currently conflicts with MATLAB. A possible solution is to either:

  1. Add .m/.mm to cpp and remove .m from MATLAB (breaking change for MATLAB users)
  2. Allow configurable file extension overrides via ls_specific_settings
  3. Add a dedicated objc language alias that maps to clangd with ObjC extensions

Environment

  • Serena version: 0.1.4
  • Platform: macOS (ARM64)
  • Use case: Cross-platform mobile SDK with C++, Objective-C++, and Kotlin code

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions