enhance: improved notices.show_notices (#70)
- Prefer use of lua functions instead of vim.cmd - Added buffer and window options - Moved from append to appendbufline
This commit is contained in:
parent
20a87ac78c
commit
05d6a13369
|
@ -36,12 +36,22 @@ function M.notice_message_startup()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.show_notices()
|
function M.show_notices()
|
||||||
vim.cmd [[
|
vim.cmd('silent! keepalt split')
|
||||||
:silent! new
|
|
||||||
:silent! setl ft=markdown bt=nofile nobuflisted bh=wipe
|
local winid = vim.fn.win_getid()
|
||||||
:silent! nnoremap <silent><buffer> q <cmd>bd<cr>
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
:silent! normal ggdG
|
vim.api.nvim_win_set_buf(winid, bufnr)
|
||||||
]]
|
|
||||||
|
vim.wo[winid].winfixheight = true
|
||||||
|
vim.wo[winid].winfixwidth = true
|
||||||
|
vim.wo[winid].number = false
|
||||||
|
vim.wo[winid].foldcolumn = '0'
|
||||||
|
vim.wo[winid].relativenumber = false
|
||||||
|
vim.wo[winid].signcolumn = 'no'
|
||||||
|
vim.bo[bufnr].filetype = 'markdown'
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'q', '<Cmd>bd<CR>', { noremap = true, silent = true })
|
||||||
|
|
||||||
local ok, _ = pcall(vim.api.nvim_buf_set_name, 0, 'Lualine Notices')
|
local ok, _ = pcall(vim.api.nvim_buf_set_name, 0, 'Lualine Notices')
|
||||||
if not ok then
|
if not ok then
|
||||||
vim.notify('Lualine Notices is already open in another window', vim.log.levels.ERROR, {})
|
vim.notify('Lualine Notices is already open in another window', vim.log.levels.ERROR, {})
|
||||||
|
@ -50,9 +60,12 @@ function M.show_notices()
|
||||||
end
|
end
|
||||||
local notice = vim.tbl_flatten(persistent_notices)
|
local notice = vim.tbl_flatten(persistent_notices)
|
||||||
notice = vim.list_extend(notice, vim.tbl_flatten(notices))
|
notice = vim.list_extend(notice, vim.tbl_flatten(notices))
|
||||||
vim.fn.append(0, notice)
|
vim.fn.appendbufline(bufnr, 0, notice)
|
||||||
vim.api.nvim_win_set_cursor(0, { 1, 0 })
|
|
||||||
vim.bo.modifiable=false
|
vim.fn.deletebufline(bufnr, #notice, vim.fn.line('$'))
|
||||||
|
vim.api.nvim_win_set_cursor(winid, { 1, 0 })
|
||||||
|
vim.bo[bufnr].modified = false
|
||||||
|
vim.bo[bufnr].modifiable = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.clear_notices()
|
function M.clear_notices()
|
||||||
|
|
Loading…
Reference in New Issue