ruanyl / vim-gh-line

vim plugin that open the link of current line on github
MIT License
406 stars 37 forks source link

Correct command to open URL generated, but the page doesn't open #55

Open alichtman opened 2 years ago

alichtman commented 2 years ago

When I trigger the plugin, I see

vim-gh-line executing: xdg-open https://github.com/alichtman/shallow-backup/blob/a5b36f3532f07c4fc577495a2d476f8e133456ff/README.md#L239

but the page never opens in Firefox. Running that command manually in a terminal does open the page.

Env

nvim health check


coc: health#coc#check
========================================================================
  - OK: nvim version satisfied
  - OK: Environment check passed
  - OK: Javascript bundle build/index.js found
  - OK: Service started

jedi: health#jedi#check
========================================================================
## jedi

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $VTE_VERSION='6800'
  - INFO: $TERM_PROGRAM='tmux'
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 0
  - INFO: Checking stuff
  - OK: focus-events: on
  - INFO: $TERM: xterm-256color
  - ERROR: $TERM should be "screen-256color" or "tmux-256color" in tmux. Colors might look wrong.
    - ADVICE:
      - Set default-terminal in ~/.tmux.conf:
          set-option -g default-terminal "screen-256color"
      - https://github.com/neovim/neovim/wiki/FAQ
  - WARNING: Neither Tc nor RGB capability set. True colors are disabled. |'termguicolors'| won't work properly.
    - ADVICE:
      - Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
          set-option -sa terminal-overrides ',XXX:RGB'
      - For older tmux versions use this instead:
          set-option -ga terminal-overrides ',XXX:Tc'

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - INFO: pyenv: Path: /usr/local/var/pyenv/libexec/pyenv
  - INFO: pyenv: Root: /usr/local/var/pyenv
  - INFO: Using: g:python_host_prog = "/usr/bin/python2"
  - INFO: Executable: /usr/bin/python2
  - ERROR: Command error (job=7, exit code 1): `'/usr/bin/python2' -c 'import sys; sys.path = list(filter(lambda x: x != "", sys.path)); import neovim; print(neovim.__file__)'` (in '/home/alichtman/Desktop/Development/projects/shallow-backup')
    stderr: Traceback (most recent call last):  File "<string>", line 1, in <module>ImportError: No module named neovim
  - INFO: Python version: 2.7.18
  - INFO: pynvim version: unable to load neovim Python module
  - ERROR: pynvim is not installed.
    Error: unable to load neovim Python module
    - ADVICE:
      - Run in shell: /usr/bin/python2 -m pip install pynvim

## Python 3 provider (optional)
  - INFO: pyenv: Path: /usr/local/var/pyenv/libexec/pyenv
  - INFO: pyenv: Root: /usr/local/var/pyenv
  - INFO: Using: g:python3_host_prog = "/usr/local/var/pyenv/shims/python3"
  - INFO: Executable: /usr/local/var/pyenv/shims/python3
  - INFO: Python version: 3.8.1
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.

## Node.js provider (optional)
  - INFO: Node.js: v18.3.0
  - WARNING: Missing "neovim" npm (or yarn) package.
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

## Perl provider (optional)
  - ERROR: perl provider error:
    - ADVICE:
      - "Neovim::Ext" cpan module is not installed

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /home/alichtman/.cache/nvim/lsp.log
  - INFO: Log size: 16 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
  - OK: Loaded parser for c: ABI version 13
zodman commented 2 years ago

same here!

I think its a neovim problem:

:call system('xdg-open http://firefox.com')

https://github.com/neovim/neovim/wiki/FAQ#-and-system-do-weird-things-with-interactive-processes

Im not neovim expert but should be other way to call xdg-open without system.

temporal solution, because I use a lot this plugin: add the setting let g:gh_trace=1 to your vimrc then you will at least see the URL on the statusline

zodman commented 1 year ago

@alichtman check prev message!

alichtman commented 1 year ago

@zodman Yup, I agree with your analysis (and thumbs'd up your comment the day you posted it 😃)

Leaving the issue open, as there's no proper fix

sebastian-palma commented 1 year ago

As mentioned here, you can use jobstart instead of system (works on Ubuntu 22.04, NVIM v0.9.0-dev-342+g282cbc235).

zodman commented 1 year ago

@sebastian-palma PR please please!

alichtman commented 1 year ago

I found out that vim-fugitive has this functionality baked in, so I added these two remappings and dropped the vim-gh-line plugin from my config.

" Open selection on github
nnoremap go :.GBrowse<CR>
vnoremap go :'<,'>.GBrowse<CR>

I think the proposed jobstart patch would fix this issue (and I would put up a PR if I hadn't already fixed my workflow).

sebastian-palma commented 1 year ago

@zodman see this, this is the only change I needed to make it work.