mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
runtime(lf): improve syntax script, add filetype plugin
- Greatly improve detection and highlighting of command/shell regions, input-device key labels, escape sequences (@joelim-work) - Add ftplugin for formatoptions, toggling comment areas (@andis-sprinkis) - Add a few missing lf option keywords, rm. old non-working code, misc. formatting (@andis-sprinkis) closes: #17078 Signed-off-by: Andis Spriņķis <andis@sprinkis.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
b71f1309a2
commit
7517a8cadf
1
.github/MAINTAINERS
vendored
1
.github/MAINTAINERS
vendored
@ -222,6 +222,7 @@ runtime/ftplugin/ldapconf.vim @ribru17
|
|||||||
runtime/ftplugin/leo.vim @ribru17
|
runtime/ftplugin/leo.vim @ribru17
|
||||||
runtime/ftplugin/less.vim @genoma
|
runtime/ftplugin/less.vim @genoma
|
||||||
runtime/ftplugin/lex.vim @ribru17
|
runtime/ftplugin/lex.vim @ribru17
|
||||||
|
runtime/ftplugin/lf.vim @andis-sprinkis
|
||||||
runtime/ftplugin/liquid.vim @tpope
|
runtime/ftplugin/liquid.vim @tpope
|
||||||
runtime/ftplugin/lua.vim @dkearns
|
runtime/ftplugin/lua.vim @dkearns
|
||||||
runtime/ftplugin/lc.vim @ribru17
|
runtime/ftplugin/lc.vim @ribru17
|
||||||
|
22
runtime/ftplugin/lf.vim
Normal file
22
runtime/ftplugin/lf.vim
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
" Vim filetype plugin file
|
||||||
|
" Language: lf file manager configuration file (lfrc)
|
||||||
|
" Maintainer: Andis Sprinkis <andis@sprinkis.com>
|
||||||
|
" URL: https://github.com/andis-sprinkis/lf-vim
|
||||||
|
" Last Change: 6 Apr 2025
|
||||||
|
|
||||||
|
if exists("b:did_ftplugin") | finish | endif
|
||||||
|
|
||||||
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
|
let s:cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
let b:undo_ftplugin = "setlocal comments< commentstring< formatoptions<"
|
||||||
|
|
||||||
|
setlocal comments=:#
|
||||||
|
setlocal commentstring=#\ %s
|
||||||
|
|
||||||
|
setlocal formatoptions-=t formatoptions+=rol
|
||||||
|
|
||||||
|
let &cpo = s:cpo
|
||||||
|
unlet s:cpo
|
@ -3,242 +3,235 @@
|
|||||||
" Maintainer: Andis Sprinkis <andis@sprinkis.com>
|
" Maintainer: Andis Sprinkis <andis@sprinkis.com>
|
||||||
" Former Maintainer: Cameron Wright
|
" Former Maintainer: Cameron Wright
|
||||||
" URL: https://github.com/andis-sprinkis/lf-vim
|
" URL: https://github.com/andis-sprinkis/lf-vim
|
||||||
" Last Change: 28 March 2025
|
" Last Change: 5 Apr 2025
|
||||||
" 29 Mar 2025 by Vim Project (save and restore 'cpo' setting)
|
|
||||||
"
|
"
|
||||||
" The shell syntax highlighting is configurable. See $VIMRUNTIME/doc/syntax.txt
|
" The shell syntax highlighting is configurable. See $VIMRUNTIME/doc/syntax.txt
|
||||||
" lf version: 34
|
" lf version: 34
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax") | finish | endif
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let s:cpo = &cpo
|
let s:cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
let b:current_syntax = "lf"
|
let b:current_syntax = "lf"
|
||||||
|
|
||||||
"{{{ Comment Matching
|
"{{{ Comment Matching
|
||||||
syn match lfComment '#.*$'
|
syn match lfComment '#.*$'
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ String Matching
|
"{{{ String Matching
|
||||||
syn match lfString "'.*'"
|
syn match lfString "'.*'"
|
||||||
syn match lfString '".*"' contains=lfVar,lfSpecial
|
syn match lfString '".*"' contains=lfSpecial
|
||||||
"}}}
|
|
||||||
|
|
||||||
"{{{ Match lf Variables
|
|
||||||
syn match lfVar '\$f\|\$fx\|\$fs\|\$id'
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Keywords
|
"{{{ Keywords
|
||||||
syn keyword lfKeyword set setlocal cmd map cmap skipwhite
|
syn keyword lfKeyword set setlocal cmd map cmap skipwhite
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Options Keywords
|
"{{{ Options Keywords
|
||||||
syn keyword lfOptions
|
syn keyword lfOptions
|
||||||
\ anchorfind
|
\ anchorfind
|
||||||
\ autoquit
|
\ autoquit
|
||||||
\ borderfmt
|
\ borderfmt
|
||||||
\ bottom
|
\ bottom
|
||||||
\ calcdirsize
|
\ calcdirsize
|
||||||
\ cd
|
\ cd
|
||||||
\ cleaner
|
\ cleaner
|
||||||
\ clear
|
\ clear
|
||||||
\ clearmaps
|
\ clearmaps
|
||||||
\ cmd-capitalize-word
|
\ cmaps
|
||||||
\ cmd-complete
|
\ cmd-capitalize-word
|
||||||
\ cmd-delete
|
\ cmd-complete
|
||||||
\ cmd-delete-back
|
\ cmd-delete
|
||||||
\ cmd-delete-end
|
\ cmd-delete-back
|
||||||
\ cmd-delete-home
|
\ cmd-delete-end
|
||||||
\ cmd-delete-unix-word
|
\ cmd-delete-home
|
||||||
\ cmd-delete-word
|
\ cmd-delete-unix-word
|
||||||
\ cmd-delete-word-back
|
\ cmd-delete-word
|
||||||
\ cmd-end
|
\ cmd-delete-word-back
|
||||||
\ cmd-enter
|
\ cmd-end
|
||||||
\ cmd-escape
|
\ cmd-enter
|
||||||
\ cmd-history-next
|
\ cmd-escape
|
||||||
\ cmd-history-prev
|
\ cmd-history-next
|
||||||
\ cmd-home
|
\ cmd-history-prev
|
||||||
\ cmd-interrupt
|
\ cmd-home
|
||||||
\ cmd-left
|
\ cmd-interrupt
|
||||||
\ cmd-lowercase-word
|
\ cmd-left
|
||||||
\ cmd-menu-accept
|
\ cmd-lowercase-word
|
||||||
\ cmd-menu-complete
|
\ cmd-menu-accept
|
||||||
\ cmd-menu-complete-back
|
\ cmd-menu-complete
|
||||||
\ cmd-right
|
\ cmd-menu-complete-back
|
||||||
\ cmd-transpose
|
\ cmd-right
|
||||||
\ cmd-transpose-word
|
\ cmd-transpose
|
||||||
\ cmd-uppercase-word
|
\ cmd-transpose-word
|
||||||
\ cmd-word
|
\ cmd-uppercase-word
|
||||||
\ cmd-word-back
|
\ cmd-word
|
||||||
\ cmd-yank
|
\ cmd-word-back
|
||||||
\ copy
|
\ cmd-yank
|
||||||
\ copyfmt
|
\ cmds
|
||||||
\ cursoractivefmt
|
\ copy
|
||||||
\ cursorparentfmt
|
\ copyfmt
|
||||||
\ cursorpreviewfmt
|
\ cursoractivefmt
|
||||||
\ cut
|
\ cursorparentfmt
|
||||||
\ cutfmt
|
\ cursorpreviewfmt
|
||||||
\ delete
|
\ cut
|
||||||
\ dircache
|
\ cutfmt
|
||||||
\ dircounts
|
\ delete
|
||||||
\ dirfirst
|
\ dircache
|
||||||
\ dironly
|
\ dircounts
|
||||||
\ dirpreviews
|
\ dirfirst
|
||||||
\ down
|
\ dironly
|
||||||
\ draw
|
\ dirpreviews
|
||||||
\ drawbox
|
\ doc
|
||||||
\ dupfilefmt
|
\ down
|
||||||
\ echo
|
\ draw
|
||||||
\ echoerr
|
\ drawbox
|
||||||
\ echomsg
|
\ dupfilefmt
|
||||||
\ errorfmt
|
\ echo
|
||||||
\ filesep
|
\ echoerr
|
||||||
\ filter
|
\ echomsg
|
||||||
\ find
|
\ errorfmt
|
||||||
\ find-back
|
\ filesep
|
||||||
\ find-next
|
\ filter
|
||||||
\ find-prev
|
\ find
|
||||||
\ findlen
|
\ find-back
|
||||||
\ glob-select
|
\ find-next
|
||||||
\ glob-unselect
|
\ find-prev
|
||||||
\ globfilter
|
\ findlen
|
||||||
\ globsearch
|
\ glob-select
|
||||||
\ half-down
|
\ glob-unselect
|
||||||
\ half-up
|
\ globfilter
|
||||||
\ hidden
|
\ globsearch
|
||||||
\ hiddenfiles
|
\ half-down
|
||||||
\ high
|
\ half-up
|
||||||
\ history
|
\ hidden
|
||||||
\ icons
|
\ hiddenfiles
|
||||||
\ ifs
|
\ high
|
||||||
\ ignorecase
|
\ history
|
||||||
\ ignoredia
|
\ icons
|
||||||
\ incfilter
|
\ ifs
|
||||||
\ incsearch
|
\ ignorecase
|
||||||
\ info
|
\ ignoredia
|
||||||
\ infotimefmtnew
|
\ incfilter
|
||||||
\ infotimefmtold
|
\ incsearch
|
||||||
\ invert
|
\ info
|
||||||
\ invert-below
|
\ infotimefmtnew
|
||||||
\ jump-next
|
\ infotimefmtold
|
||||||
\ jump-prev
|
\ invert
|
||||||
\ load
|
\ invert-below
|
||||||
\ locale
|
\ jump-next
|
||||||
\ low
|
\ jump-prev
|
||||||
\ mark-load
|
\ load
|
||||||
\ mark-remove
|
\ locale
|
||||||
\ mark-save
|
\ low
|
||||||
\ middle
|
\ maps
|
||||||
\ mouse
|
\ mark-load
|
||||||
\ number
|
\ mark-remove
|
||||||
\ numberfmt
|
\ mark-save
|
||||||
\ on-cd
|
\ middle
|
||||||
\ on-focus-gained
|
\ mouse
|
||||||
\ on-focus-lost
|
\ number
|
||||||
\ on-init
|
\ numberfmt
|
||||||
\ on-quit
|
\ on-cd
|
||||||
\ on-redraw
|
\ on-focus-gained
|
||||||
\ on-select
|
\ on-focus-lost
|
||||||
\ open
|
\ on-init
|
||||||
\ page-down
|
\ on-quit
|
||||||
\ page-up
|
\ on-redraw
|
||||||
\ paste
|
\ on-select
|
||||||
\ period
|
\ open
|
||||||
\ pre-cd
|
\ page-down
|
||||||
\ preserve
|
\ page-up
|
||||||
\ preview
|
\ paste
|
||||||
\ previewer
|
\ period
|
||||||
\ promptfmt
|
\ pre-cd
|
||||||
\ push
|
\ preserve
|
||||||
\ quit
|
\ preview
|
||||||
\ ratios
|
\ previewer
|
||||||
\ read
|
\ promptfmt
|
||||||
\ redraw
|
\ push
|
||||||
\ relativenumber
|
\ quit
|
||||||
\ reload
|
\ ratios
|
||||||
\ rename
|
\ read
|
||||||
\ reverse
|
\ redraw
|
||||||
\ roundbox
|
\ relativenumber
|
||||||
\ rulerfmt
|
\ reload
|
||||||
\ scroll-down
|
\ rename
|
||||||
\ scroll-up
|
\ reverse
|
||||||
\ scrolloff
|
\ roundbox
|
||||||
\ search
|
\ rulerfmt
|
||||||
\ search-back
|
\ scroll-down
|
||||||
\ search-next
|
\ scroll-up
|
||||||
\ search-prev
|
\ scrolloff
|
||||||
\ select
|
\ search
|
||||||
\ selectfmt
|
\ search-back
|
||||||
\ selmode
|
\ search-next
|
||||||
\ setfilter
|
\ search-prev
|
||||||
\ shell
|
\ select
|
||||||
\ shell-async
|
\ selectfmt
|
||||||
\ shell-pipe
|
\ selmode
|
||||||
\ shell-wait
|
\ setfilter
|
||||||
\ shellflag
|
\ shell
|
||||||
\ shellopts
|
\ shell-async
|
||||||
\ showbinds
|
\ shell-pipe
|
||||||
\ sixel
|
\ shell-wait
|
||||||
\ smartcase
|
\ shellflag
|
||||||
\ smartdia
|
\ shellopts
|
||||||
\ sortby
|
\ showbinds
|
||||||
\ source
|
\ sixel
|
||||||
\ statfmt
|
\ smartcase
|
||||||
\ sync
|
\ smartdia
|
||||||
\ tabstop
|
\ sortby
|
||||||
\ tag
|
\ source
|
||||||
\ tag-toggle
|
\ statfmt
|
||||||
\ tagfmt
|
\ sync
|
||||||
\ tempmarks
|
\ tabstop
|
||||||
\ timefmt
|
\ tag
|
||||||
\ toggle
|
\ tag-toggle
|
||||||
\ top
|
\ tagfmt
|
||||||
\ truncatechar
|
\ tempmarks
|
||||||
\ truncatepct
|
\ timefmt
|
||||||
\ unselect
|
\ toggle
|
||||||
\ up
|
\ top
|
||||||
\ updir
|
\ truncatechar
|
||||||
\ waitmsg
|
\ truncatepct
|
||||||
\ watch
|
\ unselect
|
||||||
\ wrapscan
|
\ up
|
||||||
\ wrapscroll
|
\ updir
|
||||||
|
\ waitmsg
|
||||||
|
\ watch
|
||||||
|
\ wrapscan
|
||||||
|
\ wrapscroll
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Special Matching
|
"{{{ Special Matching
|
||||||
syn match lfSpecial '<.*>\|\\.'
|
syn match lfSpecial '\v\<[^>]+\>'
|
||||||
|
syn match lfSpecial '\v\\(["\\abfnrtv]|\o+)'
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Shell Script Matching for cmd
|
"{{{ Shell Script Matching for cmd
|
||||||
let s:shell_syntax = get(g:, 'lf_shell_syntax', "syntax/sh.vim")
|
let s:shell_syntax = get(g:, 'lf_shell_syntax', "syntax/sh.vim")
|
||||||
let s:shell_syntax = get(b:, 'lf_shell_syntax', s:shell_syntax)
|
let s:shell_syntax = get(b:, 'lf_shell_syntax', s:shell_syntax)
|
||||||
|
|
||||||
unlet b:current_syntax
|
unlet b:current_syntax
|
||||||
exe 'syn include @Shell '.s:shell_syntax
|
exe 'syn include @Shell '.s:shell_syntax
|
||||||
let b:current_syntax = "lf"
|
let b:current_syntax = "lf"
|
||||||
syn region lfIgnore start=".{{\n" end="^}}"
|
|
||||||
\ keepend contains=lfExternalShell,lfExternalPatch
|
syn region lfCommand matchgroup=lfCommandMarker start=' \zs:\ze' end='$' keepend transparent
|
||||||
syn match lfShell '\$[a-zA-Z].*$
|
syn region lfCommand matchgroup=lfCommandMarker start=' \zs:{{\ze' end='}}' keepend transparent
|
||||||
\\|:[a-zA-Z].*$
|
syn region lfShell matchgroup=lfShellMarker start=' \zs[$!%&]\ze' end='$' keepend contains=@Shell
|
||||||
\\|%[a-zA-Z].*$
|
syn region lfShell matchgroup=lfShellMarker start=' \zs[$!%&]{{\ze' end='}}' keepend contains=@Shell
|
||||||
\\|![a-zA-Z].*$
|
|
||||||
\\|&[a-zA-Z].*$'
|
|
||||||
\ transparent contains=@Shell,lfExternalPatch
|
|
||||||
syn match lfExternalShell "^.*$" transparent contained contains=@Shell
|
|
||||||
syn match lfExternalPatch "^\s*cmd\ .*\ .{{$\|^}}$" contained
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Link Highlighting
|
"{{{ Link Highlighting
|
||||||
hi def link lfComment Comment
|
hi def link lfComment Comment
|
||||||
hi def link lfVar Type
|
hi def link lfSpecial SpecialChar
|
||||||
hi def link lfSpecial Special
|
hi def link lfString String
|
||||||
hi def link lfString String
|
hi def link lfKeyword Statement
|
||||||
hi def link lfKeyword Statement
|
hi def link lfOptions Constant
|
||||||
hi def link lfOptions Constant
|
hi def link lfCommandMarker Special
|
||||||
hi def link lfConstant Constant
|
hi def link lfShellMarker Special
|
||||||
hi def link lfExternalShell Normal
|
|
||||||
hi def link lfExternalPatch Special
|
|
||||||
hi def link lfIgnore Special
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
let &cpo = s:cpo
|
let &cpo = s:cpo
|
||||||
unlet s:cpo
|
unlet s:cpo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user