Skip to content

Commit

Permalink
fix!: filetype.nvim not support neovim 0.9
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
adoyle-h committed Jun 10, 2023
1 parent 3c5d5d1 commit e9440d7
Showing 1 changed file with 16 additions and 54 deletions.
70 changes: 16 additions & 54 deletions lua/one/plugins/filetype.lua
Original file line number Diff line number Diff line change
@@ -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',
},

},
Expand Down

0 comments on commit e9440d7

Please sign in to comment.