ej-shafran / compile-mode.nvim

A plugin for Neovim inspired by Emacs' Compilation Mode
The Unlicense
50 stars 12 forks source link

Fix default command name causing crash #15

Closed uuuulopta closed 5 months ago

uuuulopta commented 5 months ago

I was having issues with the buffers opening wrong with the latest build so I tried the nightly build, where I got crashes when I tried to run :Compile.

The cause of this was that in plugins/command.lua this line was returning -1:

local bufnr = vim.fn.bufnr(require("compile-mode").config.buffer_name)

I suspect the cause to have something to do with how vim.fn.bufnr parses asterisks ( the default _buffername is *compilation* and anything similar to that doesn't work). Changing it to simply "compilation" fixed the problem.

Windows 11 NVIM v0.9.4 Nightly branch https://github.com/ej-shafran/compile-mode.nvim/commit/4f2c70b9223684770f15ee296de1d087caa93c35

PS. Thanks for this plugin. :)

ej-shafran commented 5 months ago

Hey! Thanks for contributing! Great to see people using this plugin 😊

This seems pretty strange to me - nothing in :h bufnr() mentions invalid buffer names, or anything that might be problematic because of asterisks...

I would like to have more information, i.e. your debug logs, how often this occurs - I'm closing this pull request, how about you open an issue instead and we can dive into the problem together?

Also, I have been wanting to move the nvim_buf_create_user_command calls into init.lua for a while, which should hopefully fix this bug; I'll implement this and push it so you can check if it fixes your issue.

In general, I'd rather keep the buffer name the same (as I mention in the README, I want to stay close to the Emacs compilation mode) - if you need it to be different until there's a proper fix, you can use the buffer_name config option 😸