Skip to content

Instantly share code, notes, and snippets.

@destinio
Created February 13, 2023 20:00
Show Gist options
  • Save destinio/7ccc80d6d60424f8ed8348d54a5cf27b to your computer and use it in GitHub Desktop.
Save destinio/7ccc80d6d60424f8ed8348d54a5cf27b to your computer and use it in GitHub Desktop.
Open notes in floating window
local api = vim.api
local h = api.nvim_list_uis()[1].height
local w = api.nvim_list_uis()[1].width
local width = math.floor(api.nvim_win_get_width(0) / 2)
local height = math.floor(api.nvim_win_get_height(0) / 2)
local buf = api.nvim_create_buf(false, true)
api.nvim_open_win(buf, true, {
relative = "editor",
width = width,
height = height,
row = (h - height) * 0.5,
col = (w - width) * 0.5,
})
vim.cmd(":edit ~/NOTES/random.md")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment