-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.lua
41 lines (32 loc) · 1.05 KB
/
example.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- in Lua,
local null = require("cjson").null
local lsp = require("lsp-lib")
-- this allows adding fields to the type
---@class lsp*.Request
lsp.request = lsp.request
-- 'initialize' should auto-complete well enough under LuaLS
lsp.response["initialize"] = function(params)
-- annotation is needed here due to a shortcoming of LuaLS
---@type lsp.Response.initialize.result
return { capabilities = {} }
end
lsp.response["initialized"] = function()
-- utility notify functions are provided
lsp.notify.log.info(os.date())
-- make a blocking LSP request
lsp.config = assert(lsp.request.config({ section = "server.config" }))
end
lsp.response["shutdown"] = function()
-- notify the client of something
lsp.notify["$/cancelRequest"]({ id = 0 })
return null
end
-- define your own request function
function lsp.request.custom_request(foo, bar)
return lsp.request("$/customRequest", { foo = foo, bar = bar })
end
-- turn on debugging
-- currently logs anything received by or sent from this server
lsp.debug(true)
-- starts a loop that listens to stdio
lsp.listen()