summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-07 15:58:55 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-07 15:58:55 +0800
commit3869c8fc53fb6e014ee6570a96429ea36c707ef9 (patch)
treecc979163cc0f1eecede64739bd8a5630984ebb5e
parent5dce334f3cf6bde54c2768e0e9da145b0f50024c (diff)
downloadlua-language-server-3869c8fc53fb6e014ee6570a96429ea36c707ef9.zip
支持多语言
-rw-r--r--client/src/extension.ts18
-rw-r--r--server/src/language.lua8
-rw-r--r--server/src/matcher/find_lib.lua4
3 files changed, 14 insertions, 16 deletions
diff --git a/client/src/extension.ts b/client/src/extension.ts
index e9936119..ae2a1d89 100644
--- a/client/src/extension.ts
+++ b/client/src/extension.ts
@@ -4,7 +4,7 @@
* ------------------------------------------------------------------------------------------ */
import * as path from 'path';
-import { workspace, ExtensionContext } from 'vscode';
+import { workspace, ExtensionContext, env } from 'vscode';
import {
LanguageClient,
@@ -16,13 +16,7 @@ import {
let client: LanguageClient;
export function activate(context: ExtensionContext) {
- // The server is implemented in node
- let serverModule = context.asAbsolutePath(
- path.join('server', 'out', 'server.js')
- );
- // The debug options for the server
- // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
- let debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
+ let language = env.language;
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
@@ -33,6 +27,8 @@ export function activate(context: ExtensionContext) {
),
args: [
'-E',
+ '-e',
+ 'LANG="' + language + '"',
context.asAbsolutePath(
path.join('server', 'main.lua')
)
@@ -49,6 +45,8 @@ export function activate(context: ExtensionContext) {
),
args: [
'-E',
+ '-e',
+ 'LANG="' + language + '"',
context.asAbsolutePath(
path.join('server', 'main.lua')
)
@@ -73,8 +71,8 @@ export function activate(context: ExtensionContext) {
// Create the language client and start the client.
client = new LanguageClient(
- 'languageServerExample',
- 'Language Server Example',
+ 'sumneko.lua-lsp',
+ 'sumneko.lua-lsp',
serverOptions,
clientOptions
);
diff --git a/server/src/language.lua b/server/src/language.lua
index da25a0b8..30acdadb 100644
--- a/server/src/language.lua
+++ b/server/src/language.lua
@@ -4,14 +4,14 @@ local function supportLanguage()
local list = {}
for path in (ROOT / 'locale'):list_directory() do
if fs.is_directory(path) then
- list[#list+1] = path:filename():string()
+ list[#list+1] = path:filename():string():lower()
end
end
return list
end
local function osLanguage()
- return ''
+ return LANG:lower()
end
local function getLanguage(id)
@@ -33,8 +33,8 @@ end
local function init()
local id = osLanguage()
local language = getLanguage(id)
- log.info(('Os language: %s'):format(id))
- log.info(('Used language: %s'):format(language))
+ log.info(('VSC language: %s'):format(id))
+ log.info(('LSP language: %s'):format(language))
return language
end
diff --git a/server/src/matcher/find_lib.lua b/server/src/matcher/find_lib.lua
index e2c124ab..e91568fc 100644
--- a/server/src/matcher/find_lib.lua
+++ b/server/src/matcher/find_lib.lua
@@ -96,9 +96,9 @@ local function getLibs()
end
local relative = fs.relative(path, ROOT)
- local locale = loadLocale('enUS', relative)
+ local locale = loadLocale('en-US', relative)
mergeLocale(libs, locale)
- if language ~= 'enUS' then
+ if language ~= 'en-US' then
locale = loadLocale(language, relative)
mergeLocale(libs, locale)
end