claude-code - 💡(How to fix) Fix LSP: Support filename-based matching (filenameToLanguage) for extensionless files [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47748Fetched 2026-04-15 06:43:22
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

Root Cause

However, none of these can be integrated as Claude Code LSP plugins because Dockerfile has no file extension and docker-compose.yml shares .yml with all YAML files.

Code Example

{
  "dockerfile": {
    "command": "docker-langserver",
    "args": ["--stdio"],
    "extensionToLanguage": {
      ".dockerfile": "dockerfile"
    },
    "filenameToLanguage": {
      "Dockerfile": "dockerfile",
      "Containerfile": "dockerfile"
    },
    "transport": "stdio"
  }
}
RAW_BUFFERClick to expand / collapse

Problem

Currently, extensionToLanguage is the only mechanism for routing files to LSP servers. It relies on path.extname() to extract the file extension, then performs a direct lookup in the mapping. This means files without a traditional extension cannot be matched to any LSP server.

Affected files include:

Filepath.extname() resultCan match?
Dockerfile"" (empty)No
Makefile"" (empty)No
Jenkinsfile"" (empty)No
Vagrantfile"" (empty)No
Gemfile"" (empty)No
docker-compose.yml.ymlConflicts with all YAML files
compose.yaml.yamlConflicts with all YAML files

This also relates to #15785 (compound extension matching), which was auto-closed without resolution.

Use Case: Docker LSP

There are mature, widely-used Docker language servers available:

However, none of these can be integrated as Claude Code LSP plugins because Dockerfile has no file extension and docker-compose.yml shares .yml with all YAML files.

Proposed Solution

Add a filenameToLanguage field alongside extensionToLanguage:

{
  "dockerfile": {
    "command": "docker-langserver",
    "args": ["--stdio"],
    "extensionToLanguage": {
      ".dockerfile": "dockerfile"
    },
    "filenameToLanguage": {
      "Dockerfile": "dockerfile",
      "Containerfile": "dockerfile"
    },
    "transport": "stdio"
  }
}

The matching logic would be:

  1. Extract the basename of the file
  2. Check filenameToLanguage for an exact match (higher priority)
  3. Fall back to extensionToLanguage via path.extname() (current behavior)

This is a minimal, backwards-compatible change — existing plugins continue to work unchanged, and new plugins can opt into filename-based matching.

Alternative: Glob Patterns

A more powerful alternative would be globToLanguage supporting glob patterns (e.g., "Dockerfile*": "dockerfile", "docker-compose*.yml": "dockercompose"), but exact filename matching would cover the majority of use cases with much simpler implementation.

Impact

This would unblock LSP support for Docker, Make, and many other tools that use conventional filenames without extensions — a common pattern in the DevOps/infrastructure ecosystem.

extent analysis

TL;DR

Add a filenameToLanguage field to the configuration to enable exact filename matching for files without traditional extensions.

Guidance

  • Introduce a filenameToLanguage field alongside extensionToLanguage to handle files without extensions, such as Dockerfile and Makefile.
  • Update the matching logic to prioritize exact filename matches from filenameToLanguage before falling back to extensionToLanguage via path.extname().
  • Consider implementing globToLanguage with glob patterns for more complex filename matching, but exact filename matching may suffice for most use cases.
  • Verify the fix by testing LSP integration with files like Dockerfile and docker-compose.yml to ensure they are correctly matched to their respective language servers.

Example

{
  "dockerfile": {
    "command": "docker-langserver",
    "args": ["--stdio"],
    "extensionToLanguage": {
      ".dockerfile": "dockerfile"
    },
    "filenameToLanguage": {
      "Dockerfile": "dockerfile",
      "Containerfile": "dockerfile"
    },
    "transport": "stdio"
  }
}

Notes

The proposed solution is backwards-compatible, allowing existing plugins to continue working unchanged while enabling new plugins to opt into filename-based matching.

Recommendation

Apply the workaround by adding the filenameToLanguage field to the configuration, as it provides a simple and effective solution for handling files without traditional extensions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix LSP: Support filename-based matching (filenameToLanguage) for extensionless files [1 participants]