blob: db86d58960b91ffa06b9b6364eb1783421648d21 (
plain)
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
|
(local scratches {})
(fn scratch-buffer [name ft]
(fn setopt [buf opt value]
(vim.api.nvim_buf_set_option buf opt value)
buf)
(fn track [buf]
(tset scratches name buf)
buf)
(track (-> (vim.api.nvim_create_buf true false)
(setopt :filetype ft)
(setopt :buftype :nofile)
(setopt :bufhidden :hide)
(setopt :swapfile false))))
(let [log (fn [...]
(P [...]))]
(vim.api.nvim_create_user_command :Scratch
(fn [c]
(let [name c.args]
(fn exists? [buf]
(not= buf nil))
(fn get []
(. scratches c.args))
(fn goto [buf]
(vim.api.nvim_set_current_buf buf))
(let [buf (get)
current (vim.api.nvim_get_current_buf)]
(if (exists? buf) (goto buf)
(goto (scratch-buffer name
(vim.api.nvim_buf_get_option current
:filetype)))))))
{:complete log :nargs 1}))
|