V13Axel / neotest-pest

Neotest adapter for Pest 2.0
MIT License
14 stars 5 forks source link

All of a sudden neotest won't do anything visible (and slows down Vim incredibly for ~30seconds) #7

Closed nexxai closed 2 months ago

nexxai commented 3 months ago

Ok, I'm still fairly new to Neovim so I'm not sure how to provide more details but happy to give anything that's missing here if you can explain how, but the gist of the situation is: I just started working on some PHP this evening (I haven't in maybe a week or two?) and when I went to run my usual keymap, Neotest does not run (at least visibly) but something happens in the background that Neovim ends up absolutely dog slow for about 30 seconds.

I'm not sure what could have happened and I definitely haven't been messing with my Neovim config for at least a month so aside from updating my plugins, I'm not sure what I could have done to break things.

I'm running Neovim 0.9.5 and here is the output from :checkhealth. Nothing about it seems odd, but there's also nothing about neotest in there so I'm not sure if that should alarming.

==============================================================================
floaterm: require("floaterm.health").check()

common ~
- Platform: Darwin
- Nvim: NVIM v0.9.5
- Plugin: fatal: not a git repository (or any of the parent directories): .git

terminal ~
- OK Terminal emulator is available

floating ~
- OK Floating window is available

==============================================================================
laravel: require("laravel.health").check()

Laravel ~

External Dependencies ~
- OK rg installed

Plugin Dependencies ~
- OK Null LS is installed
- OK luasnip is installed
- OK Nui is installed
- OK Telescope is installed

Environment ~
- OK Environment setup successful
- Name: local
- Condition: 
- {
  executable = { "php" }
  }
- Commands: 
- {}

Composer Dependencies ~
- OK Composer dependency `laravel/tinker` is installed

==============================================================================
lazy: require("lazy.health").check()

lazy.nvim ~
- OK Git installed
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found
- WARNING {flash.nvim}: unknown key <vscode>
- WARNING {neo-tree.nvim}: overriding <config>
- WARNING {telescope-fzf-native.nvim}: overriding <config>
- WARNING {vim-projectionist}: unknown key <requires>

==============================================================================
lazyvim: require("lazyvim.health").check()

LazyVim ~
- OK Using Neovim >= 0.9.0
- OK `git` is installed
- OK `rg` is installed
- OK `fd` is installed
- OK `lazygit` is installed

==============================================================================
luasnip: require("luasnip.health").check()

luasnip ~
- OK jsregexp is installed

==============================================================================
mason: require("mason.health").check()

mason.nvim ~
- OK mason.nvim version v1.10.0
- OK PATH: prepend
- OK Providers: 
  mason.providers.registry-api
  mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2024-05-04-smart-gaze` is installed.

mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send`
- OK wget: `GNU Wget 1.24.5 built on darwin23.2.0.`
- OK curl: `curl 8.4.0 (x86_64-apple-darwin23.0) libcurl/8.4.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.58.0`
- OK gzip: `Apple gzip 430.100.5`
- OK tar: `bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.12 liblzma/5.4.3 bz2lib/1.0.8 `
- OK bash: `GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)`
- OK sh: `Ok`

mason.nvim [Languages] ~
- WARNING luarocks: not available
  - ADVICE:
    - spawn: luarocks failed with exit code - and signal -. luarocks is not executable
- OK Ruby: `ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]`
- OK PHP: `PHP 8.3.6 (cli) (built: Apr 12 2024 00:13:56) (NTS)`
- OK Composer: `Composer version 2.7.1 2024-02-09 15:26:28`
- OK node: `v21.7.3`
- WARNING javac: not available
  - ADVICE:
    - spawn: javac failed with exit code 1 and signal 0. The operation couldn’t be completed. Unable to locate a Java Runtime.
      Please visit http://www.java.com for information on installing Java.

- WARNING java: not available
  - ADVICE:
    - spawn: java failed with exit code 1 and signal 0. The operation couldn’t be completed. Unable to locate a Java Runtime.
      Please visit http://www.java.com for information on installing Java.

- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- OK python: `Python 3.12.3`
- OK RubyGem: `3.0.3.1`
- OK Go: `go version go1.22.2 darwin/arm64`
- OK npm: `10.5.0`
- OK cargo: `cargo 1.77.2`
- OK pip: `pip 24.0 from /opt/homebrew/lib/python3.12/site-packages/pip (python 3.12)`
- OK python venv: `Ok`

mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 0. Remaining: 60. Limit: 60. Reset: Sat  4 May 21:36:06 2024.
  Install and authenticate via gh-cli to increase rate limit.

==============================================================================
neoconf: require("neoconf.health").check()

neoconf.nvim ~
- OK **treesitter-nvim** is installed
- WARNING **TreeSitter jsonc** parser is not installed. Highlighting of jsonc files might be broken
- OK **neodev.nvim** is installed
- OK **lspconfig** is installed
- OK **lspconfig jsonls** is installed
- OK **lspconfig lua_ls** is installed

==============================================================================
noice: require("noice.health").check()

noice.nvim ~
- OK **Neovim** >= 0.8.0
- OK You're using a GUI that should work ok
- OK **vim.go.lazyredraw** is not enabled
- OK **nvim-notify** is installed
- OK **TreeSitter vim** parser is installed
- OK **TreeSitter regex** parser is installed
- OK **TreeSitter lua** parser is installed
- OK **TreeSitter bash** parser is installed
- OK **TreeSitter markdown** parser is installed
- OK **TreeSitter markdown_inline** parser is installed
- OK `vim.notify` is set to **Noice**
- OK `vim.lsp.handlers["textDocument/hover"]` is set to **Noice**
- OK `vim.lsp.handlers["textDocument/signatureHelp"]` is set to **Noice**
- OK `vim.lsp.handlers["window/showMessage"]` is set to **Noice**
- OK `vim.lsp.util.convert_input_to_markdown_lines` is set to **Noice**
- OK `vim.lsp.util.stylize_markdown` is set to **Noice**
- OK `cmp.entry.get_documentation` is set to **Noice**

==============================================================================
null-ls: require("null-ls.health").check()

- OK black: the command "black" is executable.
- OK prettier: the command "prettier" is executable.
- OK hadolint: the command "hadolint" is executable.
- OK markdownlint: the command "markdownlint" is executable.
- ERROR terraform_fmt: the command "terraform" is not executable.
- ERROR terraform_validate: the command "terraform" is not executable.
- ERROR fish_indent: the command "fish_indent" is not executable.
- ERROR fish: the command "fish" is not executable.
- OK stylua: the command "stylua" is executable.
- OK shfmt: the command "shfmt" is executable.
- ERROR gomodifytags: the source "gomodifytags" cannot be ran.
- ERROR impl: the source "impl" cannot be ran.
- ERROR goimports: the command "goimports" is not executable.
- ERROR gofumpt: the command "gofumpt" is not executable.
- Laravel_completion: cannot verify if the command is an executable.
- Laravel_Diagnostics: cannot verify if the command is an executable.
- Laravel_CodeAction: cannot verify if the command is an executable.

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

Configuration ~
- OK no issues found

Runtime ~
- OK $VIMRUNTIME: /opt/homebrew/Cellar/neovim/0.9.5/share/nvim/runtime

Performance ~
- OK Build type: Release

Remote Plugins ~
- OK Up to date

terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=^H`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`
- $TERM_PROGRAM="tmux"
- $COLORTERM="truecolor"

tmux ~
- OK escape-time: 0
- OK focus-events: on
- $TERM: xterm-256color
- ERROR $TERM should be "screen-256color" or "tmux-256color" in tmux. Colors might look wrong.
  - ADVICE:
    - Set default-terminal in ~/.tmux.conf:
      set-option -g default-terminal "screen-256color"
    - https://github.com/neovim/neovim/wiki/Building-Neovim#optimized-builds

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

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

OS Info:
{
  machine = "arm64",
  release = "23.4.0",
  sysname = "Darwin",
  version = "Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - html                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - php                 ✓ ✓ ✓ ✓ ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - regex               ✓ . . . .
  - tsx                 ✓ ✓ ✓ ✓ ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              x . . . ✓
  - vue                 ✓ . ✓ ✓ ✓
  - yaml                ✓ ✓ ✓ ✓ ✓

  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} ~

The following errors have been detected: ~
- ERROR vimdoc(highlights): ...im/0.9.5/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 749 for language vimdoc
  vimdoc(highlights) is concatenated from the following files:
  | [ERROR]:"/Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/queries/vimdoc/highlights.scm", failed to load: ...im/0.9.5/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 749 for language vimdoc

==============================================================================
phpactor: health#phpactor#check

Info ~
- Phpactor version: ac99b4d8 (3 days ago) Fix-one-more-missing-PHP_BINARY-2650 
- PHP version: 8.2
- Filesystemsgit, simple, composer
- Working directory/Users/nexxai/code/flash

Diagnostics ~
- OK XDebug is disabled. XDebug has a negative effect on performance.
- OK Git detected - enables faster refactorings in your repository scope!
- OK Composer detected - Phpactor could work faster without an index

Config files (missing is not bad) ~
- WARNING /Users/nexxai/.config/phpactor/phpactor.json
- WARNING /Users/nexxai/.config/phpactor/phpactor.yml
- WARNING /Users/nexxai/code/flash/.phpactor.json
- WARNING /Users/nexxai/code/flash/.phpactor.yml

==============================================================================
provider: health#provider#check

Clipboard (optional) ~
- OK Clipboard tool found: pbcopy

Python 3 provider (optional) ~
- WARNING No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
- WARNING Could not load Python 3:
  /opt/homebrew/bin/python3 does not have the "neovim" module.
  /opt/homebrew/bin/python3.12 does not have the "neovim" module.
  /opt/homebrew/bin/python3.11 does not have the "neovim" module.
  python3.10 not found in search path or not executable.
  python3.9 not found in search path or not executable.
  python3.8 not found in search path or not executable.
  python3.7 not found in search path or not executable.
  python not found in search path or not executable.
  - ADVICE:
    - See :help |provider-python| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
- Executable: Not found

Python virtualenv ~
- OK no $VIRTUAL_ENV

Ruby provider (optional) ~
- Ruby: ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
- WARNING `neovim-ruby-host` not found.
  - ADVICE:
    - Run `gem install neovim` to ensure the neovim RubyGem is installed.
    - Run `gem environment` to ensure the gem bin directory is in $PATH.
    - If you are using rvm/rbenv/chruby, try "rehashing".
    - See :help |g:ruby_host_prog| for non-standard gem installations.
    - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

Node.js provider (optional) ~
- Node.js: v21.7.3
- WARNING Missing "neovim" npm (or yarn, pnpm) package.
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim
    - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim

Perl provider (optional) ~
- WARNING "Neovim::Ext" cpan module is not installed
  - ADVICE:
    - See :help |provider-perl| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

==============================================================================
telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 14.1.0
- OK fd: found fd 9.0.0

===== Installed extensions ===== ~

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Telescope Extension: `laravel` ~
- No healthcheck provided

Telescope Extension: `notify` ~
- No healthcheck provided

Telescope Extension: `terraform` ~
- No healthcheck provided

Telescope Extension: `terraform_doc` ~
- No healthcheck provided

==============================================================================
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /Users/nexxai/.local/state/nvim/lsp.log
- Log size: 1829 KB

vim.lsp: Active Clients ~
- null-ls (id=1, root_dir=/Users/nexxai/code/flash)
- tailwindcss (id=2, root_dir=/Users/nexxai/code/flash)
- intelephense (id=3, root_dir=/Users/nexxai/code/flash)

==============================================================================
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14
- OK Parser: bash       ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/bash.so
- OK Parser: html       ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/html.so
- OK Parser: javascript ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/javascript.so
- OK Parser: json       ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/json.so
- OK Parser: lua        ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/lua.so
- OK Parser: markdown   ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/markdown.so
- OK Parser: markdown_inline ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/markdown_inline.so
- OK Parser: php        ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/php.so
- OK Parser: python     ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/python.so
- OK Parser: query      ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/query.so
- OK Parser: regex      ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/regex.so
- OK Parser: tsx        ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/tsx.so
- OK Parser: typescript ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/typescript.so
- OK Parser: vim        ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/vim.so
- OK Parser: vue        ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/vue.so
- OK Parser: yaml       ABI: 14, path: /Users/nexxai/.local/share/nvim/lazy/nvim-treesitter/parser/yaml.so
- OK Parser: c          ABI: 14, path: /opt/homebrew/Cellar/neovim/0.9.5/lib/nvim/parser/c.so
- OK Parser: lua        ABI: 14, path: /opt/homebrew/Cellar/neovim/0.9.5/lib/nvim/parser/lua.so
- OK Parser: query      ABI: 14, path: /opt/homebrew/Cellar/neovim/0.9.5/lib/nvim/parser/query.so
- OK Parser: vim        ABI: 14, path: /opt/homebrew/Cellar/neovim/0.9.5/lib/nvim/parser/vim.so
- OK Parser: vimdoc     ABI: 14, path: /opt/homebrew/Cellar/neovim/0.9.5/lib/nvim/parser/vimdoc.so

==============================================================================
vimtex: health#vimtex#check

VimTeX ~
- OK Vim version should have full support!
- WARNING bibtex is not executable!
  - ADVICE:
    - bibtex is required for cite completions.
- WARNING biber is not executable!
  - ADVICE:
    - Biber is often required so this may give unexpected problems.
- OK General viewer should work properly!
- ERROR |g:vimtex_compiler_method| (`latexmk`) is not executable!

This is my loading of neotest, maybe there's something obvious there, but I haven't changed anything in here in months.

vim.keymap.set("n", "<leader>t", "function() require('neotest').run.run() end")
vim.keymap.set("n", "<leader>tt", "function() require('neotest').run.run(vim.fn.expand('%')) end")
vim.keymap.set("n", "<leader>tf", function()
  require("neotest").run.run({ suite = true })
end)
vim.keymap.set("n", "<leader>ts", "function() require('neotest').summary.open() end")

return {
  {
    "nvim-neotest/neotest",
    dependencies = {
      "V13Axel/neotest-pest",
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter",
    },
    config = function()
      require("neotest").setup({
        adapters = {
          require("neotest-pest")({
            pest_cmd = function()
              return "vendor/bin/pest"
            end,
            sail_enabled = function()
              return false
            end,
          }),
        },
      })
    end,
  },
}

If anyone could give me a hand, I would greatly appreciate it.

noreason commented 3 months ago

Had the same issue and I found a quick fix for now.

Looks like there was a commit to nvim-treesitter that changed the way things are parsed (https://github.com/nvim-treesitter/nvim-treesitter/commit/4e21361e15b1d4147830c5fe571556eb1b14e6f9)

You can force nvim-treesitter to use the commit before the failing one (https://github.com/nvim-treesitter/nvim-treesitter/commit/c579d186bec0a4af9d0741b235cfa0627ffd9f15) which should at least get you running tests again.

I'm using LazyVim, but you should get the idea:

return {
  "nvim-treesitter/nvim-treesitter",
  commit = "c579d186bec0a4af9d0741b235cfa0627ffd9f15",
  ...
}
nexxai commented 3 months ago

@noreason You are a lifesaver, thank you.

@V13Axel Any chance you could dig into why this update with treesitter is causing a problem?

V13Axel commented 3 months ago

Oh, interesting! Thanks @noreason for digging into that, I hadn't gotten a chance to yet.

I'll try to make some time this evening to look a bit closer into what's going on with it - The only thing this adapter does with tree-sitter is a query to discover positions, through neotest.lib.

First thought is maybe something changed with how that query gets run.

V13Axel commented 3 months ago

Oh ... I took the minute or two just now to go look at the tree-sitter changelog and I bet I just need to update the query to change string_value to string_content, to match the tree-sitter change.

V13Axel commented 3 months ago

Tried to spend some time this evening on it, but my area was hit by really bad storms today and both power and Internet have been out since. I'll be looking into it a bit closer as soon as things are restored.

noreason commented 2 months ago

Tried to spend some time this evening on it, but my area was hit by really bad storms today and both power and Internet have been out since. I'll be looking into it a bit closer as soon as things are restored.

Ah man, hope everything is good!

Went ahead and tested the change and it did work, so I just opened a PR to help save you some time. Hope it helps.

V13Axel commented 2 months ago

I appreciate the concern, we're all ok on this end. Still waiting for Internet to come back on, but I'm able to get some things done via cell connection at the moment.

When testing the change locally, in a Laravel project running in sail, it appears like it worked... until I try to do anything with it.

The summary window shows only filenames (no tests), and when I try to do anything involving specific tests (such as calling require('neotest').run.run() or even just using i to 'navigate to' one of the files in the summary view), I get a segfault that just crashes neovim immediately. Very confusing.

However, the adapter worked perfectly with the change when trying to run it in this repository and in a fresh app running in sail... So at this point I'm convinced the segfault is my fault and the PR is good to go. ¯\_(ツ)_/¯

V13Axel commented 2 months ago

Yep, update for anyone curious or discovering this thread by hitting the same issue: Discovered that segfault is unrelated, and specifically has to do with treesitter injections via heredocs.

Typing out this content in a fresh PHP file is enough to segfault neovim for me as of the update:

<?php

$someContent = <<<HTML
HTML

After some searching, it appears to be an upstream issue with tree-sitter, according to https://github.com/nvim-treesitter/nvim-treesitter/issues/6573

nexxai commented 2 months ago

I love this community. Thanks both of you for figuring this out so quickly! ❤️

V13Axel commented 2 months ago

Ok last update before I move on, I kept digging and found out the crashes I mentioend are definitely caused by tree-sitter: https://github.com/tree-sitter/tree-sitter-php/issues/238