R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
128 stars 15 forks source link

`pdfviewer` not found (PDF Expert) #112

Closed stefanocoretta closed 2 months ago

stefanocoretta commented 2 months ago

Hi! I set the pdfviewer to /Applications/PDF Expert.app, but I get a warning that the app was not found.

This is my R.lua config.


return {
  {
    'R-nvim/R.nvim',
    lazy = false,
    config = {
      active_window_warn = false,
      pdfviewer = '/Applications/PDF Expert.app',
    },
  },
  'R-nvim/cmp-r',
  {
    'hrsh7th/nvim-cmp',
    config = function()
      require('cmp').setup { sources = { { name = 'cmp_r' } } }
      require('cmp_r').setup {}
    end,
  },
}
jalvesaq commented 2 months ago

I don't have access to any macOS to fix the bug, but, as far as I know, the path ending in .app is a directory, not the complete path of an executable. If PDF Expert is your default PDF viewer, you could try to set open as the pdfviewer value in R.nvim config.

mschilli87 commented 2 months ago

I don't have PDF Expert, but a Mac. For my browser, which qutebrowser yields qutebrowser: aliased to /Applications/qutebrowser.app/Contents/MacOS/qutebrowser. So I'd check the contents of /Applications/PDF Expert.app, starting with /Applications/PDF Expert.app/Contents/MacOS, if it exisist, looking for an executable. Once you confirm that you can launch the App through that binary, try adjusting your config lua file accordingly.

luciorq commented 2 months ago

As previously mentioned, for MacOS users, all installed binaries for the app can be found in the /Applications/PDF Expert.app/Contents/MacOS/ directory. However, it's important to note that running the binary directly may not always produce the same results as "double-clicking" the app icon.

If your goal is to replicate the action of "clicking" on the app icon or launching the app bundle via a Spotlight search, the most straightforward method is to use the open command. You can do this in one of two ways:

  1. To open the app using its name, enter:
open -a 'PDF Expert'
  1. To open the app by specifying its path, enter:
open -a '/Applications/PDF Expert.app'

Additionally, if you need to pass arguments to the app, you can create a shell script. This script can accept arguments and then use them when launching the app. For example, you might have a script like the following, which you could call from your code by specifying pdfviewer = 'script_path.sh':

#!/usr/bin/env bash
open -a '/Applications/PDF Expert.app' --args "${@}";

I hope this helps you understand the source of any issues you're experiencing.

jalvesaq commented 2 months ago

Thank you for the help, @mschilli87 and @luciorq! I believe that @stefanocoretta will be able to solve his problem with your explanations.

@stefanocoretta, please, reopen the issue if you still have problems configuring PDF Expert as your PDF viewer.