minor tweaks

This commit is contained in:
raf 2023-12-31 12:26:55 +03:00
parent 8dd06ed2d4
commit dad9dc8f94
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
2 changed files with 11 additions and 10 deletions

View file

@ -15,7 +15,7 @@
```lua ```lua
use { use {
'aspeddro/slides.nvim', 'notashelf/slides.nvim',
config = function () config = function ()
require'slides'.setup{} require'slides'.setup{}
end end
@ -36,11 +36,11 @@ require'slides'.setup{
Open current file Open current file
``` ```console
:Slides :Slides
``` ```
``` ```console
:Slides [path/to/file.md] :Slides [path/to/file.md]
``` ```

View file

@ -6,7 +6,9 @@ local state = {
local config = { local config = {
bin = 'slides', bin = 'slides',
fullscreen = true fullscreen = true,
style = "minimal",
border = "shadow"
} }
function M.close() function M.close()
@ -22,24 +24,24 @@ function M.setup(user_config)
end end
function M.show(file) function M.show(file)
local window = vim.api.nvim_get_current_win() local window = vim.api.nvim_get_current_win()
local opts = { local opts = {
style = "minimal", style = config.style,
relative = "editor", relative = "editor",
width = config.fullscreen and vim.api.nvim_get_option("columns") or vim.api.nvim_win_get_width(window), width = config.fullscreen and vim.api.nvim_get_option("columns") or vim.api.nvim_win_get_width(window),
height = config.fullscreen and vim.api.nvim_get_option("lines") or vim.api.nvim_win_get_height(window), height = config.fullscreen and vim.api.nvim_get_option("lines") or vim.api.nvim_win_get_height(window),
row = 1, row = 1,
col = 1, col = 1,
border = "shadow", border = config.border,
} }
local input = string.len(file) == 0 and vim.api.nvim_get_current_buf() or file local input = string.len(file) == 0 and vim.api.nvim_get_current_buf() or file
local is_file = type(input) == 'string' local is_file = type(input) == 'string'
local filetype = is_file and vim.fn.fnamemodify(input, ':e'):gsub("\"", "") or vim.api.nvim_buf_get_option(input, 'filetype') local filetype = is_file and vim.fn.fnamemodify(input, ':e'):gsub("\"", "") or
vim.api.nvim_buf_get_option(input, 'filetype')
if not vim.tbl_contains({'md', 'markdown'}, filetype) then if not vim.tbl_contains({ 'md', 'markdown' }, filetype) then
vim.api.nvim_err_writeln('Invalid filetype') vim.api.nvim_err_writeln('Invalid filetype')
return return
end end
@ -61,7 +63,6 @@ function M.show(file)
M.close() M.close()
end end
}) })
end end
return M return M