-
Notifications
You must be signed in to change notification settings - Fork 127
Status line
Jakson Alves de Aquino edited this page Jan 17, 2024
·
1 revision
It is possible to add the status of Nvim-R to Vim/Neovim status line. The example below is for lualine.nvim and will display the following states:
- nothing: Nvim-R not enabled.
-
-
(grey): An R file is being edited, but thenvimrserver
is not running yet. -
S
(grey): Thenvimrserver
started, but did not finish loading omni-completion data yet. -
S
(green): Thenvimrserver
loaded the omni-completion data. -
R
(orange): R was started, butnvimcom
is not loaded yet. -
R
(blue):nvimcom
is loaded and connected tonvimrserver
.
{
"nvim-lualine/lualine.nvim",
config = function()
local rstatus = function ()
if not vim.g.rplugin then
-- No R file type (R, Quarto, Rmd, Rhelp) opened yet
return ""
end
if vim.g.rplugin.jobs.R ~= 0 then
-- R was launched and nvimrserver started its TCP server
return "R"
end
if vim.g.rplugin.jobs.Server ~= 0 then
-- nvimrserver was started
return "S"
else
-- nvimrserver was not started yet
return "-"
end
end
local rsttcolor = function ()
if not vim.g.rplugin then
return {fg = "#000000"}
end
if vim.g.rplugin.jobs.R ~= 0 then
if vim.g.rplugin.R_pid == 0 then
-- R was launched
return {fg = "#ff8833"}
else
-- R started and informed its PID.
-- This means nvimcom is running.
return {fg = "#3388ff"}
end
end
if vim.g.rplugin.jobs.Server ~= 0 and #vim.g.rplugin.libs_in_nrs > 0 then
-- nvimrserver finished reading omni completion files
return {fg = "#33ff33"}
end
return {fg = "#aaaaaa"}
end
require("lualine").setup({
options = {
section_separators = "",
component_separators = "",
globalstatus = true,
},
sections = {
lualine_y = { {rstatus, color = rsttcolor }},
lualine_z = { "progress", "location" },
},
})
end,
},