Open a README.md file in slide from anywhere
So I wrote this code like a keymap to open slide in a readme file
return {
{
'ofcljaved/present',
config = function()
local present = require('present')
vim.keymap.set('n', '<leader>r', function()
local cwd = vim.uv.cwd();
local file = vim.fn.findfile('README.md', cwd .. ';', 1)
if file and file ~= '' then
local current_buf = vim.api.nvim_get_current_buf()
local file_buf = vim.fn.bufnr(vim.fn.fnameescape(file))
if file_buf == -1 then
vim.cmd('edit ' .. vim.fn.fnameescape(file))
file_buf = vim.api.nvim_get_current_buf()
end
present.start_presentation({ bufnr = file_buf })
vim.api.nvim_create_autocmd('BufDelete', {
buffer = file_buf,
once = true,
callback = function()
print('UNloadin')
vim.api.nvim_command("buffer " .. current_buf)
end,
})
else
vim.notify('No README.md file found in the current directory', vim.log.levels.INFO, { title = 'present' })
end
end)
end
}
}
so I'm still a novice in lua so I read some docs and use AI to do this like I know about cwd from livegrep and use for opening the file and find_file
The issue is I wanted when I leave the slide by pressing q I should go back to the original place like from where I triggered the keymap but this quite not working.
for example:
When I'm in .tsx file or any other file I used leader r it opens slide I see it bla bla good but when I close the slide I'm in README.md which i should not but when I again go to .tsx file and then do the same thing and close it then It takes me back to original place like in .tsx how
I didn't understand and if anyone can help I'd appreciate this
Open a README.md file in slide from anywhere
So I wrote this code like a keymap to open slide in a readme file
so I'm still a novice in lua so I read some docs and use AI to do this like I know about cwd from livegrep and use for opening the file and find_file
The issue is I wanted when I leave the slide by pressing
qI should go back to the original place like from where I triggered the keymap but this quite not working.for example:
When I'm in .tsx file or any other file I used
leader rit opens slide I see it bla bla good but when I close the slide I'm in README.md which i should not but when I again go to .tsx file and then do the same thing and close it then It takes me back to original place like in .tsx howI didn't understand and if anyone can help I'd appreciate this