summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--locale/en-US/script.lni8
-rw-r--r--locale/zh-CN/script.lni7
-rw-r--r--script/client.lua16
-rw-r--r--script/core/hover/lib_function.lua36
-rw-r--r--script/method/initialize.lua3
5 files changed, 60 insertions, 10 deletions
diff --git a/locale/en-US/script.lni b/locale/en-US/script.lni
index e6c1133e..1c151197 100644
--- a/locale/en-US/script.lni
+++ b/locale/en-US/script.lni
@@ -89,6 +89,14 @@ HOVER_DOCUMENT_LUA52 = '[View documents](http://www.lua.org/manual/5.2/manual
HOVER_DOCUMENT_LUA53 = '[View documents](http://www.lua.org/manual/5.3/manual.html#pdf-{})'
HOVER_DOCUMENT_LUA54 = '[View documents](http://www.lua.org/manual/5.4/manual.html#pdf-{})'
HOVER_DOCUMENT_LUAJIT = '[View documents](http://www.lua.org/manual/5.1/manual.html#pdf-{})'
+
+
+HOVER_NATIVE_DOCUMENT_LUA51 = '[View documents](command:extension.lua.doc?["en-us/51/manual.html/pdf-{}"])'
+HOVER_NATIVE_DOCUMENT_LUA52 = '[View documents](command:extension.lua.doc?["en-us/52/manual.html/pdf-{}"])'
+HOVER_NATIVE_DOCUMENT_LUA53 = '[View documents](command:extension.lua.doc?["en-us/53/manual.html/pdf-{}"])'
+HOVER_NATIVE_DOCUMENT_LUA54 = '[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-{}"])'
+HOVER_NATIVE_DOCUMENT_LUAJIT = '[View documents](command:extension.lua.doc?["en-us/51/manual.html/pdf-{}"])'
+
HOVER_MULTI_PROTOTYPE = '({} prototypes)'
ACTION_DISABLE_DIAG = 'Disable diagnostics ({}).'
diff --git a/locale/zh-CN/script.lni b/locale/zh-CN/script.lni
index 533a0aa9..5b47399a 100644
--- a/locale/zh-CN/script.lni
+++ b/locale/zh-CN/script.lni
@@ -89,6 +89,13 @@ HOVER_DOCUMENT_LUA52 = '[查看文档](http://www.lua.org/manual/5.2/manual.h
HOVER_DOCUMENT_LUA53 = '[查看文档](http://cloudwu.github.io/lua53doc/manual.html#pdf-{})'
HOVER_DOCUMENT_LUA54 = '[查看文档](http://www.lua.org/manual/5.4/manual.html#pdf-{})'
HOVER_DOCUMENT_LUAJIT = '[查看文档](http://www.lua.org/manual/5.1/manual.html#pdf-{})'
+
+HOVER_NATIVE_DOCUMENT_LUA51 = '[查看文档](command:extension.lua.doc?["en-us/51/manual.html/pdf-{}"])'
+HOVER_NATIVE_DOCUMENT_LUA52 = '[查看文档](command:extension.lua.doc?["en-us/52/manual.html/pdf-{}"])'
+HOVER_NATIVE_DOCUMENT_LUA53 = '[查看文档](command:extension.lua.doc?["en-us/53/manual.html/pdf-{}"])'
+HOVER_NATIVE_DOCUMENT_LUA54 = '[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-{}"])'
+HOVER_NATIVE_DOCUMENT_LUAJIT = '[查看文档](command:extension.lua.doc?["en-us/51/manual.html/pdf-{}"])'
+
HOVER_MULTI_PROTOTYPE = '({} 个原型)'
ACTION_DISABLE_DIAG = '禁用诊断({})。'
diff --git a/script/client.lua b/script/client.lua
new file mode 100644
index 00000000..a2671597
--- /dev/null
+++ b/script/client.lua
@@ -0,0 +1,16 @@
+local nonil = require 'without-check-nil'
+
+local m = {}
+
+function m.client()
+ nonil.enable()
+ local name = m.info.clientInfo.name
+ nonil.disable()
+ return name
+end
+
+function m.init(t)
+ m.info = t
+end
+
+return m
diff --git a/script/core/hover/lib_function.lua b/script/core/hover/lib_function.lua
index 06087312..92e6a34f 100644
--- a/script/core/hover/lib_function.lua
+++ b/script/core/hover/lib_function.lua
@@ -1,5 +1,7 @@
local lang = require 'language'
local config = require 'config'
+local client = require 'client'
+
local function buildLibArgs(lib, object, select)
if not lib.args then
return ''
@@ -188,16 +190,30 @@ local function buildDoc(lib)
return lang.script(lib.web, doc)
end
local version = config.config.runtime.version
- if version == 'Lua 5.1' then
- return lang.script('HOVER_DOCUMENT_LUA51', doc)
- elseif version == 'Lua 5.2' then
- return lang.script('HOVER_DOCUMENT_LUA52', doc)
- elseif version == 'Lua 5.3' then
- return lang.script('HOVER_DOCUMENT_LUA53', doc)
- elseif version == 'Lua 5.4' then
- return lang.script('HOVER_DOCUMENT_LUA54', doc)
- elseif version == 'LuaJIT' then
- return lang.script('HOVER_DOCUMENT_LUAJIT', doc)
+ if client.client() == 'vscode' then
+ if version == 'Lua 5.1' then
+ return lang.script('HOVER_NATIVE_DOCUMENT_LUA51', doc)
+ elseif version == 'Lua 5.2' then
+ return lang.script('HOVER_NATIVE_DOCUMENT_LUA52', doc)
+ elseif version == 'Lua 5.3' then
+ return lang.script('HOVER_NATIVE_DOCUMENT_LUA53', doc)
+ elseif version == 'Lua 5.4' then
+ return lang.script('HOVER_NATIVE_DOCUMENT_LUA54', doc)
+ elseif version == 'LuaJIT' then
+ return lang.script('HOVER_NATIVE_DOCUMENT_LUAJIT', doc)
+ end
+ else
+ if version == 'Lua 5.1' then
+ return lang.script('HOVER_DOCUMENT_LUA51', doc)
+ elseif version == 'Lua 5.2' then
+ return lang.script('HOVER_DOCUMENT_LUA52', doc)
+ elseif version == 'Lua 5.3' then
+ return lang.script('HOVER_DOCUMENT_LUA53', doc)
+ elseif version == 'Lua 5.4' then
+ return lang.script('HOVER_DOCUMENT_LUA54', doc)
+ elseif version == 'LuaJIT' then
+ return lang.script('HOVER_DOCUMENT_LUAJIT', doc)
+ end
end
end
diff --git a/script/method/initialize.lua b/script/method/initialize.lua
index ef025ddf..2d60e839 100644
--- a/script/method/initialize.lua
+++ b/script/method/initialize.lua
@@ -1,5 +1,6 @@
local workspace = require 'workspace'
local nonil = require 'without-check-nil'
+local client = require 'client'
local function allWords()
local str = [[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:('"[,#*@| ]]
@@ -13,6 +14,8 @@ end
return function (lsp, params)
lsp._inited = true
lsp.client = params
+ client.init(params)
+ log.info(table.dump(params))
if params.rootUri then
lsp.workspace = workspace(lsp, 'root')