Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Neorg plugin lacks norg-meta treesitter parser #2345

Closed
1 task done
Ladas552 opened this issue Sep 30, 2024 · 3 comments
Closed
1 task done

[BUG] Neorg plugin lacks norg-meta treesitter parser #2345

Ladas552 opened this issue Sep 30, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Ladas552
Copy link

Field Description
Plugin neorg
Nixpkgs unstable
Home Manager unstable
  • I have read the FAQ and my bug is not listed there.

Description

There are several issues that might be related to not having norg-meta treesitter parser packaged or included with neorg on Nixvim.

Syntax highlighting for metadata field in norg files doesn't work. Here are screenshots, the one without highlights is norg file opened in nixvim with option configured Neorg, and the other is nixvim with Neorg-overlay

no norg-meta norg-meta from overlay
Niri2024-09-30 15-45-04 Niri2024-09-30 15-58-49

The auto command for norg buffers that executes after writing a buffer trows an error:

Error detected while processing BufWritePost Autocommands for "*.norg":                                   
Error executing Lua callback: ....10.1/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser f
or 'norg_meta' language, see :help treesitter-parsers                                                     
stack traceback:                                                                                          
        [C]: in function 'error'                                                                          
        ....10.1/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'                
        ...d-0.10.1/share/nvim/runtime/lua/vim/treesitter/query.lua:250: in function 'fn'                 
        ...pped-0.10.1/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'ts_parse_query'      
        ...ua/neorg/modules/core/integrations/treesitter/module.lua:808: in function 'get_document_metadat
a'                                                                                                        
        ...ges/start/neorg/lua/neorg/modules/core/tangle/module.lua:226: in function 'tangle'             
        ...ges/start/neorg/lua/neorg/modules/core/tangle/module.lua:466: in function 'on_event'           
        .../myNeovimPackages/start/neorg/lua/neorg/core/modules.lua:781: in function 'broadcast_event'    
        ...s/start/neorg/lua/neorg/modules/core/neorgcmd/module.lua:298: in function <...s/start/neorg/lua
/neorg/modules/core/neorgcmd/module.lua:205>    

And it seems that it also breaks the core.tangle module. Because when core.tangle is enabled as a module in neorg the :Neorg journal today trows an error:
Niri2024-09-30 15-42-56

Minimal, Reproducible Example (MRE)

programs.nixvim = {
      enable = true;
      defaultEditor = true;
      plugins = {
        treesitter = {
          enable = true;
        };
        neorg = {
          enable = true;
          modules = {
            "core.defaults" = {
              __empty = null;
            };
            "core.dirman" = {
              config = {
                workspaces = {
                  general = "~/Norg";
                };
              };
            };
            "core.esupports.metagen" = {
              config = {
                timezone = "implicit-local";
                type = "empty";
                undojoin_updates = "false";
              };
            };
            "core.concealer" = {
              config = {
                __empty = null;
              };
            };
              "core.journal" = {
                config = {
                  workspace = "general";
                  journal_folder = "/./";
                };
              };
              "core.tangle" = {
                config = {
                  report_on_empty = false;
                  tangle_on_write = true;
                };
              };
            };
          };
        };
}
@Ladas552 Ladas552 added the bug Something isn't working label Sep 30, 2024
@khaneliman
Copy link
Contributor

We don't do packaging itself in nixvim, that is handled upstream in nixpkgs. The neorg plugin doesn't include treesitter grammars and the packages treesitter doesn't contain https://github.com/nvim-neorg/tree-sitter-norg-meta. If you'd like to include that grammar you would have to follow the treesitter instructions for installing a custom grammar. https://nix-community.github.io/nixvim/plugins/treesitter/index.html?highlight=tree#installing-your-own-grammars-with-nixvim.

I implemented it myself if you want to see an example:
Grammar implementation: khaneliman/khanelivim@ae3d016
Installing Grammar: khaneliman/khanelivim@8aeb4a4

@teto
Copy link

teto commented Oct 2, 2024

eventually thanks to https://github.com/nvim-neorocks/rocks-treesitter.nvim/ we should be able to have the grammar as dependencies of the plugin when installed via luarocks (with Rocks.nvim), which is then picked up automatically by nixpkgs. Can't say when it will happen though but neorg author is a rocks.nvim maintainer

@Ladas552
Copy link
Author

Ladas552 commented Oct 5, 2024

Tried the khaneliman's method. Works well. Hope that one day it could be bundled by default to make the experience more seamless. Thanks for support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants