Skip to content

Commit

Permalink
docs(R.nvim.txt): remove outdated example of using Lua function for `…
Browse files Browse the repository at this point in the history
…open_app` configuration (#336)

* docs(R.nvim.txt): remove outdated example of using Lua function for `open_app` configuration

* refactor(edit.lua): simplify condition by removing redundant type check for open_app variable
  • Loading branch information
PMassicotte authored Feb 20, 2025
1 parent 48c0caf commit ae2e38b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
13 changes: 1 addition & 12 deletions doc/R.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1957,18 +1957,7 @@ Calc:
open_app = "localc"
open_app = "c:/Program Files (x86)/LibreOffice 4/program/scalc.exe"
<
`open_app` can be a Lua function which will receive a single argument: the name
of the `tsv` file. Example on how to see the first five lines as a
notification:
>lua
view_df = {
n_lines = 5,
open_app = function(file_name)
local lines = vim.fn.readfile(file_name)
vim.notify(table.concat(lines, "\n"))
end
}
<

The substring `%s` is replaced by the name of the object under the cursor, and
`()` are added if necessary. In this case, no `csv` file is saved (see also
|R.nvim-key-bindings|).
Expand Down
7 changes: 1 addition & 6 deletions lua/r/edit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ M.view_df = function(oname, txt)
fname = oname
end

if type(open_app) == "string" and open_app == "" then
if open_app == "" then
if vim.fn.bufloaded(fname) == 1 then
local sbopt = vim.o.switchbuf
vim.o.switchbuf = "useopen,usetab"
Expand Down Expand Up @@ -324,11 +324,6 @@ M.view_df = function(oname, txt)
end
M.add_for_deletion(tsvnm)

if type(open_app) == "function" then
open_app(tsvnm)
return
end

local cmd
if open_app:find("%%s") then
cmd = string.format(open_app, tsvnm)
Expand Down

0 comments on commit ae2e38b

Please sign in to comment.