diff --git a/lua/r/doc.lua b/lua/r/doc.lua index 69809931..d4d969a0 100644 --- a/lua/r/doc.lua +++ b/lua/r/doc.lua @@ -130,8 +130,10 @@ M.show = function(rkeyword, txt) txt = txt:gsub("\019", "'") local lines + local is_help = false if txt:find("\008") then lines = require("r.rdoc").fix_rdoc(txt) + is_help = true else lines = vim.split(txt, "\020") end @@ -139,7 +141,7 @@ M.show = function(rkeyword, txt) if rkeyword:find("R History", 1, true) then vim.api.nvim_set_option_value("filetype", "r", { scope = "local" }) vim.api.nvim_win_set_cursor(0, { 1, 0 }) - elseif rkeyword:find("(help)", 1, true) or vim.fn.search("\008", "nw") > 0 then + elseif is_help then require("r.rdoc").set_buf_options() vim.api.nvim_win_set_cursor(0, { 1, 0 }) elseif rkeyword:find("%.Rd$") then diff --git a/lua/r/rdoc.lua b/lua/r/rdoc.lua index 8e6badce..483c6769 100644 --- a/lua/r/rdoc.lua +++ b/lua/r/rdoc.lua @@ -25,7 +25,13 @@ M.set_buf_options = function() syn match rdocArgDelim / / contained conceal hi def link rdocArgItem Identifier ]]) - + local buf = vim.api.nvim_get_current_buf() + if vim.fn.has("nvim-0.11") == 1 then + local ns = vim.api.nvim_create_namespace("RDocumentation") + vim.hl.range(buf, ns, "Title", { 0, 1 }, { 0, -1 }, {}) + else + vim.api.nvim_buf_add_highlight(buf, -1, "Title", 0, 0, -1) + end require("r.config").real_setup() require("r.maps").create("rdoc") end diff --git a/nvimcom/DESCRIPTION b/nvimcom/DESCRIPTION index 5985a84f..0b505b92 100644 --- a/nvimcom/DESCRIPTION +++ b/nvimcom/DESCRIPTION @@ -1,6 +1,6 @@ Package: nvimcom -Version: 0.9.64 -Date: 2025-02-25 +Version: 0.9.65 +Date: 2025-02-27 Title: Intermediate the Communication Between R and Neovim Author: Jakson Aquino Maintainer: Jakson Alves de Aquino diff --git a/nvimcom/R/help.R b/nvimcom/R/help.R index 08c5f86f..7725e779 100644 --- a/nvimcom/R/help.R +++ b/nvimcom/R/help.R @@ -2,9 +2,7 @@ # R.nvim sets this option during nvimcom loading. nvim.hmsg <- function(files, header, title, delete.file) { doc <- nvim.fix.string(paste(readLines(files[1]), collapse = "\x14")) - ttl <- sub("R Help on '(.*)'", "\\1 (help)", title) - ttl <- sub("R Help on \u2018(.*)\u2019", "\\1 (help)", ttl) - ttl <- nvim.fix.string(ttl) + ttl <- nvim.fix.string(title) .C(nvimcom_msg_to_nvim, paste0("lua require('r.doc').show('", ttl, "', '", doc, "')")) return(invisible(NULL)) }