jmbuhr / otter.nvim

Just ask an otter! 🦦
MIT License
521 stars 11 forks source link

Auto command for otter fails with error #177

Closed refaelsh closed 1 month ago

refaelsh commented 1 month ago

I have something like this in my config:

vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
  pattern = "*.org",
  callback = function()
    require("otter").activate()
  end,
})

I get this error: 2024-09-15_20-15

jmbuhr commented 1 month ago

Is your Treesitter configured correctly?

refaelsh commented 1 month ago

Here is the result of :checkheakt nvim-treesitter:


==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.22.6 (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.17.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: gcc (GCC) 13.3.0
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.6.50",
  sysname = "Linux",
  version = "#1-NixOS SMP PREEMPT_DYNAMIC Sun Sep  8 05:54:49 UTC 2024"
} ~

Parser/Features         H L F I J
  - ada                 ✓ ✓ ✓ . ✓
  - agda                ✓ . ✓ . ✓
  - angular             ✓ ✓ ✓ ✓ ✓
  - apex                ✓ ✓ ✓ . ✓
  - arduino             ✓ ✓ ✓ ✓ ✓
  - asm                 ✓ . . . ✓
  - astro               ✓ ✓ ✓ ✓ ✓
  - authzed             ✓ . . . ✓
  - awk                 ✓ . . . ✓
  - bash                ✓ ✓ ✓ . ✓
  - bass                ✓ ✓ ✓ ✓ ✓
  - beancount           ✓ . ✓ . ✓
  - bibtex              ✓ . ✓ ✓ ✓
  - bicep               ✓ ✓ ✓ ✓ ✓
  - bitbake             ✓ ✓ ✓ ✓ ✓
  - blueprint           ✓ . . . ✓
  - bp                  ✓ ✓ ✓ ✓ ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - c_sharp             ✓ ✓ ✓ . ✓
  - cairo               ✓ ✓ ✓ ✓ ✓
  - capnp               ✓ ✓ ✓ ✓ ✓
  - chatito             ✓ ✓ ✓ ✓ ✓
  - clojure             ✓ ✓ ✓ . ✓
  - cmake               ✓ . ✓ ✓ ✓
  - comment             ✓ . . . .
  - commonlisp          ✓ ✓ ✓ . ✓
  - cooklang            ✓ . . . ✓
  - corn                ✓ ✓ ✓ ✓ ✓
  - cpon                ✓ ✓ ✓ ✓ ✓
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - css                 ✓ . ✓ ✓ ✓
  - csv                 ✓ . . . .
  - cuda                ✓ ✓ ✓ ✓ ✓
  - cue                 ✓ ✓ ✓ ✓ ✓
  - d                   ✓ ✓ ✓ ✓ ✓
  - dart                ✓ ✓ ✓ ✓ ✓
  - devicetree          ✓ ✓ ✓ ✓ ✓
  - dhall               ✓ . ✓ . ✓
  - diff                ✓ . ✓ . ✓
  - disassembly         ✓ . . . ✓
  - djot                ✓ ✓ ✓ ✓ ✓
  - dockerfile          ✓ . . . ✓
  - dot                 ✓ . . ✓ ✓
  - doxygen             ✓ . . ✓ ✓
  - dtd                 ✓ ✓ ✓ . ✓
  - earthfile           ✓ . . . ✓
  - ebnf                ✓ . . . ✓
  - editorconfig        ✓ . ✓ . ✓
  - eds                 ✓ . ✓ . .
  - eex                 ✓ . . . ✓
  - elixir              ✓ ✓ ✓ ✓ ✓
  - elm                 ✓ . ✓ . ✓
  - elsa                ✓ ✓ ✓ ✓ ✓
  - elvish              ✓ . . . ✓
  - embedded_template   ✓ . . . ✓
  - erlang              ✓ . ✓ . ✓
  - facility            ✓ . ✓ ✓ ✓
  - faust               ✓ . . . ✓
  - fennel              ✓ ✓ ✓ . ✓
  - fidl                ✓ . ✓ . ✓
  - firrtl              ✓ ✓ ✓ ✓ ✓
  - fish                ✓ ✓ ✓ ✓ ✓
  - foam                ✓ ✓ ✓ ✓ ✓
  - forth               ✓ ✓ ✓ ✓ ✓
  - fortran             ✓ . ✓ ✓ ✓
  - fsh                 ✓ . . . ✓
  - func                ✓ . . . ✓
  - fusion              ✓ ✓ ✓ ✓ ✓
  - gap                 ✓ ✓ ✓ . ✓
  - gaptst              ✓ . ✓ . ✓
  - gdscript            ✓ ✓ ✓ ✓ ✓
  - gdshader            ✓ . . . ✓
  - git_config          ✓ . ✓ . ✓
  - git_rebase          ✓ . . . ✓
  - gitattributes       ✓ ✓ . . ✓
  - gitcommit           ✓ . . . ✓
  - gitignore           ✓ . . . ✓
  - gleam               ✓ ✓ ✓ ✓ ✓
  - glimmer             ✓ ✓ ✓ ✓ ✓
  - glimmer_javascript  ✓ ✓ . ✓ ✓
  - glimmer_typescript  ✓ . . ✓ ✓
  - glsl                ✓ ✓ ✓ ✓ ✓
  - gn                  ✓ ✓ ✓ ✓ ✓
  - gnuplot             ✓ . . . ✓
  - go                  ✓ ✓ ✓ ✓ ✓
  - goctl               ✓ . ✓ ✓ ✓
  - godot_resource      ✓ ✓ ✓ . ✓
  - gomod               ✓ . . . ✓
  - gosum               ✓ . . . .
  - gotmpl              ✓ ✓ ✓ . ✓
  - gowork              ✓ . . . ✓
  - gpg                 ✓ . . . ✓
  - graphql             ✓ . . ✓ ✓
  - groovy              ✓ ✓ ✓ ✓ ✓
  - gstlaunch           ✓ . . . .
  - hack                ✓ . . . ✓
  - hare                ✓ ✓ ✓ ✓ ✓
  - haskell             ✓ ✓ ✓ . ✓
  - haskell_persistent  ✓ . ✓ . .
  - hcl                 ✓ . ✓ ✓ ✓
  - heex                ✓ ✓ ✓ ✓ ✓
  - helm                ✓ ✓ ✓ . ✓
  - hjson               ✓ ✓ ✓ ✓ ✓
  - hlsl                ✓ ✓ ✓ ✓ ✓
  - hlsplaylist         ✓ . . . ✓
  - hocon               ✓ . ✓ . ✓
  - hoon                ✓ ✓ ✓ . ✓
  - html                ✓ ✓ ✓ ✓ ✓
  - htmldjango          ✓ . ✓ ✓ ✓
  - http                ✓ . . . ✓
  - hurl                ✓ . ✓ ✓ ✓
  - hyprlang            ✓ . ✓ ✓ ✓
  - idl                 ✓ . . ✓ ✓
  - ini                 ✓ . ✓ . ✓
  - inko                ✓ ✓ ✓ ✓ ✓
  - ispc                ✓ ✓ ✓ ✓ ✓
  - janet_simple        ✓ ✓ ✓ . ✓
  - java                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - jq                  ✓ ✓ . . ✓
  - jsdoc               ✓ . . . .
  - json                ✓ ✓ ✓ ✓ .
  - json5               ✓ . . . ✓
  - jsonc               ✓ ✓ ✓ ✓ ✓
  - jsonnet             ✓ ✓ ✓ . ✓
  - julia               ✓ ✓ ✓ ✓ ✓
  - just                ✓ ✓ ✓ ✓ ✓
  - kconfig             ✓ ✓ ✓ ✓ ✓
  - kdl                 ✓ ✓ ✓ ✓ ✓
  - kotlin              ✓ ✓ ✓ . ✓
  - koto                ✓ ✓ ✓ . ✓
  - kusto               ✓ . . . ✓
  - lalrpop             ✓ ✓ ✓ . ✓
  - latex               ✓ . ✓ . ✓
  - ledger              ✓ . ✓ ✓ ✓
  - leo                 ✓ . . ✓ ✓
  - linkerscript        ✓ ✓ ✓ ✓ ✓
  - liquid              ✓ . . . ✓
  - liquidsoap          ✓ ✓ ✓ ✓ ✓
  - llvm                ✓ . . . ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - luadoc              ✓ . . . .
  - luap                ✓ . . . .
  - luau                ✓ ✓ ✓ ✓ ✓
  - m68k                ✓ ✓ ✓ . ✓
  - make                ✓ . ✓ . ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - matlab              ✓ ✓ ✓ ✓ ✓
  - menhir              ✓ . . . ✓
  - mermaid             ✓ . ✓ ✓ ✓
  - meson               ✓ . ✓ ✓ ✓
  - mlir                ✓ ✓ . . ✓
  - muttrc              ✓ . . . ✓
  - nasm                ✓ . . . ✓
  - nginx               ✓ . ✓ . ✓
  - nickel              ✓ . . ✓ ✓
  - nim                 ✓ ✓ ✓ . ✓
  - nim_format_string   ✓ . . . ✓
  - ninja               ✓ . ✓ ✓ ✓
  - nix                 ✓ ✓ ✓ ✓ ✓
  - norg                . . . . .
  - nqc                 ✓ ✓ ✓ ✓ ✓
  - objc                ✓ ✓ ✓ ✓ ✓
  - objdump             ✓ . . . ✓
  - ocaml               ✓ ✓ ✓ ✓ ✓
  - ocaml_interface     ✓ ✓ ✓ ✓ ✓
  - ocamllex            ✓ . . . ✓
  - odin                ✓ ✓ ✓ ✓ ✓
  - org                 ✓ . ✓ . ✓
  - pascal              ✓ ✓ ✓ ✓ ✓
  - passwd              ✓ . . . .
  - pem                 ✓ . ✓ . ✓
  - perl                ✓ . ✓ . ✓
  - php                 ✓ ✓ ✓ ✓ ✓
  - php_only            ✓ ✓ ✓ ✓ ✓
  - phpdoc              ✓ . . . .
  - pioasm              ✓ . . . ✓
  - po                  ✓ . ✓ . ✓
  - pod                 ✓ . . . .
  - poe_filter          ✓ . ✓ ✓ ✓
  - pony                ✓ ✓ ✓ ✓ ✓
  - powershell          ✓ ✓ ✓ ✓ ✓
  - printf              ✓ . . . .
  - prisma              ✓ . ✓ . ✓
  - problog             ✓ . ✓ ✓ ✓
  - prolog              ✓ . ✓ ✓ ✓
  - promql              ✓ . . . ✓
  - properties          ✓ ✓ . . ✓
  - proto               ✓ . ✓ ✓ ✓
  - prql                ✓ . . . ✓
  - psv                 ✓ . . . .
  - pug                 ✓ . . . ✓
  - puppet              ✓ ✓ ✓ ✓ ✓
  - purescript          ✓ ✓ . . ✓
  - pymanifest          ✓ . . . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - ql                  ✓ ✓ ✓ ✓ ✓
  - qmldir              ✓ . . . ✓
  - qmljs               ✓ . ✓ . ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - r                   ✓ ✓ . ✓ ✓
  - racket              ✓ . ✓ . ✓
  - ralph               ✓ . . . ✓
  - rasi                ✓ ✓ ✓ ✓ ✓
  - rbs                 ✓ . ✓ ✓ ✓
  - re2c                ✓ ✓ ✓ ✓ ✓
  - readline            ✓ . ✓ ✓ ✓
  - regex               ✓ . . . .
  - rego                ✓ . . . ✓
  - requirements        ✓ . . . ✓
  - rescript            ✓ ✓ ✓ ✓ ✓
  - rnoweb              ✓ . ✓ . ✓
  - robot               ✓ . ✓ ✓ ✓
  - robots              ✓ . . . ✓
  - roc                 ✓ ✓ . . ✓
  - ron                 ✓ ✓ ✓ ✓ ✓
  - rst                 ✓ ✓ . . ✓
  - ruby                ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - scala               ✓ ✓ ✓ . ✓
  - scfg                ✓ . . . ✓
  - scheme              ✓ . ✓ . ✓
  - scss                ✓ . ✓ ✓ ✓
  - sflog               ✓ . . . .
  - slang               ✓ ✓ ✓ ✓ ✓
  - slint               ✓ ✓ ✓ ✓ ✓
  - smali               ✓ ✓ ✓ ✓ ✓
  - smithy              ✓ . . . ✓
  - snakemake           ✓ ✓ ✓ ✓ ✓
  - solidity            ✓ . ✓ . ✓
  - soql                ✓ . . . .
  - sosl                ✓ . . . .
  - sourcepawn          ✓ ✓ . . ✓
  - sparql              ✓ ✓ ✓ ✓ ✓
  - sql                 ✓ . . ✓ ✓
  - squirrel            ✓ ✓ ✓ ✓ ✓
  - ssh_config          ✓ ✓ ✓ ✓ ✓
  - starlark            ✓ ✓ ✓ ✓ ✓
  - strace              ✓ . . . ✓
  - styled              ✓ . ✓ ✓ ✓
  - supercollider       ✓ ✓ ✓ ✓ ✓
  - surface             ✓ . ✓ ✓ ✓
  - svelte              ✓ ✓ ✓ ✓ ✓
  - swift               ✓ ✓ . ✓ ✓
  - sxhkdrc             ✓ . ✓ . ✓
  - systemtap           ✓ ✓ ✓ . ✓
  - systemverilog       ✓ . ✓ . ✓
  - t32                 ✓ ✓ ✓ ✓ ✓
  - tablegen            ✓ ✓ ✓ ✓ ✓
  - tact                ✓ ✓ ✓ ✓ ✓
  - tcl                 ✓ . ✓ ✓ ✓
  - teal                ✓ ✓ ✓ ✓ ✓
  - templ               ✓ . ✓ . ✓
  - terraform           ✓ . ✓ ✓ ✓
  - textproto           ✓ . ✓ ✓ ✓
  - thrift              ✓ ✓ ✓ ✓ ✓
  - tiger               ✓ ✓ ✓ ✓ ✓
  - tlaplus             ✓ ✓ ✓ . ✓
  - tmux                ✓ . . . ✓
  - todotxt             ✓ . . . .
  - toml                ✓ ✓ ✓ ✓ ✓
  - tsv                 ✓ . . . .
  - tsx                 ✓ ✓ ✓ ✓ ✓
  - turtle              ✓ ✓ ✓ ✓ ✓
  - twig                ✓ . . . ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - typespec            ✓ . . ✓ ✓
  - typoscript          ✓ . ✓ ✓ ✓
  - typst               ✓ . ✓ ✓ ✓
  - udev                ✓ ✓ . . ✓
  - ungrammar           ✓ ✓ ✓ ✓ ✓
  - unison              ✓ . . . ✓
  - usd                 ✓ ✓ ✓ ✓ ✓
  - uxntal              ✓ ✓ ✓ ✓ ✓
  - v                   ✓ ✓ ✓ ✓ ✓
  - vala                ✓ . ✓ . ✓
  - vento               ✓ . . . ✓
  - verilog             ✓ ✓ ✓ . ✓
  - vhdl                ✓ . ✓ . ✓
  - vhs                 ✓ . . . ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - vrl                 ✓ ✓ ✓ ✓ ✓
  - vue                 ✓ . ✓ ✓ ✓
  - wgsl                ✓ . ✓ ✓ ✓
  - wgsl_bevy           ✓ . ✓ ✓ .
  - wing                ✓ ✓ ✓ . ✓
  - wit                 ✓ . ✓ . ✓
  - xcompose            ✓ ✓ . . ✓
  - xml                 ✓ ✓ ✓ ✓ ✓
  - yaml                ✓ ✓ ✓ ✓ ✓
  - yang                ✓ . ✓ ✓ ✓
  - yuck                ✓ ✓ ✓ ✓ ✓
  - zathurarc           ✓ . . . ✓
  - zig                 ✓ ✓ ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

Looks fine.

jmbuhr commented 1 month ago

Is this the same issue? https://github.com/jmbuhr/otter.nvim/issues/176#issuecomment-2353788250

refaelsh commented 1 month ago

Is this the same issue? #176 (comment)

No.

jmbuhr commented 1 month ago

Do you have an example file for this? Any other relevant plugins?

refaelsh commented 1 month ago

I dont have an init.lua file to give you since I am using NixOS+Nixvim, and on top of that, I manage it in an org file. Here it is: https://github.com/refaelsh/dotfiles/blob/master/configuration.org.

jmbuhr commented 1 month ago

Ok. Happy to take a look if you can provide a minimal reproducible example with a file the produces the error and e.g. a config starting from kickstarter.nvim.

refaelsh commented 1 month ago

I understand your idea. So, I took the init.lua from kickstarter.nvim repo and run it likes this: nvim -u path_to_file.lua. The only things I added are the following:

vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
  pattern = "*.org",
  callback = function()
    require('otter').activate()
  end,
})

{
  'nvim-orgmode/orgmode',
  event = 'VeryLazy',
  ft = { 'org' },
  config = function()
    -- Setup orgmode
    require('orgmode').setup({
      org_agenda_files = '~/orgfiles/**/*',
      org_default_notes_file = '~/orgfiles/refile.org',
    })
  end,
},
{
    'jmbuhr/otter.nvim',
    dependencies = {
      'nvim-treesitter/nvim-treesitter',
    },
    opts = {},
},

The problem still persists.

jmbuhr commented 1 month ago

Do you have an example file that exhibits the error when opened with this config?

refaelsh commented 1 month ago

Sure. Here is a minimal file and the issue is still there:

* Bla
asasfasd
** dsfsdf
dsfsdfs
jmbuhr commented 1 month ago

This does not reproduce the error. You can use the NVIM_APPNAME environment variable to create a truly independent nvim and avoid spillover from your other config and share directories.

jmbuhr commented 1 month ago

Closing this to reduce noise, please open a new issue with the reprex once you have it.

refaelsh commented 1 month ago

Closing this to reduce noise, please open a new issue with the reprex once you have it.

Agreed and understood.

refaelsh commented 1 month ago

This does not reproduce the error. You can use the NVIM_APPNAME environment variable to create a truly independent nvim and avoid spillover from your other config and share directories.

I will go and google NVIM_APPNAME and open a new issues as you rightly suggested.

Thank you :-)

Lcchy commented 1 month ago

FYI I had the same problem when using the autocmd you used.

I think it is coming from the fact that treesitter hasn't loaded yet when the autocmd is called.

Using FileType works for me, as it seems to be called after treesitter has started:

vim.api.nvim_create_autocmd({ "FileType" }, {
    pattern = { "org" },
    callback = function()
        require("otter").activate()
    end,
})
refaelsh commented 1 month ago

Thank you @Lcchy!