Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
77 lines (65 loc) · 2.3 KB

File metadata and controls

77 lines (65 loc) · 2.3 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
-- Copyright (c) 2025 Augment
-- MIT License - See LICENSE.md for full terms
local M = {}
-- Start the lsp client
M.start_client = function(command, notification_methods, workspace_folders)
local vim_version = tostring(vim.version())
local plugin_version = vim.call('augment#version#Version')
-- Set up noficiation handlers that forward requests to the handlers in the vimscript
local handlers = {}
for _, method in ipairs(notification_methods) do
handlers[method] = function(_, params, _)
vim.call('augment#client#NvimNotification', method, params)
end
end
local config = {
name = 'Augment Server',
cmd = command,
init_options = {
editor = 'nvim',
vimVersion = vim_version,
pluginVersion = plugin_version,
},
on_exit = function(code, signal, client_id)
-- We can not call vim functions directly from callback functions.
-- Instead, we schedule the functions for async execution
vim.schedule(function()
vim.call('augment#client#NvimOnExit', code, signal, client_id)
end)
end,
handlers = handlers,
-- TODO(mpauly): on_error
}
-- If workspace folders are provided, use them
if workspace_folders and #workspace_folders > 0 then
config.workspace_folders = workspace_folders
end
local id = vim.lsp.start_client(config)
return id
end
-- Attach the lsp client to a buffer
M.open_buffer = function(client_id, bufnr)
vim.lsp.buf_attach_client(bufnr, client_id)
end
-- Send a lsp notification
M.notify = function(client_id, method, params)
local client = vim.lsp.get_client_by_id(client_id)
if not client then
vim.call('augment#log#Error', 'No lsp client found for id: ' .. client_id)
return
end
client.notify(method, params)
end
-- Send a lsp request
M.request = function(client_id, method, params)
local client = vim.lsp.get_client_by_id(client_id)
if not client then
vim.call('augment#log#Error', 'No lsp client found for id: ' .. client_id)
return
end
local _, id = client.request(method, params, function(err, result)
vim.call('augment#client#NvimResponse', method, params, result, err)
end)
return id
end
return M
Morty Proxy This is a proxified and sanitized view of the page, visit original site.