Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual pages aren't displaying correctly #55

Closed
slococo opened this issue Sep 29, 2021 · 9 comments
Closed

Manual pages aren't displaying correctly #55

slococo opened this issue Sep 29, 2021 · 9 comments

Comments

@slococo
Copy link

slococo commented Sep 29, 2021

This is the output of man nvimpager:
https://i.imgur.com/lhZrjaN.png

Do you know what can I do?

@lucc
Copy link
Owner

lucc commented Sep 29, 2021

What version of nvim and nvimpager are you running? On which OS?

If you do not have the newest version of nvimpager you can try to update that first. Otherwise we have to investigate (I can not reproduce your problem here (yet)).

@slococo
Copy link
Author

slococo commented Sep 30, 2021

nvimpager-git 0.10.2.r6.g49315df-1 (https://aur.archlinux.org/packages/nvimpager-git/)
Arch Linux

@lucc
Copy link
Owner

lucc commented Sep 30, 2021

I can reproduce this in a podman container like so:

podman run --rm --tty --interactive archlinux

pacman -Syu
pacman -Syu neovim git scdoc make man
git clone https://github.com/lucc/nvimpager
cd nvimpager/
make nvimpager.1
PAGER=./nvimpager man ./nvimpager.1

It might be that I am still using neovim 0.5 and arch linux already has 0.5.1.
There was a note about something like that: neovim/neovim#14090 (comment)

Can you check if this patch helps:

diff --git a/lua/nvimpager.lua b/lua/nvimpager.lua
index 6737833..55f8685 100644
--- a/lua/nvimpager.lua
+++ b/lua/nvimpager.lua
@@ -392,7 +392,7 @@ end
 local function detect_filetype()
   if not doc then
     if detect_man_page_in_current_buffer() then
-      nvim.nvim_buf_set_option(0, 'filetype', 'man')
+      nvim.nvim_command('Man!')
     end
   else
     if doc == 'git' then

@slococo
Copy link
Author

slococo commented Sep 30, 2021

Sorry, but the patch didn't fix the problem.

@lucc
Copy link
Owner

lucc commented Oct 1, 2021

Ok, maybe this works better:

diff --git a/lua/nvimpager.lua b/lua/nvimpager.lua
index 6737833..deebccf 100644
--- a/lua/nvimpager.lua
+++ b/lua/nvimpager.lua
@@ -390,18 +390,18 @@ end
 -- Detect possible filetypes for the current buffer by looking at the pstree
 -- or ansi escape sequences or manpage sequences in the current buffer.
 local function detect_filetype()
-  if not doc then
-    if detect_man_page_in_current_buffer() then
-      nvim.nvim_buf_set_option(0, 'filetype', 'man')
-    end
+  if not doc and detect_man_page_in_current_buffer() then doc = 'man' end
+  if doc == 'git' then
+    -- Use nvim's syntax highlighting for git buffers instead of git's
+    -- internal highlighting.
+    strip_ansi_escape_sequences_from_current_buffer()
+  end
+  if doc == 'man' then
+    nvim.nvim_buf_set_option(0, 'readonly', false)
+    nvim.nvim_command("Man!")
+    nvim.nvim_buf_set_option(0, 'readonly', true)
   else
-    if doc == 'git' then
-      -- Use nvim's syntax highlighting for git buffers instead of git's
-      -- internal highlighting.
-      strip_ansi_escape_sequences_from_current_buffer()
-    elseif doc == 'pydoc' or doc == 'perldoc' or doc == 'ri' then
-      doc = 'man'
-    end
+    if doc == 'pydoc' or doc == 'perldoc' or doc == 'ri' then doc = 'man' end
     nvim.nvim_buf_set_option(0, 'filetype', doc)
   end
 end

@slococo
Copy link
Author

slococo commented Oct 1, 2021

Yep, that definitely works! TY!!!

@slococo
Copy link
Author

slococo commented Oct 18, 2021

Hi, I have a problem with this patch. If I run nmcli -a it will show: "Error detected while processing command line:
E5108: Error executing lua ...user/.local/share/nvimpager/runtime/lua/nvimpager.lua:405: Cannot unset option 'filety
pe' because it doesn't have a global value". Line 405 is nvim.nvim_buf_set_option(0, 'filetype', doc). I can live with this bug but I thought it was worth mentioning

@lucc
Copy link
Owner

lucc commented Nov 8, 2021

sorry @slococo for the late reply: is your new problem with the patch as posted in this thread or with 63709c4 ?

I think the commit has a fix for your problem.

@slococo
Copy link
Author

slococo commented Nov 23, 2021

I installed the latest version and now it works perfectly. TY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants