From 288208257c8d6b3c8dcce7ee6c7b6c7bb7bafb27 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sat, 8 Oct 2022 15:48:07 +0100 Subject: feat(cscope)!: remove --- runtime/lua/man.lua | 5 ----- 1 file changed, 5 deletions(-) (limited to 'runtime/lua/man.lua') diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index 6477786dbb..18d08ad1a8 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -604,11 +604,6 @@ function M.goto_tag(pattern, _, _) end end - if vim.o.cscopetag then - -- return only a single entry so we work well with :cstag (#11675) - structured = { structured[1] } - end - return vim.tbl_map(function(entry) return { name = entry.name, -- cgit From 39911d76be560c998cc7dee51c5d94f811164f66 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Mon, 17 Oct 2022 04:37:44 -0500 Subject: fix(man): handle absolute paths as `:Man` targets (#20624) * fix(man): handle absolute paths as :Man targets Previously, attempting to provide `:Man` with an absolute path as the name would cause neovim to return the following error: ``` Error detected while processing command line: /usr/local/share/nvim/runtime/lua/man.lua:690: /usr/local/share/nvim/runtime/lua/man.lua:683: Vim:E426: tag not found: nil(nil) Press ENTER or type command to continue ``` ..because it would try to validate the existence of a man page for the provided name by executing `man -w /some/path` which (on at least some Linux machines [0]) returns `/some/path` instead of the path to the nroff files that would be formatted to satisfy the man(1) lookup. While man pages are not normally named after absolute paths, users shouldn't be blamed for trying. Given such a name/path, neovim would **not** complain that the path didn't have a corresponding man file but would error out when trying to call the tag function for the null-propagated name-and-section `nil(nil)`. (The same underlying error existed before this function was ported to lua, but did not exhibit the lua-specific `nil(nil)` name; instead a tag lookup for `()` would fail and error out.) With this patch, we detect the case where `man -w ...` returns the same value as the provided name to not only prevent invoking the tag function for a non-existent/malformed name+sect but also to properly report the non-existence of a man page for the provided lookup (the absolute path). While man(1) can be used to directly read an nroff-formatted document via `man /path/to/nroff.doc`, `:Man /path/to/nroff.doc` never supported this behavior so no functionality is lost in case the provided path _was_ an nroff file. [0]: `man -w /absolute/path` returning `/absolute/path` observed on an Ubuntu 18.04 installation. * test: add regression test for #20624 Add a functional test to `man_spec.lua` to check for a regression for #20624 by first obtaining an absolute path to a random file and materializing it to disk, then attempting to query `:Man` for an entry by that same name/path. The test passes if nvim correctly reports that there is no man page correspending to the provided name/path and fails if any other error (or no error) is shown. --- runtime/lua/man.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runtime/lua/man.lua') diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index 18d08ad1a8..6eebee6376 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -283,6 +283,14 @@ local function get_path(sect, name, silent) return end + -- `man -w /some/path` will return `/some/path` for any existent file, which + -- stops us from actually determining if a path has a corresponding man file. + -- Since `:Man /some/path/to/man/file` isn't supported anyway, we should just + -- error out here if we detect this is the case. + if sect == '' and #results == 1 and results[1] == name then + return + end + -- find any that match the specified name local namematches = vim.tbl_filter(function(v) return fn.fnamemodify(v, ':t'):match(name) -- cgit From cc5b7368d61cfcd775dd02803dbdb8d4d05b5d5d Mon Sep 17 00:00:00 2001 From: Kevin Hwang Date: Thu, 3 Nov 2022 09:13:29 +0800 Subject: fix(man.lua): set modifiable before writing page (#20914) --- runtime/lua/man.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/man.lua') diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index 6eebee6376..5951884e07 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -457,7 +457,7 @@ local function get_page(path, silent) end local function put_page(page) - vim.bo.modified = true + vim.bo.modifiable = true vim.bo.readonly = false vim.bo.swapfile = false -- cgit From 0faf007a236c9b51f151790f79ee59366b501c55 Mon Sep 17 00:00:00 2001 From: euclidianAce Date: Wed, 9 Nov 2022 17:26:02 -0600 Subject: fix(man.lua): use `env` command (#21007) Previously man.lua would use the `env` field in the parameters of `vim.loop.spawn` to override things like MANPAGER. This caused issues on NixOS since `spawn` will _override_ the environment rather than _append_ to it (and NixOS relies on a heavily modified environment). Using the `env` command to append to the environment solves this issue. --- runtime/lua/man.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'runtime/lua/man.lua') diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index 5951884e07..a644dd68b8 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -12,7 +12,7 @@ local function man_error(msg) end -- Run a system command and timeout after 30 seconds. -local function system(cmd, silent, env) +local function system(cmd_, silent, env) local stdout_data = {} local stderr_data = {} local stdout = vim.loop.new_pipe(false) @@ -21,11 +21,23 @@ local function system(cmd, silent, env) local done = false local exit_code + -- We use the `env` command here rather than the env option to vim.loop.spawn since spawn will + -- completely overwrite the environment when we just want to modify the existing one. + -- + -- Overwriting mainly causes problems NixOS which relies heavily on a non-standard environment. + local cmd + if env then + cmd = { 'env' } + vim.list_extend(cmd, env) + vim.list_extend(cmd, cmd_) + else + cmd = cmd_ + end + local handle handle = vim.loop.spawn(cmd[1], { args = vim.list_slice(cmd, 2), stdio = { nil, stdout, stderr }, - env = env, }, function(code) exit_code = code stdout:close() -- cgit From 3c48d3c83fc21dbc0841f9210f04bdb073d73cd1 Mon Sep 17 00:00:00 2001 From: 0xAdk <29005635+0xAdk@users.noreply.github.com> Date: Wed, 25 Jan 2023 06:39:25 -0800 Subject: fix(man.lua): open in current window if it's already a man page (#21987) This matters when there are multiple man page windows open. --- runtime/lua/man.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime/lua/man.lua') diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index a644dd68b8..732a4ab92e 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -420,6 +420,10 @@ local function extract_sect_and_name_path(path) end local function find_man() + if vim.bo.filetype == 'man' then + return true + end + local win = 1 while win <= fn.winnr('$') do local buf = fn.winbufnr(win) -- cgit