Julian / lean.nvim

neovim support for the Lean theorem prover
MIT License
255 stars 25 forks source link

attempt to index global 'lean_nvim_ft_options' (a nil value) #275

Closed OmeletWithoutEgg closed 2 years ago

OmeletWithoutEgg commented 2 years ago

After some recent updates, the following error jumps out when I re-launch neovim.

Error detected while processing /home/user/.config/nvim/init.lua:
E5113: Error while calling lua chunk: ...re/nvim/site/pack/packer/start/lean.nvim/lua/lean/ft.lua:3: attempt to index global 'lean_nvim_ft_options' (a nil value)
stack traceback:
...re/nvim/site/pack/packer/start/lean.nvim/lua/lean/ft.lua:3: in main chunk
[C]: in function 'require'
.../nvim/site/pack/packer/start/lean.nvim/lua/lean/init.lua:61: in function 'setup'
/home/user/.config/nvim/lua/config/lsp.lua:95: in main chunk
[C]: in function 'require'
/home/user/.config/nvim/init.lua:4: in main chunk

To reproduce, use this init.lua config

require('packer').startup(function(use)
    use 'wbthomason/packer.nvim'

    use 'Julian/lean.nvim'
    use 'neovim/nvim-lspconfig'
    use 'nvim-lua/plenary.nvim'

    -- Optional Dependencies:

    use 'hrsh7th/nvim-cmp'        -- For LSP completion
    use 'hrsh7th/vim-vsnip'       -- For snippets
    use 'andrewradev/switch.vim'  -- For Lean switch support
    use 'tomtom/tcomment_vim'     -- For commenting motions
end)

require('lean').setup{
    abbreviations = { builtin = true },
    -- lsp = { on_attach = on_attach },
    -- lsp3 = { on_attach = on_attach },
    mappings = true,
}
Julian commented 2 years ago

This is obviously related to #273 so CC @4e554c4c . Will try to have a look tomorrow myself.

4e554c4c commented 2 years ago

can reproduce. this doesn't happen if you do

use {'Julian/lean.nvim', config = function() require 'lean'.setup{abbreviations = { builtin = true },mappings = true,} end}

so for some reason plugin configs are run after ftdetect scripts, but code in init.lua isn't.

4e554c4c commented 2 years ago

anyway this is kind of convincing me even more of what I said in https://github.com/Julian/lean.nvim/pull/273#discussion_r962194668, that we should make lean_nvim_ft_options the stardard API for interacting with the ftdetect script, which can be edited by users or the ft module. I'll try to release a fix for this in the next day or so, and draft up an API for working with file detection at the same time.