-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(iferr): add to installer & config * feat(iferr): add first implementation * docs(iferr): add
- Loading branch information
Showing
6 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
local c = require("gopher.config").config.commands | ||
local u = require "gopher._utils" | ||
|
||
---Add iferr declaration | ||
---That's Lua of vimscript implementation of: | ||
---github.com/koron/iferr | ||
return function() | ||
local boff = vim.fn.wordcount().cursor_bytes | ||
local cmd = (c.iferr .. " -pos " .. boff) | ||
local data = vim.fn.systemlist(cmd, vim.fn.bufnr "%") | ||
|
||
if vim.v.shell_error ~= 0 then | ||
u.notify("command " .. cmd .. " exited with code " .. vim.v.shell_error, "error") | ||
return | ||
end | ||
|
||
local pos = vim.fn.getcurpos()[2] | ||
vim.fn.append(pos, data) | ||
vim.cmd [[silent normal! j=2j]] | ||
vim.fn.setpos(".", pos) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters