Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Replace deprecated function
Browse files Browse the repository at this point in the history
desdic committed May 18, 2024
1 parent cc00491 commit ae539b5
Showing 2 changed files with 18 additions and 15 deletions.
20 changes: 10 additions & 10 deletions lua/macrothis/utils.lua
Original file line number Diff line number Diff line change
@@ -115,23 +115,23 @@ utils.create_edit_register = function(register)

vim.api.nvim_buf_set_lines(bufnr, 0, 0, true, { entrycontent })

vim.api.nvim_buf_set_option(bufnr, "modifiable", true)
vim.api.nvim_buf_set_option(bufnr, "buftype", "nofile")
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr })
vim.api.nvim_set_option_value("buftype", "nofile", { buf = bufnr })
vim.api.nvim_buf_set_name(bufnr, "editing " .. register)

vim.api.nvim_create_autocmd({ "BufWinLeave" }, {
callback = function(bufopts)
local bufcontent =
vim.api.nvim_buf_get_lines(bufopts.buf, 0, -1, true)

bufcontent = table.concat(bufcontent, "")
local bbufcontent = table.concat(bufcontent, "")

-- Re-add newlines
local newcontent = bufcontent:gsub("\\n", "\n")
local newcontent = bbufcontent:gsub("\\n", "\n")

vim.fn.setreg(register, newcontent, entrytype)

vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
vim.api.nvim_win_close(0, true)
vim.schedule(function()
vim.cmd("bdelete! " .. bufnr)
@@ -159,24 +159,24 @@ utils.create_edit_window = function(opts, description)

vim.api.nvim_buf_set_lines(bufnr, 0, 0, true, { entrycontent })

vim.api.nvim_buf_set_option(bufnr, "modifiable", true)
vim.api.nvim_buf_set_option(bufnr, "buftype", "nofile")
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr })
vim.api.nvim_set_option_value("buftype", "nofile", { buf = bufnr })
vim.api.nvim_buf_set_name(bufnr, entrylabel)

vim.api.nvim_create_autocmd({ "BufWinLeave" }, {
callback = function(bufopts)
local bufcontent =
vim.api.nvim_buf_get_lines(bufopts.buf, 0, -1, true)

bufcontent = table.concat(bufcontent, "")
local bbufcontent = table.concat(bufcontent, "")

-- Re-add newlines
local newcontent = bufcontent:gsub("\\n", "\n")
local newcontent = bbufcontent:gsub("\\n", "\n")

vim.fn.setreg(opts.run_register, newcontent, entrytype)
utils.store_register(opts, opts.run_register, entrylabel)

vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
vim.api.nvim_win_close(0, true)
vim.schedule(function()
vim.cmd("bdelete! " .. bufnr)
13 changes: 8 additions & 5 deletions lua/telescope/_extensions/macrothis.lua
Original file line number Diff line number Diff line change
@@ -370,14 +370,17 @@ local help = function(prompt_bufnr)
end

local bufnr = vim.api.nvim_create_buf(false, false)
vim.api.nvim_buf_set_option(bufnr, "buftype", "nofile")
vim.api.nvim_buf_set_option(bufnr, "filetype", "macrothishelp")
vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
vim.api.nvim_buf_set_option(bufnr, "swapfile", false)

local options = { buf = bufnr }

vim.api.nvim_set_option_value("buftype", "nofile", options)
vim.api.nvim_set_option_value("filetype", "macrothishelp", options)
vim.api.nvim_set_option_value("bufhidden", "wipe", options)
vim.api.nvim_set_option_value("swapfile", false, options)

vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, entries)

vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
vim.api.nvim_set_option_value("modifiable", false, options)

opts.style = "minimal"
opts.zindex = 200

0 comments on commit ae539b5

Please sign in to comment.