Skip to content

Commit

Permalink
Differentiated TypeScript files from JavaScript files
Browse files Browse the repository at this point in the history
  • Loading branch information
eranif committed Jun 15, 2024
1 parent dc88c9c commit 7797be6
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CodeLite/fileextmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ void FileExtManager::Init()
m_map[wxT("sass")] = TypeCSS;
m_map[wxT("js")] = TypeJS;
m_map[wxT("javascript")] = TypeJS;
m_map[wxT("ts")] = TypeJS; // TypeScript, but we consider this a JavaScript
m_map[wxT("ts")] = TypeTypeScript;
m_map[wxT("py")] = TypePython;
m_map[wxT("pyi")] = TypePython;
m_map["json"] = TypeJSON;
m_map["conf"] = TypeJSON; // CodeLite configuration files are marked as "conf"
m_map["md"] = TypeMarkdown;
Expand Down
1 change: 1 addition & 0 deletions CodeLite/fileextmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class WXDLLIMPEXP_CL FileExtManager
TypeTcl,
TypeGo,
TypeLast,
TypeTypeScript,
};

public:
Expand Down
2 changes: 1 addition & 1 deletion LanguageServer/LanguageServerCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ void LanguageServerCluster::DiscoverWorkspaceType()
FileExtManager::TypeSourceCpp, FileExtManager::TypeCSS, FileExtManager::TypeHeader,
FileExtManager::TypeHtml, FileExtManager::TypeJS, FileExtManager::TypeJava,
FileExtManager::TypeLua, FileExtManager::TypeRuby, FileExtManager::TypeRust,
FileExtManager::TypePython, FileExtManager::TypeDart,
FileExtManager::TypePython, FileExtManager::TypeDart, FileExtManager::TypeTypeScript,
};
for (const wxString& file : files) {
auto file_type = FileExtManager::GetType(file);
Expand Down
5 changes: 5 additions & 0 deletions Plugin/ColoursAndFontsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ LexerConf::Ptr_t ColoursAndFontsManager::GetLexerForFile(const wxString& filenam
lexerByContent = GetLexer("script");
break;
case FileExtManager::TypeJS:
case FileExtManager::TypeTypeScript:
lexerByContent = GetLexer("javascript");
break;
case FileExtManager::TypePhp:
Expand Down Expand Up @@ -728,6 +729,10 @@ LexerConf::Ptr_t ColoursAndFontsManager::DoAddLexer(JSONItem json)
lexer->SetFileSpec(filespec);
}

if (lexer->GetName() == "javascript") {
AddLexerKeywords(lexer, 0, { "async", "await" });
}

// Hack: fix Java lexer which is using the same
// file extensions as C++...
if (lexer->GetName() == "java" && lexer->GetFileSpec().Contains(".cpp")) {
Expand Down
3 changes: 3 additions & 0 deletions Plugin/LSP/LanguageServerProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ LanguageServerProtocol::~LanguageServerProtocol()
wxString LanguageServerProtocol::GetLanguageId(FileExtManager::FileType file_type)
{
switch (file_type) {
case FileExtManager::TypeGo:
return "go";
case FileExtManager::TypeSourceC:
return "c";
case FileExtManager::TypeSourceCpp:
case FileExtManager::TypeHeader:
return "cpp";
case FileExtManager::TypeJS:
case FileExtManager::TypeTypeScript:
return "javascript";
case FileExtManager::TypeDockerfile:
return "dockerfile";
Expand Down
3 changes: 2 additions & 1 deletion Plugin/ThemeImporters/ThemeImporterJavaScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ThemeImporterJavaScript::ThemeImporterJavaScript()
SetFunctionsWordSetIndex(1);
SetClassWordSetIndex(3);
SetOthersWordSetIndex(4);
SetLangName("javascript");
SetLocalsWordSetIndex(LexerConf::WS_VARIABLES, true);
SetFileExtensions("*.js;*.javascript;*.qml;*.json;*.ts");
}
Expand All @@ -68,7 +69,7 @@ ThemeImporterJavaScript::~ThemeImporterJavaScript() {}

LexerConf::Ptr_t ThemeImporterJavaScript::Import(const wxFileName& theme_file)
{
LexerConf::Ptr_t lexer = InitializeImport(theme_file, "javascript", wxSTC_LEX_CPP);
LexerConf::Ptr_t lexer = InitializeImport(theme_file, GetLangName(), wxSTC_LEX_CPP);
CHECK_PTR_RET_NULL(lexer);

// Covnert to codelite's XML properties
Expand Down
1 change: 1 addition & 0 deletions Plugin/bitmap_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ void BitmapLoader::CreateMimeList()
m_mimeBitmaps.AddBitmap(LoadBitmap("mime-python", 16), FileExtManager::TypePython);
m_mimeBitmaps.AddBitmap(LoadBitmap("mime-css", 16), FileExtManager::TypeCSS);
m_mimeBitmaps.AddBitmap(LoadBitmap("mime-js", 16), FileExtManager::TypeJS);
m_mimeBitmaps.AddBitmap(LoadBitmap("mime-ts", 16), FileExtManager::TypeTypeScript);
m_mimeBitmaps.AddBitmap(LoadBitmap("mime-java", 16), FileExtManager::TypeJava);
m_mimeBitmaps.AddBitmap(LoadBitmap("mime-go", 16), FileExtManager::TypeGo);
m_mimeBitmaps.AddBitmap(LoadBitmap("cxx-workspace", 16), FileExtManager::TypeWorkspace);
Expand Down
55 changes: 54 additions & 1 deletion svgs/dark-theme/mime-js.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions svgs/dark-theme/mime-ts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 54 additions & 1 deletion svgs/light-theme/mime-js.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions svgs/light-theme/mime-ts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7797be6

Please sign in to comment.