From d6510eec4f5e4d1ca08f685f9ce7984ca9ab1c9e Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 3 Jan 2023 09:13:35 -0700 Subject: feat(editorconfig): add editorconfig syntax file This is intentionally _not_ copied from Vim because our syntax file makes use of Lua to dynamically generate a list of valid EditorConfig properties. This requires the builtin editorconfig module, which Vim does not have. --- runtime/lua/vim/filetype.lua | 2 +- runtime/syntax/editorconfig.vim | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 runtime/syntax/editorconfig.vim (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 7eec567b66..c3ab39a1a3 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1378,13 +1378,13 @@ local filename = { npmrc = 'dosini', ['/etc/yum.conf'] = 'dosini', ['.npmrc'] = 'dosini', - ['.editorconfig'] = 'dosini', ['/etc/pacman.conf'] = 'confini', ['mpv.conf'] = 'confini', dune = 'dune', jbuild = 'dune', ['dune-workspace'] = 'dune', ['dune-project'] = 'dune', + ['.editorconfig'] = 'editorconfig', ['elinks.conf'] = 'elinks', ['mix.lock'] = 'elixir', ['filter-rules'] = 'elmfilt', diff --git a/runtime/syntax/editorconfig.vim b/runtime/syntax/editorconfig.vim new file mode 100644 index 0000000000..006b99cec5 --- /dev/null +++ b/runtime/syntax/editorconfig.vim @@ -0,0 +1,18 @@ +runtime! syntax/dosini.vim +unlet! b:current_syntax + +syntax match editorconfigInvalidProperty "^\s*\zs\w\+\ze\s*=" +syntax keyword editorconfigProperty root + +lua<< +local props = {} +for k in pairs(require('editorconfig').properties) do + props[#props + 1] = k +end +vim.cmd(string.format('syntax keyword editorconfigProperty %s', table.concat(props, ' '))) +. + +hi def link editorconfigInvalidProperty Error +hi def link editorconfigProperty dosiniLabel + +let b:current_syntax = 'editorconfig' -- cgit