Browse Source

bug fix for netrw's gx command (#431)

* open remote link in browser correctly with gx, not in a tmp file
rmagillxyz 4 years ago
parent
commit
31fcd6c1df
3 changed files with 10 additions and 3 deletions
  1. 5 0
      lua/keymappings.lua
  2. 2 2
      lua/lv-globals.lua
  3. 3 1
      lua/settings.lua

+ 5 - 0
lua/keymappings.lua

@@ -47,6 +47,11 @@ vim.api.nvim_set_keymap('x', 'J', ':move \'>+1<CR>gv-gv', {noremap = true, silen
 -- Better nav for omnicomplete
 -- Better nav for omnicomplete
 vim.cmd('inoremap <expr> <c-j> (\"\\<C-n>\")')
 vim.cmd('inoremap <expr> <c-j> (\"\\<C-n>\")')
 vim.cmd('inoremap <expr> <c-k> (\"\\<C-p>\")')
 vim.cmd('inoremap <expr> <c-k> (\"\\<C-p>\")')
+
+-- fix to get netrw's gx command to work correctly 
+vim.api.nvim_set_keymap('n', 'gx', ":call netrw#BrowseX(expand((exists('g:netrw_gx')? g:netrw_gx : '<cfile>')),netrw#CheckIfRemote())<cr>", {noremap = true, silent = true})
+
+
 -- vim.cmd('inoremap <expr> <TAB> (\"\\<C-n>\")')
 -- vim.cmd('inoremap <expr> <TAB> (\"\\<C-n>\")')
 -- vim.cmd('inoremap <expr> <S-TAB> (\"\\<C-p>\")')
 -- vim.cmd('inoremap <expr> <S-TAB> (\"\\<C-p>\")')
 
 

+ 2 - 2
lua/lv-globals.lua

@@ -11,8 +11,8 @@ O = {
     number = true,
     number = true,
     relative_number = true,
     relative_number = true,
     shell = 'bash',
     shell = 'bash',
-	timeoutlen = 100,
-    nvim_tree_disable_netrw = 0, -- "1 by default, disables netrw (must be set before plugin's packadd)
+	  timeoutlen = 100,
+    nvim_tree_disable_netrw = 0, 
 
 
     -- @usage pass a table with your desired languages
     -- @usage pass a table with your desired languages
     treesitter = {
     treesitter = {

+ 3 - 1
lua/settings.lua

@@ -34,7 +34,9 @@ vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shif
 vim.o.updatetime = 300 -- Faster completion
 vim.o.updatetime = 300 -- Faster completion
 vim.o.timeoutlen = O.timeoutlen -- By default timeoutlen is 1000 ms
 vim.o.timeoutlen = O.timeoutlen -- By default timeoutlen is 1000 ms
 vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else
 vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else
-vim.g.nvim_tree_disable_netrw = O.nvim_tree_disable_netrw
+vim.g.nvim_tree_disable_netrw = O.nvim_tree_disable_netrw -- enable netrw for remote gx gf support (must be set before plugin's packadd)
+vim.g.loaded_netrwPlugin = 1 -- needed for netrw gx command to open remote links in browser
+vim.cmd('filetype plugin on') -- filetype detection
 -- vim.o.guifont = "JetBrainsMono\\ Nerd\\ Font\\ Mono:h18"
 -- vim.o.guifont = "JetBrainsMono\\ Nerd\\ Font\\ Mono:h18"
 -- vim.o.guifont = "Hack\\ Nerd\\ Font\\ Mono"
 -- vim.o.guifont = "Hack\\ Nerd\\ Font\\ Mono"
 -- vim.o.guifont = "SauceCodePro Nerd Font:h17"
 -- vim.o.guifont = "SauceCodePro Nerd Font:h17"