nathom / filetype.nvim

A faster version of filetype.vim
560 stars 35 forks source link

Vim:E492: Not an editor command: dist#ft#SetFileTypeSH("bash") #68

Closed ttys3 closed 2 years ago

ttys3 commented 2 years ago
Error detected while processing BufReadPost Autocommands for "*":
E5108: Error executing lua ...r/start/filetype.nvim/lua/filetype/mappings/function.lua:568: Vim:E492: Not an editor command: dist#ft#SetFileTypeSH("bash")
stack traceback:
        [C]: in function 'cmd'
        ...r/start/filetype.nvim/lua/filetype/mappings/function.lua:568: in function 'name'
        ...te/pack/packer/start/filetype.nvim/lua/filetype/init.lua:17: in function 'set_filetype'
        ...te/pack/packer/start/filetype.nvim/lua/filetype/init.lua:52: in function 'try_regex'
        ...te/pack/packer/start/filetype.nvim/lua/filetype/init.lua:171: in function 'resolve'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to contin
punowo commented 2 years ago

Also happens to me when I open .bash_profile.

ObserverOfTime commented 2 years ago

Update: sourcing dist#ft breaks the plugin. Do this instead:

local function bash_literal()
    vim.bo.filetype = 'sh'
    vim.b.is_bash = true
end

require('filetype').setup {
    overrides = {
        function_literal = {
            ['.bashrc'] = bash_literal,
            ['.bash_profile'] = bash_literal,
            ['.bash_history'] = bash_literal,
            ['.bash_logout'] = bash_literal,
            ... -- more overrides
        },
        ... -- even more overrides
    }
}

Here's a bandaid for packer.nvim users:

    use {
        'nathom/filetype.nvim',
        setup = [[vim.cmd('runtime! autoload/dist/ft.vim')]],
        ... -- config and whatever else
    }

This command should probably be included in the plugin. (related to #9)

foundObjects commented 2 years ago

I'm also experiencing this with any .bash* file. The band-aid above works with a single complex rule as a workaround:

require('filetype').setup {
    overrides = {
        complex = {
            ['.*/.bash.*'] = bash_literal,
        },
    },
}
evanpurkhiser commented 1 year ago

I am seeing this now in the nighly neovim builds.

I suspect because of this bullet

filetype.vim is removed in favor of lua-filetype (Note that filetype logic and tests still align with Vim, so additions or changes need to be contributed there first.) See https://github.com/neovim/neovim/pull/20674.

I believe what I'm seeing is the same as https://github.com/nathom/filetype.nvim/issues/91