Skip to content

Commit 1c0fa67

Browse files
committed
完善1.0.0的大部分特性
1 parent be762c4 commit 1c0fa67

17 files changed

+383
-468
lines changed

CodeFormatServer/CMakeLists.txt

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,70 @@ add_executable(CodeFormatServer)
77
add_dependencies(CodeFormatServer CodeService)
88

99
target_include_directories(CodeFormatServer PUBLIC
10-
${LuaCodeStyle_SOURCE_DIR}/include
11-
${LuaCodeStyle_SOURCE_DIR}/3rd/asio-1.20.0/include
12-
${LuaCodeStyle_SOURCE_DIR}/3rd/nlohmann_json/include
13-
${LuaCodeStyle_SOURCE_DIR}/3rd/mimalloc-2.0.3/include
14-
src
15-
)
10+
${LuaCodeStyle_SOURCE_DIR}/include
11+
${LuaCodeStyle_SOURCE_DIR}/3rd/asio-1.20.0/include
12+
${LuaCodeStyle_SOURCE_DIR}/3rd/nlohmann_json/include
13+
${LuaCodeStyle_SOURCE_DIR}/3rd/mimalloc-2.0.3/include
14+
src
15+
)
1616

1717
target_compile_options(CodeFormatServer PUBLIC -DASIO_STANDALONE)
1818

1919
target_sources(CodeFormatServer
20-
PRIVATE
21-
${CodeFormatServer_SOURCE_DIR}/src/main.cpp
22-
${CodeFormatServer_SOURCE_DIR}/src/LanguageServer.cpp
23-
24-
#LSP
25-
${CodeFormatServer_SOURCE_DIR}/src/LSP/LSP.cpp
26-
${CodeFormatServer_SOURCE_DIR}/src/LSP/LSPHandle.cpp
27-
#Session
28-
${CodeFormatServer_SOURCE_DIR}/src/Session/IOSession.cpp
29-
${CodeFormatServer_SOURCE_DIR}/src/Session/SocketIOSession.cpp
30-
${CodeFormatServer_SOURCE_DIR}/src/Session/StandardIOSession.cpp
31-
#protocol
32-
${CodeFormatServer_SOURCE_DIR}/src/Session/Protocol/ProtocolParser.cpp
33-
${CodeFormatServer_SOURCE_DIR}/src/Session/Protocol/ProtocolBuffer.cpp
34-
35-
#vfs
36-
${CodeFormatServer_SOURCE_DIR}/src/VFS/VirtualFile.cpp
37-
${CodeFormatServer_SOURCE_DIR}/src/VFS/VirtualFileSystem.cpp
38-
39-
#DB
40-
${CodeFormatServer_SOURCE_DIR}/src/DB/FileDB.cpp
41-
${CodeFormatServer_SOURCE_DIR}/src/DB/UriDB.cpp
42-
${CodeFormatServer_SOURCE_DIR}/src/DB/LineIndexDB.cpp
43-
44-
#lib
45-
${CodeFormatServer_SOURCE_DIR}/src/Lib/LineIndex/LineIndex.cpp
46-
${CodeFormatServer_SOURCE_DIR}/src/Lib/LineIndex/LineTypes.cpp
47-
48-
#service
49-
${CodeFormatServer_SOURCE_DIR}/src/Service/Service.cpp
50-
${CodeFormatServer_SOURCE_DIR}/src/Service/FormatService.cpp
51-
${CodeFormatServer_SOURCE_DIR}/src/Service/DiagnosticService.cpp
52-
# ${CodeFormatServer_SOURCE_DIR}/src/Service/CommandService.cpp
53-
# ${CodeFormatServer_SOURCE_DIR}/src/Service/CodeActionService.cpp
54-
${CodeFormatServer_SOURCE_DIR}/src/Service/ConfigService.cpp
55-
56-
# mimalloc
57-
${LuaCodeStyle_SOURCE_DIR}/3rd/mimalloc-2.0.3/src/static.c
58-
)
20+
PRIVATE
21+
${CodeFormatServer_SOURCE_DIR}/src/main.cpp
22+
${CodeFormatServer_SOURCE_DIR}/src/LanguageServer.cpp
23+
24+
#Config
25+
${CodeFormatServer_SOURCE_DIR}/src/Config/ClientConfig.cpp
26+
27+
#LSP
28+
${CodeFormatServer_SOURCE_DIR}/src/LSP/LSP.cpp
29+
${CodeFormatServer_SOURCE_DIR}/src/LSP/LSPHandle.cpp
30+
#Session
31+
${CodeFormatServer_SOURCE_DIR}/src/Session/IOSession.cpp
32+
${CodeFormatServer_SOURCE_DIR}/src/Session/SocketIOSession.cpp
33+
${CodeFormatServer_SOURCE_DIR}/src/Session/StandardIOSession.cpp
34+
#protocol
35+
${CodeFormatServer_SOURCE_DIR}/src/Session/Protocol/ProtocolParser.cpp
36+
${CodeFormatServer_SOURCE_DIR}/src/Session/Protocol/ProtocolBuffer.cpp
37+
38+
#vfs
39+
${CodeFormatServer_SOURCE_DIR}/src/VFS/VirtualFile.cpp
40+
${CodeFormatServer_SOURCE_DIR}/src/VFS/VirtualFileSystem.cpp
41+
42+
#DB
43+
${CodeFormatServer_SOURCE_DIR}/src/DB/FileDB.cpp
44+
${CodeFormatServer_SOURCE_DIR}/src/DB/UriDB.cpp
45+
${CodeFormatServer_SOURCE_DIR}/src/DB/LineIndexDB.cpp
46+
47+
#lib
48+
${CodeFormatServer_SOURCE_DIR}/src/Lib/LineIndex/LineIndex.cpp
49+
${CodeFormatServer_SOURCE_DIR}/src/Lib/LineIndex/LineTypes.cpp
50+
51+
#service
52+
${CodeFormatServer_SOURCE_DIR}/src/Service/Service.cpp
53+
${CodeFormatServer_SOURCE_DIR}/src/Service/FormatService.cpp
54+
${CodeFormatServer_SOURCE_DIR}/src/Service/DiagnosticService.cpp
55+
${CodeFormatServer_SOURCE_DIR}/src/Service/CommandService.cpp
56+
${CodeFormatServer_SOURCE_DIR}/src/Service/CodeActionService.cpp
57+
${CodeFormatServer_SOURCE_DIR}/src/Service/ConfigService.cpp
58+
59+
# mimalloc
60+
${LuaCodeStyle_SOURCE_DIR}/3rd/mimalloc-2.0.3/src/static.c
61+
)
5962

6063
target_link_libraries(CodeFormatServer PUBLIC CodeService)
6164

6265

63-
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
64-
target_compile_definitions(CodeFormatServer PUBLIC -D_WIN32_WINNT=0x0601)
65-
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
66-
target_link_libraries(CodeFormatServer PUBLIC pthread -static-libstdc++ -static-libgcc)
67-
endif()
66+
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
67+
target_compile_definitions(CodeFormatServer PUBLIC -D_WIN32_WINNT=0x0601)
68+
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
69+
target_link_libraries(CodeFormatServer PUBLIC pthread -static-libstdc++ -static-libgcc)
70+
endif ()
6871

6972
install(
70-
TARGETS CodeFormatServer
71-
LIBRARY DESTINATION lib
72-
RUNTIME DESTINATION bin
73+
TARGETS CodeFormatServer
74+
LIBRARY DESTINATION lib
75+
RUNTIME DESTINATION bin
7376
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "ClientConfig.h"
2+
3+
void ClientConfig::Deserialize(nlohmann::json json) {
4+
if (json["emmylua"].is_object()) {
5+
auto emmylua = json["emmylua"];
6+
if (emmylua["lint"].is_object()) {
7+
auto lint = emmylua["lint"];
8+
if (lint["codeStyle"].is_boolean()) {
9+
emmylua_lint_codeStyle = lint["codeStyle"];
10+
}
11+
if (lint["nameStyle"].is_boolean()) {
12+
emmylua_lint_nameStyle = lint["nameStyle"];
13+
}
14+
}
15+
16+
if (emmylua["spell"].is_object()) {
17+
auto spell = emmylua["spell"];
18+
if (spell["enable"].is_boolean()) {
19+
emmylua_spell_enable = spell["enable"];
20+
}
21+
22+
if (spell["dict"].is_array()) {
23+
emmylua_spell_dict.clear();
24+
for (auto j: spell["dict"]) {
25+
if (j.is_string()) {
26+
emmylua_spell_dict.push_back(j);
27+
}
28+
}
29+
}
30+
}
31+
}
32+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
#include "LSP/LSP.h"
3+
4+
class ClientConfig : lsp::Serializable {
5+
public:
6+
bool emmylua_lint_codeStyle = true;
7+
bool emmylua_lint_nameStyle = false;
8+
bool emmylua_spell_enable = false;
9+
std::vector<std::string> emmylua_spell_dict;
10+
11+
void Deserialize(nlohmann::json json) override;
12+
};

CodeFormatServer/src/LSP/LSP.cpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void lsp::InitializationOptions::Deserialize(nlohmann::json json)
218218

219219
if (json["vscodeConfig"].is_object())
220220
{
221-
vscodeConfig.Deserialize(json["vscodeConfig"]);
221+
vscodeConfig = json["vscodeConfig"];
222222
}
223223

224224
if (json["dictionaryPath"].is_array())
@@ -334,33 +334,6 @@ void lsp::ConfigSource::Deserialize(nlohmann::json json)
334334
workspace = json["workspace"];
335335
}
336336

337-
void lsp::VscodeSettings::Deserialize(nlohmann::json json)
338-
{
339-
if (json["emmylua.lint.moduleCheck"].is_boolean())
340-
{
341-
lintModule = json["emmylua.lint.moduleCheck"];
342-
}
343-
344-
if (json["emmylua.lint.codeStyle"].is_boolean())
345-
{
346-
lintCodeStyle = json["emmylua.lint.codeStyle"];
347-
}
348-
349-
if (json["emmylua.spell.enable"].is_boolean())
350-
{
351-
spellEnable = json["emmylua.spell.enable"];
352-
}
353-
354-
if (json["emmylua.spell.dict"].is_array())
355-
{
356-
spellDict.clear();
357-
for (auto j : json["emmylua.spell.dict"])
358-
{
359-
spellDict.push_back(j);
360-
}
361-
}
362-
}
363-
364337
void lsp::ConfigUpdateParams::Deserialize(nlohmann::json json)
365338
{
366339
type = json["type"];

CodeFormatServer/src/LSP/LSP.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,6 @@ class ServerCapabilities : public Serializable
254254

255255
class ConfigSource;
256256

257-
class VscodeSettings : public Serializable
258-
{
259-
public:
260-
bool lintCodeStyle = true;
261-
bool lintModule = true;
262-
// bool autoImport = true;
263-
bool spellEnable;
264-
std::vector<std::string> spellDict;
265-
266-
void Deserialize(nlohmann::json json) override;
267-
};
268-
269257
class InitializationOptions : public Serializable
270258
{
271259
public:
@@ -275,7 +263,7 @@ class InitializationOptions : public Serializable
275263
std::string localeRoot;
276264
std::string extensionChars;
277265
std::vector<std::string> dictionaryPath;
278-
VscodeSettings vscodeConfig;
266+
nlohmann::json vscodeConfig;
279267
void Deserialize(nlohmann::json json) override;
280268
};
281269

0 commit comments

Comments
 (0)