nvim-orgmode / orgmode

Orgmode clone written in Lua for Neovim 0.9+.
https://nvim-orgmode.github.io/
MIT License
3.08k stars 136 forks source link

No highlighting in org file #481

Closed pianocomposer321 closed 5 months ago

pianocomposer321 commented 1 year ago

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:

```lua vim.g.mapleader = " " -- vim.g.maplocalleader = "\" vim.keymap.set("n", "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", "") --- Redo vim.keymap.set("n", "U", "") --- Diagnostics vim.keymap.set("n", "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:

```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 ;-).

pianocomposer321 commented 1 year ago

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.

pianocomposer321 commented 1 year ago

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?

kristijanhusak commented 1 year ago

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

kristijanhusak commented 1 year ago

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:

  1. Use event = 'VeryLazy' on treesitter
  2. Add nvim-treesitter as 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.

pianocomposer321 commented 1 year ago

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.

kristijanhusak commented 1 year ago

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.

g0t0wasd commented 1 year ago

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.

jgollenz commented 1 year ago

org file with date entries

@g0t0wasd does the problem disappear, when you remove the date entries?

g0t0wasd commented 1 year ago

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
                    ----------------------------------------------------------------------
jgollenz commented 1 year ago

I assume this is the body of a heading? What syntax highlighting are you expecting beyond the timestamps?

g0t0wasd commented 1 year ago

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

jgollenz commented 1 year ago

Did you try with the minimal_init.lua? I can open it just fine

nvim -u /path/to/minimal_init.lua <your_file>

g0t0wasd commented 1 year ago

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

jgollenz commented 1 year ago

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?

g0t0wasd commented 1 year ago

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

jgollenz commented 1 year ago

Ok, now we're talking. Things are definitely starting to break on my end. I'll keep you posted. Thanks for the file :+1:

mvolkmann commented 1 year ago

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.

kristijanhusak commented 1 year ago

@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.

mvolkmann commented 1 year ago

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.

kristijanhusak commented 1 year ago

Do you have your configuration somewhere public so I can look at it?

mvolkmann commented 1 year ago

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

kristijanhusak commented 1 year ago

@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

mvolkmann commented 1 year ago

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.

kristijanhusak commented 1 year ago

Did you run :TSUpdate to install the parser? Also I can't find a call to orgmode setup, it's maybe somewhere else.

mvolkmann commented 1 year ago

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.

mvolkmann commented 1 year ago

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

kristijanhusak commented 1 year ago

@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.

Aneeqasif commented 1 year ago

@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

image

without that block image

Aneeqasif commented 1 year ago

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

kristijanhusak commented 1 year ago

@Aneeqasif I can't reproduce this, with or without additional_vim_regex_highlighting. Please provide the minimal init configuration.

Aneeqasif commented 1 year ago

@Aneeqasif I can't reproduce this, with or without additional_vim_regex_highlighting. Please provide the minimal init configuration.

as i have mentioned it worked totally fine with minimal.lua , it collapsed with some preconfigured distributions like lazyvim and lunarvim, i am on lunarvim you can try this on lunarvim or lazyvim to see the effect of `additional_vim_regex_highlighting

birdmanmandbir commented 11 months ago

I add this line event = { "LazyFile", "VeryLazy" }, to my lazyvim config, and it seems good for highlighting, can anyone try this and make sure its work? @Aneeqasif @pianocomposer321 this is my org-mode config:

return {
  {
    "nvim-orgmode/orgmode",
    dependencies = {
      {
        "nvim-treesitter/nvim-treesitter",
        lazy = true,
        config = function() end,
      },
    },
    event = { "LazyFile", "VeryLazy" },
    config = function()
      -- Load treesitter grammar for org
      require("orgmode").setup_ts_grammar()

      -- Setup orgmode
      require("orgmode").setup({
        org_agenda_files = "~/org/**/*",
        org_default_notes_file = "~/org/tutorial.org",
      })

      require("nvim-treesitter.configs").setup({
        highlight = {
          enable = true,
          additional_vim_regex_highlighting = { "org" },
        },
        ensure_installed = { "org" }, -- Or run :TSUpdate org
      })
    end,
  },
  {
    "hrsh7th/nvim-cmp",
    config = function()
      require("cmp").setup({
        sources = {
          { name = "orgmode" },
        },
      })
    end,
  },
}
birdmanmandbir commented 11 months ago

It is worth mentioning that LazyFile is an event only in LazyVim. LazyFile is commonly used in many plugin files of LazyVim.

gerazov commented 8 months ago

I recently updated my orgmode install and got no highlighting, specifically when I run :TSHighlightCaptureUnderCursor on any part of the org file I get * No highlight groups foun.

I traced it all back to commit 5baf0c5:

feat(highlights)!: Use treesitter highlights (https://github.com/nvim-orgmode/orgmode/pull/676)

1. Leverage default syntax highlights from treesitter, like @markup.bold, @markup.italic, etc.
2. Require treesitter highlights to be enabled and remove legacy Vim syntax

If I roll back to 82d6d94 syntax highlighting works fine, e.g.

# Syntax
* OrgHeadlineLevel1 -> **OrgHeadlineLevel1**
* OrgKeywordFaceDOING -> **OrgKeywordFaceDOING**

In the rolled back version highlighting works regardless of the lazy loading setting for orgmode (I have it set to ft = { 'org' })

On the taking a lot of CPU to highlight a file - this was happening to me when I was enabling the additinoal regex highlighting - so I was not using it. And I see it's not in the current suggested config anymore.

Hope this helps :+1:

kristijanhusak commented 8 months ago

I added short snippet in the notice about changing these, in case someone wants to use old highlights: https://github.com/nvim-orgmode/orgmode/issues/217#issuecomment-1955096757

gerazov commented 8 months ago

Ok thanks will do :+1:

But shouldn't :TSHighlightCaptureUnderCursor output some of the new groups? I get * No highlight groups found for all parts of the file.

kristijanhusak commented 8 months ago

@gerazov do you get anything if you do :Inspect? Ts capture plugin might be outdated.

Edit: https://github.com/nvim-treesitter/playground?tab=readme-ov-file#deprecation-notice

Aneeqasif commented 8 months ago

i am sad to say but due bugs in this package and the sane philosophy behind orgmode. I have joined hands with emacs forces and completely left neovim behind. Please dont curse on me.

gerazov commented 8 months ago

@gerazov do you get anything if you do :Inspect? Ts capture plugin might be outdated.

Edit: https://github.com/nvim-treesitter/playground?tab=readme-ov-file#deprecation-notice

:Inspect also doesn't return anything:

image

gerazov commented 8 months ago

i am sad to say but due bugs in this package and the sane philosophy behind orgmode. I have joined hands with emacs forces and completely left neovim behind. Please dont curse on me.

I've been using this plugin for years now and I can atest to it being really robust. There have not been any major hickups in my experience so far ..

kristijanhusak commented 8 months ago

@gerazov do you get anything if you do :Inspect? Ts capture plugin might be outdated. Edit: nvim-treesitter/playground#deprecation-notice

:Inspect also doesn't return anything:

image

That's odd. Can you try running minimal_init.lua (nvim -u minimal_init.lua) and see if it works with it? If not, please open up a separate issue with details about your system, Neovim version, etc. so I can look into it.

gerazov commented 8 months ago

Tried and it broke my whole config :sweat_smile: I barely rolled back to my config. There was some easy way to change configs enivornment variable or something ..

kristijanhusak commented 8 months ago

Minimal init should not have any impact on your config. It creates and loads everything from the tmp folder. Unless you copy pasted the content into your own init.lua, which I hope you didn't 😄 .

You need to run minimal init like this:

  1. Copy content of https://github.com/nvim-orgmode/orgmode/blob/master/scripts/minimal_init.lua into a file named minimal_init.lua in your filesystem somewhere
  2. From terminal, go to that folder and do nvim -u minimal_init.lua
  3. Wait for it to set up, and load some org file
gerazov commented 8 months ago

Ahaha - that's exacly what I did - and then all hell broke loose :sweat_smile:

It's good to have this info on using the minimal init :+1:

Ok, so now Inspect does output something legit. There is no coloring nonetheless, even after setting :syntax enable

This is the output when the cursor is on CLOCK

image

kristijanhusak commented 8 months ago

@gerazov I pushed a fix on master. I missed that they changed the default treesitter highlight names between the v0.9 and v0.10.

There is no coloring nonetheless, even after setting :syntax enable

:syntax enable does not have any effect, since all highlights are handled by treesitter.

Please give it a try once more. You can re-use the same minimal_init.lua, just run :Lazy sync to get the latest version.

gerazov commented 8 months ago

It's the same - no coloring.

kristijanhusak commented 8 months ago

Ok, please open up a separate issue and provide some details about your system, neovim version etc, and all the steps you take to get to this point, so I can check.

lyndhurst commented 8 months ago

I am not sure this is of any interest to you, but I had the same problem on a first time install. I am using a LunarVim distribution, and I could not get any coloring.

I tried all the suggestions I found here, and the only one that fixed the issue was commenting out event = 'VeryLazy'. Before that, I only had agenda mappings and functionalities, and no highlight groups.

On the other hand, I also tried intalling the plugin on an NvChad installation, and there, nothing helps even though all functionalities are working and the highlght groups are present.

I am not a neovim power user, so I am not providing very useful info I guess, but if I can provide some logs or anything like that, just ask, I will gladly help out.

kristijanhusak commented 8 months ago

Thanks for the info @lyndhurst, this is helpful information. I'll give it a try with LunarVim and NvChad and see if I can make installation instructions clearer.

lyndhurst commented 8 months ago

I am glad if it could help a little . I have settled for event = "BufRead" on lunarvim, and everything is working fine so far.

Not sure how it impacts performance compared to 'VeryLazy', I have to read about that when I get the time, but I thought that would at least be easier on startup than nothing.