vim-patch:9.0.1766: Runtime: Missing QML support

Problem:  Runtime: Missing QML support
Solution: Add QML support to Vim

closes: vim/vim#12810

bedc69f9d6

Co-authored-by: ChaseKnowlden <haroldknowlden@gmail.com>
This commit is contained in:
Christian Clason 2023-08-21 09:46:44 +09:00
parent a2a226170d
commit a5b6468e9b
5 changed files with 1223 additions and 0 deletions

31
runtime/ftplugin/qml.vim Normal file
View File

@ -0,0 +1,31 @@
" Vim filetype plugin file
" Language: QML
" Maintainer: Chase Knowlden <haroldknowlden@gmail.com>
" Last Change: 2023 Aug 16
if exists( 'b:did_ftplugin' )
finish
endif
let b:did_ftplugin = 1
let s:cpoptions_save = &cpoptions
set cpoptions&vim
" command for undo
let b:undo_ftplugin = "setlocal formatoptions< comments< commentstring<"
if (has("gui_win32") || has("gui_gtk")) && !exists( 'b:browsefilter' )
let b:browsefilter =
\ 'QML Files (*.qml,*.qbs)\t*.qml;*.qbs\n' .
\ 'All Files\t*\n'
endif
" Set 'comments' to format dashed lists in comments.
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
setlocal commentstring=//%s
setlocal formatoptions-=t
setlocal formatoptions+=croql
let &cpoptions = s:cpoptions_save
unlet s:cpoptions_save

59
runtime/indent/qml.vim Normal file
View File

@ -0,0 +1,59 @@
" Vim indent file
" Language: QML
" Maintainer: Chase Knowlden <haroldknowlden@gmail.com>
" Last Change: 2023 Aug 16
"
" Improved JavaScript indent script.
" Indent script in place for this already?
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
let b:undo_indent = "setlocal indentexpr< indentkeys<"
setlocal indentexpr=s:GetQmlIndent()
setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e,*<Return>,=*/
" Only define functions once per session
if exists("*s:GetQmlIndent")
finish
endif
" Clean up a line of code by removing trailing '//' and '/* */' comments, and trimming
" whitespace
function! s:Trim(line)
return substitute(substitute(substitute(a:line, '// .*', '', ''), '/\* .* \*/', '', ''), '^\s*\|\s*$', '', 'g')
endfunction
function! s:GetQmlIndent()
let num = v:lnum
let line = s:Trim(getline(num))
let pnum = prevnonblank(num - 1)
if pnum == 0
return 0
endif
let pline = s:Trim(getline(pnum))
let ind = indent(pnum)
" bracket/brace/paren blocks
if pline =~ '[{[(]$'
let ind += &sw
endif
if line =~ '^[}\])]'
let ind -= &sw
endif
" '/*' comments
if pline =~ '^/\*.*\*/'
" no indent for single-line form
elseif pline =~ '^/\*'
let ind += 1
elseif pline =~ '^\*/'
let ind -= 1
endif
return ind
endfunction

View File

@ -800,6 +800,8 @@ local extension = {
ptl = 'python',
ql = 'ql',
qll = 'ql',
qml = 'qml',
qbs = 'qml',
qmd = 'quarto',
R = detect.r,
rkt = 'racket',

1130
runtime/syntax/qml.vim Normal file

File diff suppressed because it is too large Load Diff

View File

@ -511,6 +511,7 @@ func s:GetFilenameChecks() abort
\ 'pyrex': ['file.pyx', 'file.pxd'],
\ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', 'file.ptl', 'file.pyi', 'SConstruct'],
\ 'ql': ['file.ql', 'file.qll'],
\ 'qml': ['file.qml', 'file.qbs'],
\ 'qmldir': ['qmldir'],
\ 'quake': ['anybaseq2/file.cfg', 'anyid1/file.cfg', 'quake3/file.cfg', 'baseq2/file.cfg', 'id1/file.cfg', 'quake1/file.cfg', 'some-baseq2/file.cfg', 'some-id1/file.cfg', 'some-quake1/file.cfg'],
\ 'quarto': ['file.qmd'],