-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuffer.lua
More file actions
32 lines (28 loc) · 810 Bytes
/
Copy pathbuffer.lua
File metadata and controls
32 lines (28 loc) · 810 Bytes
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
local buffer = {}
function buffer.trim()
local view = vim.fn.winsaveview()
vim.cmd([[
keeppatterns keepjumps %s/\s\+$//e
keeppatterns keepjumps %s#\($\n\s*\)\+\%$##e
]])
vim.fn.winrestview(view)
end
function buffer.writeskeleton()
local configdir = vim.fn.stdpath("config")
local extension = vim.fn.expand("%:e")
local skeletonfile = vim.fn.fnameescape(configdir .. "/templates/skeleton." .. extension)
if vim.fn.filereadable(skeletonfile) == 1 then
vim.cmd("read ++edit " .. skeletonfile)
vim.fn.deletebufline(vim.fn.bufname(), 1)
vim.bo.modified = false
end
end
function buffer.getclients()
local result = {}
local activeclients = vim.lsp.buf_get_clients()
for _, v in ipairs(activeclients) do
table.insert(result, v.name)
end
return table.concat(result, ":")
end
return buffer