Skip to content

Commit

Permalink
fix: replace deprecated nvim_exec
Browse files Browse the repository at this point in the history
  • Loading branch information
crispgm committed Dec 29, 2023
1 parent 76a72fa commit e8feb43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lua/go/format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local function do_fmt(formatter, args)
local buf_nr = vim.api.nvim_get_current_buf()
local file_path = vim.api.nvim_buf_get_name(buf_nr)
local view = vim.fn.winsaveview()
vim.api.nvim_exec('noautocmd write', true)
vim.api.nvim_exec2('noautocmd write', { output = true })
local original_file_len = vim.fn.line('$')
local original_line = vim.fn.getline('.')
local original_col_nr = vim.fn.col('.')
Expand All @@ -48,14 +48,14 @@ local function do_fmt(formatter, args)
on_exit = function(_, code, _)
if code == 0 then
output.show_success('GoFormat', 'Success')
vim.api.nvim_exec('edit', true)
vim.api.nvim_exec2('edit', { output = true })
vim.fn.winrestview(view)
if config.options.maintain_cursor_pos then
local new_line_nr = get_new_line_nr(original_file_len)
local new_line = vim.fn.getline(new_line_nr)
local new_col_nr =
get_new_col_nr(new_line, original_line, original_col_nr)
vim.fn.cursor(new_line_nr, new_col_nr)
vim.fn.cursor({ new_line_nr, new_col_nr })
end
end
end,
Expand Down
4 changes: 2 additions & 2 deletions lua/go/struct_tag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ local function modify_tags(prefix, args)
end

local view = vim.fn.winsaveview()
vim.api.nvim_exec('noautocmd write', true)
vim.api.nvim_exec2('noautocmd write', { output = true })
vim.fn.jobstart(cmd, {
on_exit = function(_, code, _)
if code == 0 then
output.show_success(prefix, 'Success')
vim.api.nvim_exec('edit', true)
vim.api.nvim_exec2('edit', { output = true })
vim.fn.winrestview(view)
end
end,
Expand Down

0 comments on commit e8feb43

Please sign in to comment.