Add pi-tool-display (compact tool rendering, adaptive diffs) + pi-lsp-extension (LSP diagnostics/hover/definitions) — vendored from npm 0.5.0 / 1.3.0
This commit is contained in:
51
extensions/pi-lsp-extension/src/shared/language-map.ts
Normal file
51
extensions/pi-lsp-extension/src/shared/language-map.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Shared language mappings — single source of truth for file extension → language ID.
|
||||
*
|
||||
* Used by both LspManager and TreeSitterManager.
|
||||
*/
|
||||
|
||||
/** Map file extensions to LSP language IDs */
|
||||
export const EXT_TO_LANGUAGE: Record<string, string> = {
|
||||
".ts": "typescript",
|
||||
".tsx": "typescriptreact",
|
||||
".js": "javascript",
|
||||
".jsx": "javascriptreact",
|
||||
".mts": "typescript",
|
||||
".mjs": "javascript",
|
||||
".cts": "typescript",
|
||||
".cjs": "javascript",
|
||||
".rs": "rust",
|
||||
".py": "python",
|
||||
".go": "go",
|
||||
".java": "java",
|
||||
".c": "c",
|
||||
".h": "c",
|
||||
".cpp": "cpp",
|
||||
".cc": "cpp",
|
||||
".hpp": "cpp",
|
||||
".cs": "csharp",
|
||||
".rb": "ruby",
|
||||
".kt": "kotlin",
|
||||
".kts": "kotlin",
|
||||
".scala": "scala",
|
||||
".ex": "elixir",
|
||||
".exs": "elixir",
|
||||
".lua": "lua",
|
||||
".sh": "bash",
|
||||
".bash": "bash",
|
||||
".zsh": "bash",
|
||||
".swift": "swift",
|
||||
".zig": "zig",
|
||||
".json": "json",
|
||||
".html": "html",
|
||||
".htm": "html",
|
||||
".css": "css",
|
||||
".vue": "vue",
|
||||
".php": "php",
|
||||
};
|
||||
|
||||
/** Get the language ID for a file path based on extension */
|
||||
export function getLanguageIdFromPath(filePath: string): string | undefined {
|
||||
const ext = filePath.match(/\.[^.]+$/)?.[0]?.toLowerCase();
|
||||
return ext ? EXT_TO_LANGUAGE[ext] : undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user