Giter Club home page Giter Club logo

Comments (9)

vito-c avatar vito-c commented on July 24, 2024 1

I'm going to back out the previous PR

from jq.vim.

itchyny avatar itchyny commented on July 24, 2024

@vito-c (CC @Freed-Wu)
I'm facing this issue, too. Please do not expect autoload scripts in ftdetect scripts.

from jq.vim.

Freed-Wu avatar Freed-Wu commented on July 24, 2024

Similar problem like raimon49/requirements.txt.vim#38. What is your minimum vimrc to reproduce?

from jq.vim.

vito-c avatar vito-c commented on July 24, 2024

@itchyny does the latest master work for you now?

from jq.vim.

itchyny avatar itchyny commented on July 24, 2024

Yes, it works after reverting.

from jq.vim.

Freed-Wu avatar Freed-Wu commented on July 24, 2024

Hey, can anyone provide a minimum vimrc to reproduce the bug? I cannot trigger this bug.

from jq.vim.

vito-c avatar vito-c commented on July 24, 2024

@itchyny @baod-rate do you happen to have a simplified version of the file you were using?

from jq.vim.

baodrate avatar baodrate commented on July 24, 2024

I believe the issue (at least, my issue) is when using lazy.nvim's lazy setting (see the section: Startup Sequence). Although I imagine this impacts other methods of lazy-loading as well. jq.vim's ftdetect is sourced in the "handlers" step of lazy's init sequence, regardless of the plugin's lazy setting. this means that call jq#shebang() is executed while opening any file:

function! s:DetectJQ()
if did_filetype() && &filetype !=# 'conf'
return
endif
call jq#shebang()
endfunction
au BufNewFile,BufRead *.jq,.jqrc*,jqrc set filetype=jq
au BufNewFile,BufRead * call s:DetectJQ()

even though autoload/jq.vim is not (yet) in the runtimepath.

I only thing to do here to fix this is perhaps noting that users should avoid lazy=true with jq.vim when using lazy.nvim (and other plugin managers). But perhaps it's best to avoid autoload functions in the ftdetect script altogether, especially since the autocmd loads and executes the function on any buffer anyways.

edit: for the record, a minimal init.lua to reproduce this error:

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

require("lazy").setup({
	{
		"vito-c/jq.vim",
		lazy = true,
		tag = "v1.0.3",
		ft = "jq",
	}
})

from jq.vim.

vito-c avatar vito-c commented on July 24, 2024

@baod-rate that is a nice summary of the issue and I think it explains why having the autoload in ftdetect script would cause an error. Thank you for reporting your findings. I have also added support for the jq filetype in vim. So this plugin will get any latest additions but after the next release of vim there the support should be built in. I'm not sure how often neovim pulls in vim changes but I imagine the changes will show up there soon as well.

from jq.vim.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.