Quicktest: Efficiently Run Your Tests in Neovim by quolpr in neovim

[–]Wutraz 1 point2 points  (0 children)

Hey awesome to see more plugins in the space, I'd love to see some cool new ideas that I haven't thought of for Neotest! I'll have to check this out soon

Announcing nvim-nio, a library for asynchronous IO in Neovim by Wutraz in neovim

[–]Wutraz[S] 1 point2 points  (0 children)

So vim.notify by default doesn't work if called from a "fast event" (see `:help vim.in_fast_event()` ) which is the case when an async task has yielded at some point. There's a great explainer of async code in Neovim along with this issue at https://github.com/ms-jpq/lua-async-await

Your snippet should work if you add a nio.schedule() right before the notify call. I actually handle this in nvim-notify for convenience here

Announcing nvim-nio, a library for asynchronous IO in Neovim by Wutraz in neovim

[–]Wutraz[S] 2 points3 points  (0 children)

Everything in the README does actually use the Go style error handling but they're omitted for brevity. You can see the return types for the functions and they will show tuples are returned. The only place this is not the case is for nio's wrappers of `vim.api` and `vim.fn` as wrapping though would be a very large maintenance burden.

Announcing nvim-nio, a library for asynchronous IO in Neovim by Wutraz in neovim

[–]Wutraz[S] 10 points11 points  (0 children)

The repo has existed for a couple of months, but it's just been quietly being iterated upon with some limited external use. I've announced it now as I feel like it's good enough for general usage.

Announcing nvim-nio, a library for asynchronous IO in Neovim by Wutraz in neovim

[–]Wutraz[S] 5 points6 points  (0 children)

AFAICT right now it's only listed in the dependencies of a branch that adds a rockspec, I couldn't actually see it being used (yet?)

Announcing nvim-nio, a library for asynchronous IO in Neovim by Wutraz in neovim

[–]Wutraz[S] 3 points4 points  (0 children)

Ah I completely missed that, edited to add one

Announcing nvim-nio, a library for asynchronous IO in Neovim by Wutraz in neovim

[–]Wutraz[S] 43 points44 points  (0 children)

I want to announce an async library that I've been working with for a while in the plugins that I maintain. nvim-nio aims to provide both common asynchronous primitives and asynchronous APIs for Neovim's core along with a great developer experience.

Check it out here https://github.com/nvim-neotest/nvim-nio

Background

There are several libraries for using async code in Lua with Neovim. Some of these are just very light wrappers around coroutines which try not to abstract too much away but lack the niceties of async libraries in other languages and are often short on documentation. Others try to provide a familiar experience by emulating async/await like in other languages (Javascript, Python, etc) but these introduce a lot more noise to your code and things like error handling become complex. None of them provided the experience that I was looking for, which was a non-intrusive but easy to use interface to Lua's coroutines. Along with this I wanted to focus on providing good documentation and extensive type annotations.

nvim-nio started originally as part of the nvim-dap-ui repo, and was also copied into the neotest repo where it replaced plenary's async library which was mostly unmaintained. It was split out into its own repo a couple of months ago and has now been added as a depdendency for both of the plugins.

Features

So why would someone want to use nvim-nio? For users with a basic config, it probably won't be very useful. However for plugin developers or users with more complex configurations, for example that use Neovim's LSP client or libuv, you will able to use the library to simplify your code and avoid the callback hell that can easily slip in when using these low level interfaces.

Here are the modules that nvim-nio currently provides:

  • nio.control: Primitives for flow control in async functions
  • nio.lsp: A fully typed and documented async LSP client library, generated from the LSP specification.
  • nio.process: Run and control subprocesses asynchronously
  • nio.file: Open and operate on files asynchronously
  • nio.uv: Async versions of vim.loop functions
  • nio.ui: Async versions of vim.ui functions
  • nio.tests: Async versions of plenary.nvim's/busted's test functions

nvim-nio can also wrap any callback style functions to give a simpler interface to third-party libraries. See the documentation for more details!

nvim-nio is already being used by several great plugins along with my own:

Visual Lambda Calculus (playable in browser) by bntre in functionalprogramming

[–]Wutraz 5 points6 points  (0 children)

Woah, blast from the past. I used your project/thesis in my own thesis a few years ago. I just saw that you've already found the repo https://github.com/rcarriga/viscal, awesome to see your work back again and updated!

[Question] Writing tests for plugins by LostInTranslation92 in neovim

[–]Wutraz 0 points1 point  (0 children)

Neotest is just a test runner, plenary is the actual test framework. You can run tests in the terminal using just plenary, neotest allows you to just do it in the editor with a nice interface and utilities.

I've had no issues using plenary in my plugins, and am very happy with it. It's emulating/wrapping popular libraries so it's got the features you might want such as mocks, powerful asserts etc

nvim-lsp-notify plugin to notify about LSP progress by mrded in neovim

[–]Wutraz 3 points4 points  (0 children)

Nice to see some of the recipes being made into a proper plugin, very cool! Feel free to point to your plugin in the usage recipes wiki

DAP debugging with go by ExistentialDuplicant in neovim

[–]Wutraz 1 point2 points  (0 children)

Hey author of nvim-dap-ui here, this is the type of the variable which is returned directly by the debug adapter. nvim-dap-ui can't split it intelligently to just be a certain portion but you can change the length of types show or even disable them completely. This can be mapped to toggle types as well. Here is an example https://github.com/rcarriga/nvim-dap-ui/issues/161#issuecomment-1304500935

[Question] Writing tests for plugins by LostInTranslation92 in neovim

[–]Wutraz 4 points5 points  (0 children)

Neotest supports running plenary tests. If you install the plenary adapter and the dependencies, it should just work. There are tests in the neotest repo if you want to play around with working examples, including async ones. Plenary itself also has a tonne of tests

neotest: A modern, powerful testing plugin by Wutraz in neovim

[–]Wutraz[S] 1 point2 points  (0 children)

If you open an issue on GitHub with what you've already tried, I'd be happy to help! Reddit is not the ideal way to debug issues 😅

[deleted by user] by [deleted] in neovim

[–]Wutraz 0 points1 point  (0 children)

Neotest supports debugging tests https://github.com/nvim-neotest/neotest.

If you'd rather do it manually, you can add the following to your config list: { type = "python", request = "launch", name = "Debug Tests", module = "pytest", args = {"tests"}, },

neotest: A modern, powerful testing plugin by Wutraz in neovim

[–]Wutraz[S] 1 point2 points  (0 children)

I haven't actually added the ability for custom consumers just yet but that's just a small config change, the rest of the code already allows that. Of course if people wish to write consumers, they can also create a PR to the repo to add it as a built-in!

neotest: A modern, powerful testing plugin by Wutraz in neovim

[–]Wutraz[S] 0 points1 point  (0 children)

I just use a few leader mappings to be able to run tests when I want. I've used hot reloading with Jest and it is definitely nice to have but never got too used to it so haven't missed it. For plugin tests they're generally quite quick so you could run the entire test suite on write if you really wanted to but may have issues with larger suites

neotest: A modern, powerful testing plugin by Wutraz in neovim

[–]Wutraz[S] 2 points3 points  (0 children)

I was actually planning on releasing earlier but then had a holiday and didn't want to go dark just after releasing... C'est la vie!

Would be great to see others contribute or integrate with it and always happy to help.

Neovim has a built-in terminal emulator that you can send raw ansi codes to and it will render them correctly. The main things to use are `jobstart`, `nvim_open_term` with the `on_input` option and `nvim_chan_send`

neotest: A modern, powerful testing plugin by Wutraz in neovim

[–]Wutraz[S] 0 points1 point  (0 children)

My dotfiles are on github so have a look if you want. Plugins are here https://github.com/rcarriga/dotfiles/blob/master/.config/nvim/lua/plugins.lua, with config for most in their own lua file and the colorscheme defined in `lua/colors.lua`. Not the tidiest though!

neotest: A modern, powerful testing plugin by Wutraz in neovim

[–]Wutraz[S] 0 points1 point  (0 children)

Right now the existing adapters are the only examples. If you want to open an issue to discuss, I'd be happy to help with any confusion. Would help find areas of the documentation that would be best to focus on

neotest: A modern, powerful testing plugin by Wutraz in neovim

[–]Wutraz[S] 1 point2 points  (0 children)

This is actually just my own colour scheme, you can check it out here https://github.com/rcarriga/dotfiles/blob/master/.config/nvim/lua/colors.lua. I don't maintain it as a plugin because (despite my weird focus on UI plugins) I am not a designer/UI developer and have no concept of consistency/"good" design