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

Neorg Kickstart Config Error when Opening a Neorg File #1501

Open
2 tasks done
mgwinsor opened this issue Jul 5, 2024 · 6 comments
Open
2 tasks done

Neorg Kickstart Config Error when Opening a Neorg File #1501

mgwinsor opened this issue Jul 5, 2024 · 6 comments
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@mgwinsor
Copy link

mgwinsor commented Jul 5, 2024

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478

Neorg setup

Using the unmodified neorg config from the norg-kickstart config

{
  "nvim-neorg/neorg",
  dependencies = { "luarocks.nvim" },
  version = "*",
  config = function()
    require("neorg").setup {
      load = {
        ["core.defaults"] = {},
        ["core.concealer"] = {},
        ["core.dirman"] = {
          config = {
            workspaces = {
              notes = "~/notes",
            },
            default_workspace = "notes",
          },
        },
      },
    }

    vim.wo.foldlevel = 99
    vim.wo.conceallevel = 2
  end,
}

Actual behavior

When opening a .norg file after installing the packaged defined in the kickstarter init.lua file, I get the following output (middle section omitted for brevity):

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:35: Error executing lua: ...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:36: BufReadPost Autocomman
ds for "*"..FileType Autocommands for "norg": Vim(append):Error executing lua callback: ....10.0/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'norg' language, see :help treesit
ter-parsers
stack traceback:
        [C]: in function 'error'
        ....10.0/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
        ...m/0.10.0/share/nvim/runtime/lua/vim/treesitter/query.lua:250: in function 'fn'
        ...ovim/0.10.0/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'ts_parse_query'
        ...ua/neorg/modules/core/integrations/treesitter/module.lua:827: in function 'execute_query'
        ...eorg/lua/neorg/modules/core/todo-introspector/module.lua:50: in function 'attach_introspector'
        ...eorg/lua/neorg/modules/core/todo-introspector/module.lua:37: in function <...eorg/lua/neorg/modules/core/todo-introspector/module.lua:29>
        [C]: in function 'nvim_cmd'
        ...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:36: in function <...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        ...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:35: in function <...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_cmd'
        ...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:36: in function <...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        ...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:35: in function <...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_buf_call'
        ...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:35: in function <...rew/Cellar/neovim/0.10.0/share/nvim/runtime/filetype.lua:10>
Error detected while processing BufReadPost Autocommands for "*.norg":
Error executing lua callback: ....10.0/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'norg' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        ....10.0/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
        ...0/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
        .../neovim/0.10.0/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
        .../neovim/0.10.0/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
        ...m/lazy/neorg/lua/neorg/modules/core/concealer/module.lua:1322: in function 'on_event'
        .../.local/share/nvim/lazy/neorg/lua/neorg/core/modules.lua:796: in function 'broadcast_event'
        ...azy/neorg/lua/neorg/modules/core/autocommands/module.lua:51: in function '_neorg_module_autocommand_triggered'
        ...azy/neorg/lua/neorg/modules/core/autocommands/module.lua:84: in function <...azy/neorg/lua/neorg/modules/core/autocommands/module.lua:83>
Downloading tree-sitter-norg...
Creating temporary directory
Extracting tree-sitter-norg...
Compiling...
src/scanner.cc:176:6: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class TagType : char
     ^
src/scanner.cc:194:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
    for (auto& elem : vec)
         ^
<omission begins>
.
.
.
.
<omission ends>
src/scanner.cc:506:65: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
            else if (lexer->lookahead == '.' && m_TagContext != TagType::IN_VERBATIM_TAG)
                                                                ^
src/scanner.cc:525:32: error: expected expression
            if (check_detached({HEADING1, HEADING2, HEADING3,
                               ^
src/scanner.cc:530:32: error: expected expression
            if (check_detached({QUOTE1, QUOTE2, QUOTE3, QUOTE4, QUOTE5, QUOTE6}, '>'))
                               ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
27 warnings and 20 errors generated.
Error detected while processing BufEnter Autocommands for "*.norg":
Error during compilation
Failed to execute the following command:
{
  cmd = "cc",
  err = "Error during compilation",
  info = "Compiling...",
  opts = {
    args = { "-o", "parser.so", "-I./src", "src/parser.c", "src/scanner.cc", "-Os", "-bundle", "-lstdc++", "-fPIC" },
    cwd = "/Users/michaelwinsor/.local/share/nvim/tree-sitter-norg"
  }
}
Downloading tree-sitter-norg_meta...
Creating temporary directory
Extracting tree-sitter-norg_meta...
Compiling...
Treesitter parser for norg_meta has been installed

After this process finishes, the moment I enter insert mode in the .norg file, I get the following error:

Error executing vim.schedule lua callback: ....10.0/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'norg' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        ....10.0/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
        ...0/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
        .../neovim/0.10.0/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
        .../neovim/0.10.0/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
        ...ua/neorg/modules/core/integrations/treesitter/module.lua:607: in function 'get_document_root'
        ...m/lazy/neorg/lua/neorg/modules/core/concealer/module.lua:1145: in function 'prettify_range'
        ...m/lazy/neorg/lua/neorg/modules/core/concealer/module.lua:1235: in function 'render_window_buffer'
        ...m/lazy/neorg/lua/neorg/modules/core/concealer/module.lua:1242: in function <...m/lazy/neorg/lua/neorg/modules/core/concealer/module.lua:1239>

Expected behavior

The expected behavior was that the .norg file could be opened and modified that file with Neorg functionality, especially since this was kickstarter Neorg config file.

Steps to reproduce

Backup any existing nvim configuration files and downloaded packages:

mv ~/.config/nvim ~/.config/nvim_bk
mv ~/.local/share/nvim ~/.local/share/nvim_bk

Create a new nvim directory and init.lua file:

mkdir ~/.config/nvim
touch ~/.config/nvim/init.lua

Proceed to copy and past the contents of the init.lua file specified in the kickstart config to the newly created init.lua file.

Launch nvim to install the packages:

nvim

Once all packages are installed, create a new .norg file and open it with nvim:

touch ~/note.norg
nvim ~/note.norg

The errors are shown immediately upon opening the file. A further set of errors are shown when entering insert mode.

Potentially conflicting plugins

None. I am using the kickstarter configuration file and have backed up my old configuration and ~/.local/share/nvim directory.

Other information

Using M3 MBP 36GB RAM

Installed luajit with Brew:

LuaJIT 2.1.1716656478 -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
JIT: ON fold cse dce fwd dse narrow loop abc sink fuse

Help

No

Implementation help

No response

@mgwinsor mgwinsor added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label Jul 5, 2024
@benlubas
Copy link
Contributor

benlubas commented Jul 5, 2024

Looks like the parser failing to build on your system b/c it's not using c++11 or newer, while the parser uses a c++11 feature.

Given this part of the error.

src/scanner.cc:176:6: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class TagType : char
     ^

Some people have had success in the past with adding this to their zsh/bashrc export CXXFLAGS="-std=c++11"

@max397574
Copy link
Contributor

or using a different compiler
iirc cc worked for me

@mgwinsor
Copy link
Author

mgwinsor commented Jul 6, 2024

@benlubas indeed you are correct about the C++ version. Strange thing is that this line already specifies to use the proper version:

local cc = "clang++ -std=c++11"

I was able to run this command locally in zsh with a small test file as input and compilation was successful:

clang++ -std=c++11 -o output_file test.cpp

Not sure why it failed when run from the Lua file.

I also tried setting the CXXFLAGS environment variable, but no luck... According to this StackOverflow answer, clang does not automatically check the environment variables. They would still need to be passed into the clang command when it is called.

@max397574 I'm curious how you managed to get it working my using a different compiler. Looks like the line I linked above hard codes clang++ compiler, unless it can be overwritten. C++ compilers are very unfamiliar territory for me, so I'm very likely missing something.

@mgwinsor
Copy link
Author

mgwinsor commented Jul 6, 2024

Solved it. Needed to add export CC="gcc-14" to my .zshrc file. Came across it in "From No Org to Neorg - The Basics | 1" YouTube video. Don't see it on the docs currently though.

If it is there somewhere the issue can be closed. Otherwise, I'll leave this open and find some time to submit a pull request with a minor update to the docs.

@stephenloggedon
Copy link

CC=gcc-14 nvim -c "TSInstall norg" worked for me in the past, but it is no longer working after a fresh install.

@mgwinsor
Copy link
Author

mgwinsor commented Jul 9, 2024

@stephenloggedon I believe you should just set CC=gcc-14 instead of the entire command. Make sure to check your gcc version as well with gcc -dumpversion and change the environment variable accordingly.

edit: found this in the documentation. It seems your command should work... I was setting the environment variable in my .zshrc file instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.
Projects
None yet
Development

No branches or pull requests

4 participants