Skip to content

Commit

Permalink
fix: Replace deprecated function
Browse files Browse the repository at this point in the history
  • Loading branch information
desdic committed May 18, 2024
1 parent cc00491 commit 6da31c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: date +%F > todays-date
- name: Restore cache for today's nightly.
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: _neovim
key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }}
Expand Down
20 changes: 10 additions & 10 deletions lua/macrothis/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions lua/telescope/_extensions/macrothis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6da31c9

Please sign in to comment.