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
|
; :: autoclose empty unnamed buffers ----------------------------------------------- foldstart
|
||||||
|
|
||||||
(fn _G.clean_no_name_empty_buffers []
|
(fn _G.clean_no_name_empty_buffers []
|
||||||
(let [bufs (a.filter #(and (vim.api.nvim_buf_get_option $1 "buflisted")
|
(let [bufs (a.filter #(and (a.empty? (vim.fn.bufname $1))
|
||||||
(a.empty? (vim.fn.bufname $1))
|
|
||||||
(< (vim.fn.bufwinnr $1) 0)
|
(< (vim.fn.bufwinnr $1) 0)
|
||||||
(if (vim.api.nvim_buf_is_loaded $1)
|
(vim.api.nvim_buf_is_loaded $1)
|
||||||
(a.empty? (vim.api.nvim_buf_get_lines $1 0 -1 false))
|
(= "" (str.join (utils.buffer-content $1)))
|
||||||
false))
|
(vim.api.nvim_buf_get_option $1 "buflisted"))
|
||||||
(vim.fn.range 1 (vim.api.nvim_buf_get_number "$")))]
|
(vim.fn.range 1 (vim.api.nvim_buf_get_number "$")))]
|
||||||
(when (not (a.empty? bufs))
|
(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
|
; foldend
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,12 @@
|
||||||
(fn [name]
|
(fn [name]
|
||||||
`(.. "lua require('" *module-name* "')['" ,(tostring name) "']()"))
|
`(.. "lua require('" *module-name* "')['" ,(tostring name) "']()"))
|
||||||
|
|
||||||
|
:dbg
|
||||||
|
(fn [x]
|
||||||
|
`(let [view# (. (require "aniseed.fennel") :view)]
|
||||||
|
(print (.. `,(tostring x) " => " (view# ,x)))
|
||||||
|
,x))
|
||||||
|
|
||||||
:dbg-call
|
:dbg-call
|
||||||
(fn [x ...]
|
(fn [x ...]
|
||||||
`(do
|
`(do
|
||||||
|
|
|
@ -10,9 +10,8 @@
|
||||||
(defn plugin-installed? [name]
|
(defn plugin-installed? [name]
|
||||||
(~= nil (. packer_plugins name)))
|
(~= nil (. packer_plugins name)))
|
||||||
|
|
||||||
(defn dbg [x]
|
(defn all [f xs]
|
||||||
(a.println (fennel.view x))
|
(not (a.some (not (f $1)))))
|
||||||
x)
|
|
||||||
|
|
||||||
(defn single-to-list [x]
|
(defn single-to-list [x]
|
||||||
"Returns the list given to it. If given a single value, wraps it in a list"
|
"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]
|
(defn without-keys [keys t]
|
||||||
(filter-table #(not (contains? keys $1)) t))
|
(filter-table #(not (contains? keys $1)) t))
|
||||||
|
|
||||||
|
|
||||||
(defn keymap [modes from to ?opts]
|
(defn keymap [modes from to ?opts]
|
||||||
"Set a mapping in the given modes, and some optional parameters, defaulting to {:noremap true :silent true}.
|
"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"
|
If :buffer is set, uses buf_set_keymap rather than set_keymap"
|
||||||
|
@ -68,6 +66,10 @@
|
||||||
(use (a.assoc opts 1 name)))))))
|
(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]
|
(defn surround-if-present [a mid b]
|
||||||
(if mid
|
(if mid
|
||||||
(.. a mid b)
|
(.. a mid b)
|
||||||
|
|
Loading…
Reference in a new issue