mirror of
https://github.com/elkowar/dots-of-war.git
synced 2024-11-06 03:12:24 +00:00
Fix empty buffer close thingy
This commit is contained in:
parent
82cc8c3e1c
commit
399d32327d
3 changed files with 18 additions and 11 deletions
|
@ -137,17 +137,16 @@
|
|||
; :: autoclose empty unnamed buffers ----------------------------------------------- foldstart
|
||||
|
||||
(fn _G.clean_no_name_empty_buffers []
|
||||
(let [bufs (a.filter #(and (vim.api.nvim_buf_get_option $1 "buflisted")
|
||||
(a.empty? (vim.fn.bufname $1))
|
||||
(let [bufs (a.filter #(and (a.empty? (vim.fn.bufname $1))
|
||||
(< (vim.fn.bufwinnr $1) 0)
|
||||
(if (vim.api.nvim_buf_is_loaded $1)
|
||||
(a.empty? (vim.api.nvim_buf_get_lines $1 0 -1 false))
|
||||
false))
|
||||
(vim.api.nvim_buf_is_loaded $1)
|
||||
(= "" (str.join (utils.buffer-content $1)))
|
||||
(vim.api.nvim_buf_get_option $1 "buflisted"))
|
||||
(vim.fn.range 1 (vim.api.nvim_buf_get_number "$")))]
|
||||
(when (not (a.empty? bufs))
|
||||
(nvim.command (.. "bd " (str.join " " bufs))))))
|
||||
(vim.cmd (.. "bdelete " (str.join " " bufs))))))
|
||||
|
||||
(nvim.command "autocmd! BufCreate * :call v:lua.clean_no_name_empty_buffers()")
|
||||
(vim.cmd "autocmd! BufCreate * :call v:lua.clean_no_name_empty_buffers()")
|
||||
|
||||
; foldend
|
||||
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
(fn [name]
|
||||
`(.. "lua require('" *module-name* "')['" ,(tostring name) "']()"))
|
||||
|
||||
:dbg
|
||||
(fn [x]
|
||||
`(let [view# (. (require "aniseed.fennel") :view)]
|
||||
(print (.. `,(tostring x) " => " (view# ,x)))
|
||||
,x))
|
||||
|
||||
:dbg-call
|
||||
(fn [x ...]
|
||||
`(do
|
||||
|
|
|
@ -10,9 +10,8 @@
|
|||
(defn plugin-installed? [name]
|
||||
(~= nil (. packer_plugins name)))
|
||||
|
||||
(defn dbg [x]
|
||||
(a.println (fennel.view x))
|
||||
x)
|
||||
(defn all [f xs]
|
||||
(not (a.some (not (f $1)))))
|
||||
|
||||
(defn single-to-list [x]
|
||||
"Returns the list given to it. If given a single value, wraps it in a list"
|
||||
|
@ -29,7 +28,6 @@
|
|||
(defn without-keys [keys t]
|
||||
(filter-table #(not (contains? keys $1)) t))
|
||||
|
||||
|
||||
(defn keymap [modes from to ?opts]
|
||||
"Set a mapping in the given modes, and some optional parameters, defaulting to {:noremap true :silent true}.
|
||||
If :buffer is set, uses buf_set_keymap rather than set_keymap"
|
||||
|
@ -68,6 +66,10 @@
|
|||
(use (a.assoc opts 1 name)))))))
|
||||
|
||||
|
||||
(defn buffer-content [bufnr]
|
||||
"Returns a table of lines in the given buffer"
|
||||
(vim.api.nvim_buf_get_lines bufnr 0 -1 false))
|
||||
|
||||
(defn surround-if-present [a mid b]
|
||||
(if mid
|
||||
(.. a mid b)
|
||||
|
|
Loading…
Reference in a new issue