mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
vim-patch:7517a8c: 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: vim/vim#17078
7517a8cadf
Co-authored-by: Andis Spriņķis <andis@sprinkis.com>
This commit is contained in:
committed by
Christian Clason
parent
c73a827564
commit
ff2cbe8fac
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,15 +3,13 @@
|
||||
" Maintainer: Andis Sprinkis <andis@sprinkis.com>
|
||||
" Former Maintainer: Cameron Wright
|
||||
" URL: https://github.com/andis-sprinkis/lf-vim
|
||||
" Last Change: 28 March 2025
|
||||
" 29 Mar 2025 by Vim Project (save and restore 'cpo' setting)
|
||||
" Last Change: 5 Apr 2025
|
||||
"
|
||||
" The shell syntax highlighting is configurable. See $VIMRUNTIME/doc/syntax.txt
|
||||
" lf version: 34
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
if exists("b:current_syntax") | finish | endif
|
||||
|
||||
let s:cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
@ -23,11 +21,7 @@ syn match lfComment '#.*$'
|
||||
|
||||
"{{{ String Matching
|
||||
syn match lfString "'.*'"
|
||||
syn match lfString '".*"' contains=lfVar,lfSpecial
|
||||
"}}}
|
||||
|
||||
"{{{ Match lf Variables
|
||||
syn match lfVar '\$f\|\$fx\|\$fs\|\$id'
|
||||
syn match lfString '".*"' contains=lfSpecial
|
||||
"}}}
|
||||
|
||||
"{{{ Keywords
|
||||
@ -45,6 +39,7 @@ syn keyword lfOptions
|
||||
\ cleaner
|
||||
\ clear
|
||||
\ clearmaps
|
||||
\ cmaps
|
||||
\ cmd-capitalize-word
|
||||
\ cmd-complete
|
||||
\ cmd-delete
|
||||
@ -73,6 +68,7 @@ syn keyword lfOptions
|
||||
\ cmd-word
|
||||
\ cmd-word-back
|
||||
\ cmd-yank
|
||||
\ cmds
|
||||
\ copy
|
||||
\ copyfmt
|
||||
\ cursoractivefmt
|
||||
@ -86,6 +82,7 @@ syn keyword lfOptions
|
||||
\ dirfirst
|
||||
\ dironly
|
||||
\ dirpreviews
|
||||
\ doc
|
||||
\ down
|
||||
\ draw
|
||||
\ drawbox
|
||||
@ -127,6 +124,7 @@ syn keyword lfOptions
|
||||
\ load
|
||||
\ locale
|
||||
\ low
|
||||
\ maps
|
||||
\ mark-load
|
||||
\ mark-remove
|
||||
\ mark-save
|
||||
@ -207,38 +205,33 @@ syn keyword lfOptions
|
||||
"}}}
|
||||
|
||||
"{{{ Special Matching
|
||||
syn match lfSpecial '<.*>\|\\.'
|
||||
syn match lfSpecial '\v\<[^>]+\>'
|
||||
syn match lfSpecial '\v\\(["\\abfnrtv]|\o+)'
|
||||
"}}}
|
||||
|
||||
"{{{ Shell Script Matching for cmd
|
||||
let s:shell_syntax = get(g:, 'lf_shell_syntax', "syntax/sh.vim")
|
||||
let s:shell_syntax = get(b:, 'lf_shell_syntax', s:shell_syntax)
|
||||
|
||||
unlet b:current_syntax
|
||||
exe 'syn include @Shell '.s:shell_syntax
|
||||
let b:current_syntax = "lf"
|
||||
syn region lfIgnore start=".{{\n" end="^}}"
|
||||
\ keepend contains=lfExternalShell,lfExternalPatch
|
||||
syn match lfShell '\$[a-zA-Z].*$
|
||||
\\|:[a-zA-Z].*$
|
||||
\\|%[a-zA-Z].*$
|
||||
\\|![a-zA-Z].*$
|
||||
\\|&[a-zA-Z].*$'
|
||||
\ transparent contains=@Shell,lfExternalPatch
|
||||
syn match lfExternalShell "^.*$" transparent contained contains=@Shell
|
||||
syn match lfExternalPatch "^\s*cmd\ .*\ .{{$\|^}}$" contained
|
||||
|
||||
syn region lfCommand matchgroup=lfCommandMarker start=' \zs:\ze' end='$' keepend transparent
|
||||
syn region lfCommand matchgroup=lfCommandMarker start=' \zs:{{\ze' end='}}' keepend transparent
|
||||
syn region lfShell matchgroup=lfShellMarker start=' \zs[$!%&]\ze' end='$' keepend contains=@Shell
|
||||
syn region lfShell matchgroup=lfShellMarker start=' \zs[$!%&]{{\ze' end='}}' keepend contains=@Shell
|
||||
"}}}
|
||||
|
||||
"{{{ Link Highlighting
|
||||
hi def link lfComment Comment
|
||||
hi def link lfVar Type
|
||||
hi def link lfSpecial Special
|
||||
hi def link lfSpecial SpecialChar
|
||||
hi def link lfString String
|
||||
hi def link lfKeyword Statement
|
||||
hi def link lfOptions Constant
|
||||
hi def link lfConstant Constant
|
||||
hi def link lfExternalShell Normal
|
||||
hi def link lfExternalPatch Special
|
||||
hi def link lfIgnore Special
|
||||
hi def link lfCommandMarker Special
|
||||
hi def link lfShellMarker Special
|
||||
"}}}
|
||||
|
||||
let &cpo = s:cpo
|
||||
unlet s:cpo
|
||||
|
Reference in New Issue
Block a user