From e9440d7f62546434934e64bde4810f0a46277210 Mon Sep 17 00:00:00 2001 From: ADoyle Date: Sat, 10 Jun 2023 14:08:16 +0800 Subject: [PATCH] fix!: filetype.nvim not support neovim 0.9 - fix #14 - use vim.filetype.add to replace nathom/filetype.nvim Breaking Change: The content of `config.filetype` is changed. From `{ overrides = { extensions = {}, literal = {}, complex = {} } }`, to `{ extension = {}, filename = {}, pattern = {} }`. See `:h vim.filetype.add` for details. --- lua/one/plugins/filetype.lua | 70 +++++++++--------------------------- 1 file changed, 16 insertions(+), 54 deletions(-) diff --git a/lua/one/plugins/filetype.lua b/lua/one/plugins/filetype.lua index 1059832..b46293a 100644 --- a/lua/one/plugins/filetype.lua +++ b/lua/one/plugins/filetype.lua @@ -1,67 +1,29 @@ -local M = { 'nathom/filetype.nvim', desc = 'filetype detection' } +local M = { 'filetype', desc = 'filetype detection' } function M.config(config) - local conf = config.filetype - - ---@diagnostic disable-next-line: different-requires, redundant-parameter - require('filetype').setup(conf) + vim.filetype.add(config.filetype) end M.defaultConfig = { 'filetype', { - overrides = { - - -- Set the filetype based on file extension - extensions = { - -- *.cocoascript files set filetype javascript - cocoascript = 'javascript', - bats = 'sh', - }, - - -- Set the filetype based on filename - literal = { bash_profile = 'sh', profile = 'sh' }, - - complex = { - -- Set the filetype of any full filename matching the regex to gitconfig - ['.*git/config'] = 'gitconfig', - ['Dockerfile*'] = 'dockerfile', - ['*.dockerfile'] = 'dockerfile', - }, + -- see :h vim.filetype.add - -- shebang = { - -- -- Set the filetype of files with a dash shebang to sh - -- dash = "sh", - -- }, - - -- The same as the ones above except the keys map to functions - -- function_extensions = { - -- cpp = function() - -- vim.bo.filetype = "cpp" - -- -- Remove annoying indent jumping - -- vim.bo.cinoptions = vim.bo.cinoptions .. "L0" - -- end, - - -- jsx = function() - -- vim.bo.filetype = "pdf" - -- -- Open in PDF viewer (Skim.app) automatically - -- vim.fn.jobstart( - -- "open -a skim " .. '"' .. vim.fn.expand("%") .. '"' - -- ) - -- end, - -- }, + -- Set the filetype based on file extension + extension = { + -- *.cocoascript files set filetype javascript + cocoascript = 'javascript', + bats = 'sh', + }, - -- function_literal = { - -- Brewfile = function() - -- vim.cmd("syntax off") - -- end, - -- }, + -- Set the filetype based on filename + filename = { bash_profile = 'sh', profile = 'sh' }, - -- function_complex = { - -- ["*.math_notes/%w+"] = function() - -- vim.cmd("iabbrev $ $$") - -- end, - -- }, + pattern = { + -- Set the filetype of any full filename matching the regex to gitconfig + ['.*git/config'] = 'gitconfig', + ['Dockerfile*'] = 'dockerfile', + ['*.dockerfile'] = 'dockerfile', }, },