mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 17:17:42 +03:00
Fix TypeScript React and JavasSript React files in LSP, they were recognized as TypeScript and JavaScript files so it was incorrectly parsed.
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"language": "tsx",
|
||||
"language": "typescriptreact",
|
||||
"use": "typescript-language-server",
|
||||
"share_process": true,
|
||||
"file_patterns": ["%.tsx$"]
|
||||
@@ -43,7 +43,7 @@
|
||||
"file_patterns": ["%.js$"]
|
||||
},
|
||||
{
|
||||
"language": "jsx",
|
||||
"language": "javascriptreact",
|
||||
"use": "typescript-language-server",
|
||||
"share_process": true,
|
||||
"file_patterns": ["%.jsx$"]
|
||||
|
||||
@@ -770,6 +770,24 @@ void LSPClientPlugin::load( PluginManager* pluginManager ) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::unordered_map<std::string, std::string>> lspPatternsLangId;
|
||||
|
||||
for ( auto& lsp : lsps ) {
|
||||
if ( lsp.shareProcessWithOtherDefinition && !lsp.usesLSP.empty() ) {
|
||||
for ( const auto& ptrn : lsp.filePatterns )
|
||||
lspPatternsLangId[lsp.usesLSP][ptrn] = lsp.language;
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto& lsp : lsps ) {
|
||||
auto ptrnsLangIds = lspPatternsLangId.find( lsp.name );
|
||||
if ( ptrnsLangIds != lspPatternsLangId.end() ) {
|
||||
lsp.languageIdsForFilePatterns.merge( ptrnsLangIds->second );
|
||||
for ( const auto& ptrn : lsp.filePatterns )
|
||||
lsp.languageIdsForFilePatterns[ptrn] = lsp.language;
|
||||
}
|
||||
}
|
||||
|
||||
mClientManager.load( this, pluginManager, std::move( lsps ) );
|
||||
|
||||
subscribeFileSystemListener();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <eepp/system/iostreamstring.hpp>
|
||||
#include <eepp/system/lock.hpp>
|
||||
#include <eepp/system/log.hpp>
|
||||
#include <eepp/system/luapattern.hpp>
|
||||
#include <eepp/system/sys.hpp>
|
||||
#include <eepp/ui/doc/textdocument.hpp>
|
||||
#include <eepp/window/engine.hpp>
|
||||
@@ -1433,7 +1434,18 @@ bool LSPClientServer::trimLogs() const {
|
||||
|
||||
LSPClientServer::LSPRequestHandle LSPClientServer::didOpen( const URI& document,
|
||||
const std::string& text, int version ) {
|
||||
auto params = textDocumentParams( textDocumentItem( document, mLSP.language, text, version ) );
|
||||
std::string languageId = mLSP.language;
|
||||
if ( !mLSP.languageIdsForFilePatterns.empty() ) {
|
||||
for ( const auto& filePattern : mLSP.languageIdsForFilePatterns ) {
|
||||
LuaPattern ptrn( filePattern.first );
|
||||
if ( ptrn.matches( document.toString() ) ) {
|
||||
languageId = filePattern.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto params = textDocumentParams( textDocumentItem( document, languageId, text, version ) );
|
||||
return send( newRequest( "textDocument/didOpen", params ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ struct LSPDefinition {
|
||||
std::string url;
|
||||
std::string host;
|
||||
std::unordered_map<std::string, std::string> env;
|
||||
/* filePattern, languageId */
|
||||
std::unordered_map<std::string, std::string> languageIdsForFilePatterns;
|
||||
int port{ 0 };
|
||||
nlohmann::json initializationOptions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user