mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
vim-patch:2d88210: runtime(kdl): include syntax, indent and ftplugin files
closes: vim/vim#14956
2d88210b3c
Co-authored-by: inzuo Jiang <jiangyinzuo@foxmail.com>
Co-authored-by: Aram Drevekenin <aram@poor.dev>
This commit is contained in:
parent
04d3ad1ded
commit
c06f3dbe3e
17
runtime/ftplugin/kdl.vim
Normal file
17
runtime/ftplugin/kdl.vim
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
" Vim filetype plugin
|
||||||
|
" Language: KDL
|
||||||
|
" Author: Aram Drevekenin <aram@poor.dev>
|
||||||
|
" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com>
|
||||||
|
" Last Change: 2024-06-10
|
||||||
|
|
||||||
|
if exists("b:did_ftplugin")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
|
setlocal comments=://
|
||||||
|
setlocal commentstring=//\ %s
|
||||||
|
setlocal formatoptions-=t
|
||||||
|
|
||||||
|
let b:undo_ftplugin = 'setlocal comments< commentstring< formatoptions<'
|
26
runtime/indent/kdl.vim
Normal file
26
runtime/indent/kdl.vim
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: KDL
|
||||||
|
" Author: Aram Drevekenin <aram@poor.dev>
|
||||||
|
" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com>
|
||||||
|
" Last Change: 2024-06-10
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
setlocal indentexpr=KdlIndent()
|
||||||
|
let b:undo_indent = "setlocal indentexpr<"
|
||||||
|
|
||||||
|
function! KdlIndent(...)
|
||||||
|
let line = getline(v:lnum)
|
||||||
|
let previousNum = prevnonblank(v:lnum - 1)
|
||||||
|
let previous = getline(previousNum)
|
||||||
|
|
||||||
|
if previous =~ "{" && previous !~ "}" && line !~ "}" && line !~ ":$"
|
||||||
|
return indent(previousNum) + &tabstop
|
||||||
|
else
|
||||||
|
return indent(previousNum)
|
||||||
|
endif
|
||||||
|
endfunction
|
45
runtime/syntax/kdl.vim
Normal file
45
runtime/syntax/kdl.vim
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: KDL
|
||||||
|
" Maintainer: Aram Drevekenin <aram@poor.dev>
|
||||||
|
" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com>
|
||||||
|
" Latest Revision: 2024-06-10
|
||||||
|
|
||||||
|
" quit when a syntax file was already loaded
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
syn match kdlNode '\v(\w|-|\=)' display
|
||||||
|
syn match kdlBool '\v(true|false)' display
|
||||||
|
|
||||||
|
syn keyword kdlTodo contained TODO FIXME XXX NOTE
|
||||||
|
syn match kdlComment "//.*$" contains=kdlTodo
|
||||||
|
|
||||||
|
" Regular int like number with - + or nothing in front
|
||||||
|
syn match kdlNumber '\d\+'
|
||||||
|
syn match kdlNumber '[-+]\d\+'
|
||||||
|
|
||||||
|
" Floating point number with decimal no E or e (+,-)
|
||||||
|
syn match kdlNumber '\d\+\.\d*' contained display
|
||||||
|
syn match kdlNumber '[-+]\d\+\.\d*' contained display
|
||||||
|
|
||||||
|
" Floating point like number with E and no decimal point (+,-)
|
||||||
|
syn match kdlNumber '[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+' contained display
|
||||||
|
syn match kdlNumber '\d[[:digit:]]*[eE][\-+]\=\d\+' contained display
|
||||||
|
|
||||||
|
" Floating point like number with E and decimal point (+,-)
|
||||||
|
syn match kdlNumber '[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' contained display
|
||||||
|
syn match kdlNumber '\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' contained display
|
||||||
|
|
||||||
|
syn region kdlString start='"' end='"' skip='\\\\\|\\"' display
|
||||||
|
|
||||||
|
syn region kdlChildren start="{" end="}" contains=kdlString,kdlNumber,kdlNode,kdlBool,kdlComment
|
||||||
|
|
||||||
|
hi def link kdlTodo Todo
|
||||||
|
hi def link kdlComment Comment
|
||||||
|
hi def link kdlNode Statement
|
||||||
|
hi def link kdlBool Boolean
|
||||||
|
hi def link kdlString String
|
||||||
|
hi def link kdlNumber Number
|
||||||
|
|
||||||
|
let b:current_syntax = "kdl"
|
Loading…
Reference in New Issue
Block a user