Skip to content

Commit

Permalink
Merge pull request #13 from desdic/v0.10
Browse files Browse the repository at this point in the history
Fix: replace deprecated functions
  • Loading branch information
desdic authored May 18, 2024
2 parents cc00491 + 6001c7f commit 6a9a23a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 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
22 changes: 11 additions & 11 deletions doc/macrothis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*macrothis.nvim*
Macrothis.nvim is a plugin for saving and loading registers/macros

Usage~
Usage ~
Using Lazy plugin manager
{
"desdic/macrothis.nvim",
Expand Down Expand Up @@ -74,79 +74,79 @@ Using Lazy plugin manager
`macrothis.save`()
Save a macro/register

Usage~
Usage ~
`require('macrothis').save()`

------------------------------------------------------------------------------
*macrothis.load()*
`macrothis.load`()
Load a macro/register

Usage~
Usage ~
`require('macrothis').load()`

------------------------------------------------------------------------------
*macrothis.delete()*
`macrothis.delete`()
Delete a macro/register

Usage~
Usage ~
`require('macrothis').delete()`

------------------------------------------------------------------------------
*macrothis.run()*
`macrothis.run`()
Run macro

Usage~
Usage ~
`require('macrothis').run()`

------------------------------------------------------------------------------
*macrothis.quickfix()*
`macrothis.quickfix`()
Run macro on all in quickfix list

Usage~
Usage ~
`require('macrothis').quickfix()`

------------------------------------------------------------------------------
*macrothis.edit()*
`macrothis.edit`()
Edit macro

Usage~
Usage ~
`require('macrothis').edit()`

------------------------------------------------------------------------------
*macrothis.rename()*
`macrothis.rename`()
Rename macro

Usage~
Usage ~
`require('macrothis').rename()`

------------------------------------------------------------------------------
*macrothis.register()*
`macrothis.register`()
Modify register

Usage~
Usage ~
require('macrothis').register()

------------------------------------------------------------------------------
*macrothis.copy_register_printable()*
`macrothis.copy_register_printable`()
Copy register as printable

Usage~
Usage ~
require('macrothis').copy_register_printable()

------------------------------------------------------------------------------
*macrothis.copy_macro_printable()*
`macrothis.copy_macro_printable`()
Copy macro as printable

Usage~
Usage ~
require('macrothis').copy_macro_printable()

------------------------------------------------------------------------------
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 6a9a23a

Please sign in to comment.