-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathlspui.lua
More file actions
52 lines (47 loc) · 1.51 KB
/
lspui.lua
File metadata and controls
52 lines (47 loc) · 1.51 KB
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
local M = {}
function M.open_info()
-- 获取当前窗口的高度
local columns = vim.o.columns
local lines = vim.o.lines
local width = math.floor(columns * 0.8)
local height = math.floor(lines * 0.8)
local opts = {
row = math.floor((lines - height) * 0.5),
col = math.floor((columns - width) * 0.5),
relative = "editor",
width = width, -- 窗口的宽度
height = height, -- 窗口的高度
style = "minimal", -- 最小化样式
border = "rounded", -- 窗口边框样式
}
local buf = vim.api.nvim_create_buf(false, true)
local win = vim.api.nvim_open_win(buf, true, opts)
vim.wo[win].number = false
vim.keymap.set("n", "q", function()
vim.api.nvim_win_close(win, true)
end, { noremap = true, silent = true, buffer = buf })
local clients = vim.lsp.get_clients()
local client_info = {
"Lsp Clients:",
"",
}
local function lsp_buffers(id)
local client = vim.lsp.get_client_by_id(id)
return client and vim.tbl_keys(client.attached_buffers) or {}
end
for _, client in pairs(clients) do
vim.list_extend(client_info, {
"Name: " .. client.name,
" Id: " .. client.id,
" buffers: " .. vim.inspect(lsp_buffers(client.id)),
" filetype: " .. vim.inspect(client.config.filetypes),
" root_dir: " .. vim.inspect(client.config.root_dir),
" cmd: " .. vim.inspect(client.config.cmd),
"",
})
end
vim.api.nvim_put(client_info, "c", true, true)
vim.bo[buf].modifiable = false
vim.bo[buf].readonly = true
end
return M