From 97af93b2a8ebc89364852e3f63e9fd8cfedaeedf Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Mon, 9 Jun 2025 13:43:45 +0300 Subject: =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D1=91=D0=BB=20dotfiles?= =?UTF-8?q?=20=D0=BD=D0=B0=20stow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/nvim/lua/syntax/hjson.lua | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 config/nvim/lua/syntax/hjson.lua (limited to 'config/nvim/lua/syntax/hjson.lua') diff --git a/config/nvim/lua/syntax/hjson.lua b/config/nvim/lua/syntax/hjson.lua new file mode 100644 index 0000000..a2e01ed --- /dev/null +++ b/config/nvim/lua/syntax/hjson.lua @@ -0,0 +1,61 @@ +-- ~/.config/nvim/after/syntax/hjson.lua +-- Или путь плагина: ~/.config/nvim/plugin/hjson.lua + +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + pattern = "*.hjson", + callback = function() + vim.b.current_syntax = "hjson" + + -- Очистка предыдущих правил + vim.cmd("syntax clear") + + -- Комментарии (высший приоритет) + vim.cmd([[ syntax match hjsonLineComment "\/\/.*" ]]) + vim.cmd([[ syntax match hjsonLineComment "#.*" ]]) + vim.cmd([[ syntax region hjsonComment start="/\*" end="\*/" ]]) + + -- Строки + vim.cmd([[ syntax region hjsonString matchgroup=hjsonQuote start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=hjsonEscape ]]) + vim.cmd([[ syntax region hjsonString matchgroup=hjsonQuote start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=hjsonEscape ]]) + vim.cmd([[ syntax region hjsonMLString matchgroup=hjsonQuote start=/'''/ end=/'''/ ]]) + + -- Числа + vim.cmd([[ syntax match hjsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>" ]]) + + -- Булевы значения и null + vim.cmd([[ syntax keyword hjsonBoolean true false ]]) + vim.cmd([[ syntax keyword hjsonNull null ]]) + + -- Ключи объектов + vim.cmd([[ syntax match hjsonKey "[^][{}:,\"'\s]\+" contained ]]) + vim.cmd([[ syntax match hjsonKeyUnquoted "[^][{}:,\"'\s]\+:"he=e-1 contains=hjsonKey,hjsonNoise ]]) + + -- Пунктуация + vim.cmd([[ syntax match hjsonNoise "[{}\[\],:]" ]]) + + -- Escape-последовательности + vim.cmd([[ syntax match hjsonEscape "\\[\\\"'/bfnrt]" contained ]]) + vim.cmd([[ syntax match hjsonEscape "\\u\x\{4}" contained ]]) + + -- Строки без кавычек (низший приоритет) + vim.cmd([[ syntax match hjsonStringUQ "[^][{}:,\"'\s]\+" contains=@NoSpell ]]) + + -- Сворачивание структур + vim.cmd([[ syntax region hjsonObject matchgroup=hjsonBraces start="{" end="}" transparent fold ]]) + vim.cmd([[ syntax region hjsonArray matchgroup=hjsonBraces start="\[" end="\]" transparent fold ]]) + + -- Подсветка + vim.cmd([[ highlight default link hjsonComment Comment ]]) + vim.cmd([[ highlight default link hjsonLineComment Comment ]]) + vim.cmd([[ highlight default link hjsonString String ]]) + vim.cmd([[ highlight default link hjsonMLString String ]]) + vim.cmd([[ highlight default link hjsonStringUQ String ]]) + vim.cmd([[ highlight default link hjsonEscape SpecialChar ]]) + vim.cmd([[ highlight default link hjsonNumber Number ]]) + vim.cmd([[ highlight default link hjsonBoolean Boolean ]]) + vim.cmd([[ highlight default link hjsonNull Constant ]]) + vim.cmd([[ highlight default link hjsonKey Label ]]) + vim.cmd([[ highlight default link hjsonNoise Delimiter ]]) + vim.cmd([[ highlight default link hjsonBraces Delimiter ]]) + end +}) -- cgit v1.2.3