From 6da31c9510edc00441901cafcdea247b0ea4c646 Mon Sep 17 00:00:00 2001 From: Kim Gert Nielsen Date: Sat, 18 May 2024 16:05:03 +0200 Subject: [PATCH] fix: Replace deprecated function --- .github/workflows/docgen.yml | 6 +++--- lua/macrothis/utils.lua | 20 ++++++++++---------- lua/telescope/_extensions/macrothis.lua | 13 ++++++++----- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docgen.yml b/.github/workflows/docgen.yml index 0401279..dbb729f 100644 --- a/.github/workflows/docgen.yml +++ b/.github/workflows/docgen.yml @@ -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') }} diff --git a/lua/macrothis/utils.lua b/lua/macrothis/utils.lua index 5727328..d772625 100644 --- a/lua/macrothis/utils.lua +++ b/lua/macrothis/utils.lua @@ -115,8 +115,8 @@ 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" }, { @@ -124,14 +124,14 @@ utils.create_edit_register = function(register) 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,8 +159,8 @@ 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" }, { @@ -168,15 +168,15 @@ utils.create_edit_window = function(opts, description) 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) diff --git a/lua/telescope/_extensions/macrothis.lua b/lua/telescope/_extensions/macrothis.lua index 098836b..e3f563c 100644 --- a/lua/telescope/_extensions/macrothis.lua +++ b/lua/telescope/_extensions/macrothis.lua @@ -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