NoahTheDuke / vim-just

Vim Just Syntax
MIT License
76 stars 8 forks source link

vim-just doesn't detect Justfile buffer when starting nvim by creating new file #47

Closed erikkrieg closed 9 months ago

erikkrieg commented 9 months ago

vim-just does not seem to realize I have an active just buffer in some cases.

I am running something like:

nvim Justfile

But vim-just fails to detect that this is a just buffer. If I save and quit, then opening the existing file in the same way does work as expected.

I have done this test with other languages I have LSP setup for and they do work as expected.

Edit: For additional context, I am using lazy as my plugin manager. Here is where I setup the plugin:

{
  "NoahTheDuke/vim-just",
  event = { "BufReadPre", "BufNewFile" },
},

I have confirmed that in the case where vim-just is not syntax highlighting the new Justfile that the vim-just plugin is actually loaded.

laniakea64 commented 9 months ago

I can confirm the issue when using lazy.nvim on Neovim 0.8.3. But it works if instead of using lazy.nvim, I copy the vim-just clone that lazy.nvim created into ~/.config/nvim/pack/vim-just/start/.

What makes you think this isn't a lazy.nvim issue?

erikkrieg commented 9 months ago

I haven't dug into code yet, but my hunch is that vim-just has assumptions about when it gets loaded that doesn't account for the lazy loading that lazy.nvim offers. So this could be a feature request to support lazy as much as a might be a bug.

Alternatively, there is no problem with either and I am just missing options for loading vim-just with lazy.nvim that would make this work. Maybe someone following this repo is already aware something?

laniakea64 commented 9 months ago

I'm not really familiar with Neovim or lazy.nvim or Lua, but this init.lua seem to get it working? -

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  "NoahTheDuke/vim-just",
  event = { "BufReadPre", "BufNewFile" },
  ft = { "\\cjustfile", "*.just", ".justfile" },
})
erikkrieg commented 9 months ago

Cool, I'll give adding the ft option a try and see what happens. I'll let you know how it goes :)

erikkrieg commented 9 months ago

That seems to work for me, thanks!

I think that we could add this to the install section of the README for future travellers.

laniakea64 commented 9 months ago

That seems to work for me, thanks!

:+1: You're welcome.

I think that we could add this to the install section of the README for future travellers.

That's up to @NoahTheDuke . If he agrees, feel free to submit a pull request with the appropriate code snippet.

erikkrieg commented 9 months ago

@NoahTheDuke let me know if you're down with that and I'll open up a PR.

NoahTheDuke commented 9 months ago

Yeah of course, go for it.

laniakea64 commented 6 months ago

For anyone who happens on this issue in a search, the recommended instructions for installing vim-just using lazy.nvim have been updated since this issue was closed, see https://github.com/NoahTheDuke/vim-just#lazynvim for current instructions.