No highlighting in org file
Describe the bug
Just what the title says - when I open a .org file, there is no syntax highlighting whatsoever. Highlighting works for all other filetypes for which I have a parser installed, and, strangely enough, other treesitter functions like folding, incremental selection, and the treesitter playground work...but I still have no highlighting at all in org files.
Steps to reproduce
Literally just open an org file. Same results with nvim file.org from the shell and :e file.org from within neovim, or using telescope, etc.
Expected behavior
I get syntax highlighting for org files.
Emacs functionality
I'm not using emacs, but obviously this works lol.
Minimal init.lua
I'm using lazy.nvim. Here's my current config (pretty barebones right now because I stripped it down to try to diagnose the problem to no avail):
init.lua:
require("mappings")
require("options")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins", {
defaults = { lazy = true },
})
lua/plugins/treesitter.lua:
return {
{
"nvim-treesitter/nvim-treesitter",
lazy = false,
config = function()
require'nvim-treesitter.configs'.setup {
auto_install = true,
ensure_installed = {
"lua",
"norg",
"org",
"rust",
"toml",
},
highlight = {
enable = true
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<A-o>",
node_incremental = "<A-o>",
node_decremental = "<A-i>",
}
},
playground = {
enable = true,
disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = false, -- Whether the query persists across vim sessions
keybindings = {
toggle_query_editor = 'o',
toggle_hl_groups = 'i',
toggle_injected_languages = 't',
toggle_anonymous_nodes = 'a',
toggle_language_display = 'I',
focus_language = 'f',
unfocus_language = 'F',
update = 'R',
goto_node = '<cr>',
show_help = '?',
},
}
}
end,
run = ":TSUpdate",
},
{
"nvim-treesitter/playground",
-- event = "BufReadPre",
lazy = false,
dependencies = "nvim-treesitter/nvim-treesitter",
},
}
lua/plugins/orgmode.lua:
return {
{
"nvim-orgmode/orgmode",
-- ft = "org",
lazy = false,
config = function()
require("orgmode").setup_ts_grammar()
require("orgmode").setup {
org_agenda_files = {"~/Documents/notes/**/*"},
org_default_notes_file = "~/Documents/notes/refile.org",
}
end
},
}
lua/plugins/onedark.lua:
return {
"olimorris/onedarkpro.nvim",
lazy = false,
priority = 1000,
config = function()
vim.cmd.colorscheme("onedark")
end
}
These files should be irrelevent because they're just mappings and options (hence their names :-P), but here they are anyway:
mappings.lua:
vim.g.mapleader = " "
-- vim.g.maplocalleader = "\"
vim.keymap.set("n", "<LEADER>w", "<C-W>")
-- Mappings that I lied from helix
--- Movement
vim.keymap.set("n", "gl", "$")
vim.keymap.set("v", "gl", "$")
vim.keymap.set("n", "gh", "0")
vim.keymap.set("v", "gh", "0")
vim.keymap.set("n", "gs", "^")
vim.keymap.set("v", "gs", "^")
vim.keymap.set("n", "ge", "G")
vim.keymap.set("v", "ge", "G")
--- Alternate file
vim.keymap.set("n", "ga", "<C-6>")
--- Redo
vim.keymap.set("n", "U", "<C-R>")
--- Diagnostics
vim.keymap.set("n", "<LEADER>d", function() vim.diagnostic.open_float({scope = "cursor"}) end)
vim.keymap.set("n", "]g", vim.diagnostic.goto_next)
vim.keymap.set("n", "[g", vim.diagnostic.goto_prev)
options.lua:
vim.opt.splitright = true
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.expandtab = true
vim.opt.scrolloff = 5
vim.opt.number = true
vim.opt.signcolumn = "yes"
vim.opt.laststatus = 3
vim.opt.wrap = false
vim.opt.completeopt = { "menu", "menuone", "noselect" }
vim.opt.pumheight = 6
vim.opt.ignorecase = true
vim.opt.smartcase = true
Screenshots and recordings
No response
OS / Distro
Debian 11
Neovim version/commit
0.8.2
Additional context
As mentioned above, I'm using lazy.nvim, not packer. Not sure if that's relevent, but there you go ;-).
Update: I think this may be a lazy.nvim issue, because I do get highlighting when I use you're minimal_init.lua file. I am opening an issue at lazy.nvim and will close this if someone has a solution there.
Ok, never mind, I think the problem was that I didn't have additional_vim_regex_highlighting = { 'org' } set. Though I'm not sure why this should be the source of the issue...from the readme.md it seems like it should only be necessary "for spellcheck, some LaTex highlights and code block highlights that do not have ts grammar"...but removing it from the minimal config disables syntax highlighting for me too. Is this expected?
I'm also using lazy.nvim without any issues, so it might be some configuration issue. I do have that additional vim regex highlights. I'll check how it behaves without it
I managed to reproduce it. It seems it's caused by some bad order of loading the plugins. I'm using event = 'VeryLazy' for treesitter and it works fine. Doing lazy = false on treesitter causes the issue for me.
I think there are 2 solutions to this:
- Use
event = 'VeryLazy'on treesitter - Add
nvim-treesitteras dependency on orgmode:
{
'nvim-orgmode/orgmode',
dependencies = {
'nvim-treesitter/nvim-treesitter'
},
config = function()
require('orgmode').setup()
end
}
I would suggest to go with first solution because I know for sure it works. Second one can bug sometimes if you open up Telescope too quickly.
Hmm...for me, lazy = false doesn't make a difference, at least not the few times I've tested it with that so far. The only setting that changes anything for me is the additional_vim_regex_highlighting = { "org" }, one.
I have noticed however that lazily loading the orgmode plugin (i.e. ft = "org") often causes the syntax highlighting to not work properly, particularly when opening files with telesecope.
ft = 'org' does not work because we have filetype autocmds in here which are not triggered since they are attached too late. You could maybe try using ft = 'org' and do vim.cmd('doautocmd FileType org') in the lazy config for orgmode. Didn't tested it though.
Not sure if this is related, but might be a hint.
Though highlighting works for most of my files. It takes too much time in highlighting specific org file with date entries, like this:
<2022-09-01>
Opening not that big file (~300 lines) loads system heavily and in the end I got
'redrawtime' exceeded, syntax highlighting disabled message.
org file with date entries
@g0t0wasd does the problem disappear, when you remove the date entries?
No, I did additional testing and it seems, like it is not related to the date entries. This is example of a file which I have. It works quite slow, but manages to eventually get highlighted. Similar but bigger file breaks highlighting completely
<2021-11-11> ORC | Poor fundamentals:
P/E = -81.83x
P/B = 1.09x
EPS (TTM) = -0.0380
PRICE = 4.91
----------------------------------------------------------------------
Valuation (0) ORC is poor value based on its book value relative to its share price (1.09x), compared to the US REIT - Mortgage industry average (0.91x)
Financials (0) ORC's Earnings (EBIT) of -$3.72M are insufficient to safely cover interest payments on company debt ($5.21B)
Financials (0) ORC's profit margin has decreased (-66.2%) in the last year from (28.9%) to (-37.3%)
Financials (1) ORC's debt relative to shareholder equity (7.46) has decreased or remained constant compared to 5 years ago (8.06)
Financials (0) ORC's debt to equity ratio (7.46) is considered high
Financials (0) ORC's operating cash flow ($85.68M) may not be sufficient to safely service the company's debt ($5.21B)
Performance (0) ORC's revenue has grown slower (-23.84% per year) than the US REIT - Mortgage industry average (23.09%)
Performance (0) ORC's revenue has grown slower (-23.84% per year) than the US market average (20.71%)
Performance (0) ORC's revenue growth is slowing down - its growth over the last year (-32.39%) is below its 5-year compound annual rate (-23.84%)
Performance (0) ORC's Return on Equity (-0.7%) shows a company that is not efficient at transforming shareholder equity into returns
Performance (0) ORC is generating lower Return on Assets (-0.1%) than the US REIT - Mortgage industry average (2.34%)
Dividend (0) ORC's dividend has dropped by more than 10% five time(s) in the last 9 years
Dividend (0) ORC dividends have decreased over the last 9 years
Dividend (1) ORC dividends (15.89%) are in the top 75% of all US listed companies
Dividend (1) ORC dividends (15.89%) are in the top 25% of all US listed companies
Dividend (0) ORC cannot cover its dividend payouts because ORC has negative earnings
Ownership (1) ORC insiders have bought more ORC shares than they have sold in the last year
----------------------------------------------------------------------
<2021-11-11> PFE | Good news on new vaccination
P/E = 20.77x
P/B = 3.78x
EPS (TTM) = 3.50
PRICE = 49.9
----------------------------------------------------------------------
Valuation (1) PFE ($49.02) is trading below its intrinsic value of $128.18, according to Benjamin Graham's Formula from Chapter 11 of "The Intelligent Investor"
Valuation (1) PFE is good value based on its earnings relative to its share price (20.77x), compared to the US market average 36.6x)
Valuation (1) PFE is good value based on its earnings relative to its share price (20.77x), compared to the US Drug Manufacturers - General industry average (22.85x)
Valuation (1) PFE is good value based on its book value relative to its share price (3.78x), compared to the US Drug Manufacturers - General industry average (5.11x)
Valuation (0) PFE is poor value relative to its rate of earnings growth, measured by PEG ratio (1.84x)
Financials (1) PFE's Earnings (EBIT) of $14.56B can safely cover interest payments on company debt ($39.24B)
Financials (0) PFE's profit margin has decreased (-15.2%) in the last year from (40.8%) to (25.6%)
Financials (1) PFE's short-term assets ($48.81B) exceed its short-term liabilities ($35.66B)
Financials (0) PFE's long-term liabilities ($63.94B) exceed its short-term assets ($48.81B)
Financials (1) PFE's debt relative to shareholder equity (1.42) has decreased or remained constant compared to 5 years ago (1.71)
Financials (0) PFE's debt to equity ratio (1.42) is considered high
Financials (1) PFE's operating cash flow ($23.55B) is sufficient to service the company's debt ($39.24B)
Performance (1) PFE's earnings have grown faster (15.26% per year) than the US Drug Manufacturers - General industry average (12.28%)
Performance (0) PFE's earnings have grown slower (15.26% per year) than the US market average (36.15%)
Performance (0) PFE's earnings growth is slowing down - its growth over the last year (-7.45%) is below its 5-year compound annual rate (15.26%)
Performance (0) PFE's revenue has grown slower (-0.25% per year) than the US Drug Manufacturers - General industry average (5.64%)
Performance (0) PFE's revenue has grown slower (-0.25% per year) than the US market average (20.71%)
Performance (1) PFE's revenue growth is accelerating - its growth over the last year (48.65%) is above its 5-year compound annual rate (-0.25%)
Performance (1) PFE's has demonstrated consistent long-term earnings growth over the past 10 years (118.52%)
Performance (0) PFE's Return on Equity (19.8%) shows a company that is not efficient at transforming shareholder equity into returns
Performance (1) PFE is generating higher Return on Assets (8%) than the US Drug Manufacturers - General industry average (7.83%)
Performance (1) PFE has gotten more efficient at generating Return on Capital (10.84%) compared to 3 years ago (9.89%)
Dividend (1) PFE's dividend has not dropped by more than 10% at any point in the last 10 years
Dividend (1) PFE dividends have increased over the last 10 years
Dividend (1) PFE dividends (3.18%) are in the top 75% of all US listed companies
Dividend (0) PFE dividends (3.18%) are not in the top 25% of all US listed companies
Dividend (1) PFE earnings are sufficient to cover PFE's dividend payouts
Ownership (1) PFE insiders have bought more PFE shares than they have sold in the last year
----------------------------------------------------------------------
<2021-11-11> JNJ | Medical company in the new part of pandemic, dividend king
P/E = 24.23x
P/B = 6.1x
EPS (TTM) = 6.69
PRICE = 163.00
----------------------------------------------------------------------
Valuation (1) JNJ ($164.27) is trading below its intrinsic value of $498.85, according to Benjamin Graham's Formula from Chapter 11 of "The Intelligent Investor"
Valuation (1) JNJ is good value based on its earnings relative to its share price (24.23x), compared to the US market average 36.6x)
Valuation (0) JNJ is poor value based on its earnings relative to its share price (24.23x), compared to the US Drug Manufacturers - General industry average (22.85x)
Valuation (0) JNJ is poor value based on its book value relative to its share price (6.1x), compared to the US Drug Manufacturers - General industry average (5.11x)
Valuation (0) JNJ is poor value relative to its rate of earnings growth, measured by PEG ratio (1.37x)
Financials (1) JNJ's Earnings (EBIT) of $19.80B can safely cover interest payments on company debt ($33.93B)
Financials (0) JNJ's profit margin has decreased (-1.4%) in the last year from (21%) to (19.6%)
Financials (1) JNJ's short-term assets ($59.89B) exceed its short-term liabilities ($44.56B)
Financials (0) JNJ's long-term liabilities ($64.40B) exceed its short-term assets ($59.89B)
Financials (0) JNJ's debt has increased relative to shareholder equity (1.55), over the past 5 years ago (0.93)
Financials (0) JNJ's debt to equity ratio (1.55) is considered high
Financials (1) JNJ's operating cash flow ($26.02B) is sufficient to service the company's debt ($33.93B)
Performance (0) JNJ's earnings have grown slower (3.14% per year) than the US Drug Manufacturers - General industry average (12.28%)
Performance (0) JNJ's earnings have grown slower (3.14% per year) than the US market average (36.15%)
Performance (1) JNJ's earnings growth is accelerating - its growth over the last year (4.95%) is above its 5-year compound annual rate (3.14%)
Performance (0) JNJ's revenue has grown slower (5.02% per year) than the US Drug Manufacturers - General industry average (5.64%)
Performance (0) JNJ's revenue has grown slower (5.02% per year) than the US market average (20.71%)
Performance (1) JNJ's revenue growth is accelerating - its growth over the last year (13.1%) is above its 5-year compound annual rate (5.02%)
Performance (0) JNJ's has not demonstrated consistent long-term earnings growth over the past 10 years (62.59%)
Performance (1) JNJ's Return on Equity (26.6%) shows a company that is highly efficient at transforming shareholder equity into returns
Performance (1) JNJ is generating higher Return on Assets (10.2%) than the US Drug Manufacturers - General industry average (7.83%)
Performance (1) JNJ has gotten more efficient at generating Return on Capital (14.7%) compared to 3 years ago (14.4%)
Dividend (1) JNJ dividends have increased over the last 10 years
Dividend (1) JNJ dividends (2.52%) are in the top 75% of all US listed companies
Dividend (1) JNJ dividends (2.52%) are not in the top 25% of all US listed companies
Dividend (1) JNJ earnings are sufficient to cover JNJ's dividend payouts
----------------------------------------------------------------------
I assume this is the body of a heading? What syntax highlighting are you expecting beyond the timestamps?
I have no heading in this file at all. As for highlighting I need only timestamps. The problems is that this file hangs nvim, while opens properly in Emacs
Did you try with the minimal_init.lua? I can open it just fine
nvim -u /path/to/minimal_init.lua <your_file>
Tried with minimal_init.lua - gives same result:
Only some timestamps are highlighted. And I get 'redrawtime' exceeded, syntax highlighting disabled message.
Also also, the provided example is just part of my real file. I have like tens (maybe hundred) of similar entries
What nvim version are you using? Did you try the minimal_init.lua with the short file you provided in the earlier comment or with the larger one you mentioned? Perhaps you could share it in a pastebin or a gist?
Also: what operating system are you on?
Nvim 0.8.0 Tried with the long file. It's here: https://pastebin.com/7FY9W19X Linux laptop 5.4.0-139-generic #156-Ubuntu SMP Fri Jan 20 17:27:18 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Ok, now we're talking. Things are definitely starting to break on my end. I'll keep you posted. Thanks for the file :+1:
Any progress on this? I'm using AstroNvim which uses Lazy to manage plugins. I haven't landed on a way to successfully configure nvim-orgmode. The error I get is "no parser for 'org' language". I'd love to see a description of a configuration that works from someone else using Lazy.
@mvolkmann I'm actually using Lazy as a package manager.
Here's my orgmode configuration: https://github.com/kristijanhusak/neovim-config/blob/master/nvim/lua/partials/plugins/orgmode.lua And treesitter: https://github.com/kristijanhusak/neovim-config/blob/master/nvim/lua/partials/plugins/treesitter.lua
It is a bit tricky to set it up with Lazy, but this works for me. Further investigation is needed.
Thanks! I copied your configuration. When I start nvim I get this:
Error detected while processing User Autocommands for "AstroMasonLspSetup"..FileType Autocommands for "org": Error executing lua callback: ...0.9.0/share/nvim/runtime/lua/vim/treesitter/language.lua:94: no parser for 'org' language
I must need to install something additional.
Do you have your configuration somewhere public so I can look at it?
Yes. It is at https://github.com/mvolkmann/MyUnixEnv. See the .config directory there. Thanks so much for looking at this!
Part of the code in tree-sitter.lua is commented out for now. But I tried with that uncommented.
See .config/nvim/lua/user/plugins/tree-sitter.lua
@mvolkmann You are missing this part:
require('orgmode').setup_ts_grammar()
I have it defined here https://github.com/kristijanhusak/neovim-config/blob/master/nvim/lua/partials/plugins/treesitter.lua#L13
That is on line 28 in my tree-sitter.lua file. The block it is inside is currently commented out, but I get the error I described when I uncomment that block.
On Fri, May 5, 2023 at 10:08 AM Kristijan Husak @.***> wrote:
@mvolkmann https://github.com/mvolkmann You are missing this part:
require('orgmode').setup_ts_grammar()
I have it defined here https://github.com/kristijanhusak/neovim-config/blob/master/nvim/lua/partials/plugins/treesitter.lua#L13
— Reply to this email directly, view it on GitHub https://github.com/nvim-orgmode/orgmode/issues/481#issuecomment-1536401875, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATLUAFC6DQJYMAE33IDWDXEUJXLANCNFSM6AAAAAATRGX6P4 . You are receiving this because you were mentioned.Message ID: @.***>
-- R. Mark Volkmann Object Computing, Inc.
Did you run :TSUpdate to install the parser? Also I can't find a call to orgmode setup, it's maybe somewhere else.
I just now ran :TSUpdate, uncommented that block of code in my
tree-sitter.lua file, and restarted nvim. That certainly changed things!
Now when I open a .org file I get the following error which doesn't
include any of my files in the stack trace. Do you have any ideas about
what could cause this?
Error detected while processing User Autocommands for "AstroMasonLspSetup"..FileType Autocommands for "*": Error executing lua callback: vim/keymap.lua:0: E31: No such mapping stack traceback: [C]: in function 'nvim_buf_del_keymap' vim/keymap.lua: in function 'del' ...treesitter/lua/nvim-treesitter/incremental_selection.lua:168: in function 'detach' ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:522: in function 'detach_module' ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:531: in function 'reattach_module' ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:132> [C]: in function 'nvim_exec_autocmds' ...volkmannm/.config/nvim/lua/plugins/configs/lspconfig.lua:28: in function <...volkmannm/.config/nvim/lua/plugins/configs/lspconfig.lua:26> [C]: in function 'nvim_exec_autocmds' /Users/volkmannm/.config/nvim/lua/astronvim/utils/init.lua:120: in function </Users/volkmannm/.config/nvim/lua/astronvim/utils/init.lua:120>
On Fri, May 5, 2023 at 10:17 AM Kristijan Husak @.***> wrote:
Did you run :TSUpdate to install the parser? Also I can't find a call to orgmode setup, it's maybe somewhere else.
— Reply to this email directly, view it on GitHub https://github.com/nvim-orgmode/orgmode/issues/481#issuecomment-1536412854, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATLUBLVLUF64D5MQWN4CDXEUKXJANCNFSM6AAAAAATRGX6P4 . You are receiving this because you were mentioned.Message ID: @.***>
-- R. Mark Volkmann Object Computing, Inc.
For now I have gotten past the error by commenting out the following line in my .config/nvim/lua/astronvim/utils/init.lua file. I don't know what issues that may cause, but orgmode is working now.
function M.event(event) vim.schedule(function() -- vim.api.nvim_exec_autocmds("User", { pattern = "Astro" .. event }) end) end
@mvolkmann you have some treesitter configs which you didn't install plugin for, maybe textobjects or refactor. Put only necessary things in the treesitter config.
@mvolkmann you have some treesitter configs which you didn't install plugin for, maybe textobjects or refactor. Put only necessary things in the treesitter config.
hello sir i facing a intersting kinda behavior relating to this i am using lunarvim with
{'nvim-orgmode/orgmode',
lazy=false,
dependencies = {
'nvim-treesitter/nvim-treesitter'
},
config = function()
require('orgmode').setup_ts_grammar()
require('orgmode').setup{
org_agenda_files = {'~/org/*'},
org_default_notes_file = '~/org/refile.org',
}
end
},
highlighting only work when org document has a #+BEGIN_SRC and #+END_SRC
when i open the file with
* This is an example headline
* Another headline
Nesting headlines is as easy as adding another start
** Nested headline
#+BEGIN_SRC sh
# do some things
echo "stuff"
echo "more stuff"
echo <<hi>>
#+END_SRC
#+RESULTS:
To enter and edit a block of text, use =C-c C-'=
it do proper syntax highlighting but when i open
* This is an example headline
* Another headline
Nesting headlines is as easy as adding another start
** Nested headline
#+RESULTS:
To enter and edit a block of text, use =C-c C-'=
there is not sytax highlighting execpt the == block
the highlight is working finw with minimal init.lua
demo
without that block
so it turn out highlight.additional_vim_regex_highlighting was the culprit most many people donot have any thing in this setting
so highlight is not working
if u set it to
additional_vim_regex_highlighting = { 'org' }, it works please add some documentation for this as many popular neovim distributions like lunarvim , lazy vim and ig astro also will break this plugin just due to this thingy . thanks for developing this amazing piece of software stay blessed
@Aneeqasif I can't reproduce this, with or without additional_vim_regex_highlighting. Please provide the minimal init configuration.