Skip to content

Commit 0f146b7

Browse files
andis-sprinkischrisbra
authored andcommitted
patch 9.1.0778: filetype: lf config files are not recognized
Problem: filetype: lf config files are not recognized Solution: detect lfrc files as lf filetype, include a syntax script for lf files (Andis Spriņķis). References: - https://github.com/gokcehan/lf closes: #15859 Signed-off-by: Andis Spriņķis <spr.andis@protonmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent f64bafd commit 0f146b7

7 files changed

Lines changed: 262 additions & 1 deletion

File tree

.github/MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ runtime/syntax/kotlin.vim @udalov
494494
runtime/syntax/kdl.vim @imsnif @jiangyinzuo
495495
runtime/syntax/krl.vim @KnoP-01
496496
runtime/syntax/less.vim @genoma
497+
runtime/syntax/lf.vim @andis-sprinkis
497498
runtime/syntax/liquid.vim @tpope
498499
runtime/syntax/lua.vim @marcuscf
499500
runtime/syntax/lyrics.vim @ObserverOfTime

runtime/doc/syntax.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*syntax.txt* For Vim version 9.1. Last change: 2024 Oct 06
1+
*syntax.txt* For Vim version 9.1. Last change: 2024 Oct 13
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2223,6 +2223,20 @@ define the vim variable 'lace_case_insensitive' in your startup file: >
22232223
:let lace_case_insensitive=1
22242224
22252225
2226+
LF (LFRC) *lf.vim* *ft-lf-syntax* *g:lf_shell_syntax*
2227+
*b:lf_shell_syntax*
2228+
2229+
For the lf file manager configuration files (lfrc) the shell commands
2230+
syntax highlighting can be changed globally and per buffer by setting
2231+
a different 'include' command search pattern using these variables:
2232+
let g:lf_shell_syntax = "syntax/dosbatch.vim"
2233+
let b:lf_shell_syntax = "syntax/zsh.vim"
2234+
2235+
These variables are unset by default.
2236+
2237+
The default 'include' command search pattern is 'syntax/sh.vim'.
2238+
2239+
22262240
LEX *lex.vim* *ft-lex-syntax*
22272241

22282242
Lex uses brute-force synchronizing as the "^%%$" section delimiter

runtime/doc/tags

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6121,6 +6121,7 @@ b:changelog_name filetype.txt /*b:changelog_name*
61216121
b:clojure_syntax_keywords syntax.txt /*b:clojure_syntax_keywords*
61226122
b:clojure_syntax_without_core_keywords syntax.txt /*b:clojure_syntax_without_core_keywords*
61236123
b:current_syntax-variable syntax.txt /*b:current_syntax-variable*
6124+
b:lf_shell_syntax syntax.txt /*b:lf_shell_syntax*
61246125
b:netrw_lastfile pi_netrw.txt /*b:netrw_lastfile*
61256126
b:rust_cargo_avoid_whole_workspace ft_rust.txt /*b:rust_cargo_avoid_whole_workspace*
61266127
b:rust_cargo_check_all_features ft_rust.txt /*b:rust_cargo_check_all_features*
@@ -7331,6 +7332,7 @@ ft-json-syntax syntax.txt /*ft-json-syntax*
73317332
ft-ksh-syntax syntax.txt /*ft-ksh-syntax*
73327333
ft-lace-syntax syntax.txt /*ft-lace-syntax*
73337334
ft-lex-syntax syntax.txt /*ft-lex-syntax*
7335+
ft-lf-syntax syntax.txt /*ft-lf-syntax*
73347336
ft-lifelines-syntax syntax.txt /*ft-lifelines-syntax*
73357337
ft-lisp-syntax syntax.txt /*ft-lisp-syntax*
73367338
ft-lite-syntax syntax.txt /*ft-lite-syntax*
@@ -7581,6 +7583,7 @@ g:html_use_encoding syntax.txt /*g:html_use_encoding*
75817583
g:html_use_input_for_pc syntax.txt /*g:html_use_input_for_pc*
75827584
g:html_use_xhtml syntax.txt /*g:html_use_xhtml*
75837585
g:html_whole_filler syntax.txt /*g:html_whole_filler*
7586+
g:lf_shell_syntax syntax.txt /*g:lf_shell_syntax*
75847587
g:markdown_fenced_languages syntax.txt /*g:markdown_fenced_languages*
75857588
g:markdown_minlines syntax.txt /*g:markdown_minlines*
75867589
g:markdown_syntax_conceal syntax.txt /*g:markdown_syntax_conceal*
@@ -8556,6 +8559,7 @@ len() builtin.txt /*len()*
85568559
less various.txt /*less*
85578560
letter print.txt /*letter*
85588561
lex.vim syntax.txt /*lex.vim*
8562+
lf.vim syntax.txt /*lf.vim*
85598563
lhaskell.vim syntax.txt /*lhaskell.vim*
85608564
libcall() builtin.txt /*libcall()*
85618565
libcallnr() builtin.txt /*libcallnr()*

runtime/filetype.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,9 @@ au BufNewFile,BufRead *.lean setf lean
13151315
" Ledger
13161316
au BufRead,BufNewFile *.ldg,*.ledger,*.journal setf ledger
13171317

1318+
" lf configuration (lfrc)
1319+
au BufNewFile,BufRead lfrc setf lf
1320+
13181321
" Less
13191322
au BufNewFile,BufRead *.less setf less
13201323

runtime/syntax/lf.vim

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
" Vim syntax file
2+
" Language: lf file manager configuration file (lfrc)
3+
" Maintainer: Andis Sprinkis <andis@sprinkis.com>
4+
" Former Maintainer: Cameron Wright
5+
" Former URL: https://github.com/andis-sprinkis/lf-vim
6+
" Last Change: 13 October 2024
7+
"
8+
" The shell syntax highlighting is configurable. See $VIMRUNTIME/doc/syntax.txt
9+
" lf version: 32
10+
11+
if exists("b:current_syntax")
12+
finish
13+
endif
14+
15+
let b:current_syntax = "lf"
16+
17+
"{{{ Comment Matching
18+
syn match lfComment '#.*$'
19+
"}}}
20+
21+
"{{{ String Matching
22+
syn match lfString "'.*'"
23+
syn match lfString '".*"' contains=lfVar,lfSpecial
24+
"}}}
25+
26+
"{{{ Match lf Variables
27+
syn match lfVar '\$f\|\$fx\|\$fs\|\$id'
28+
"}}}
29+
30+
"{{{ Keywords
31+
syn keyword lfKeyword set setlocal cmd map cmap skipwhite
32+
"}}}
33+
34+
"{{{ Options Keywords
35+
syn keyword lfOptions
36+
\ quit
37+
\ up
38+
\ half-up
39+
\ page-up
40+
\ scroll-up
41+
\ down
42+
\ half-down
43+
\ page-down
44+
\ scroll-down
45+
\ updir
46+
\ open
47+
\ jump-next
48+
\ jump-prev
49+
\ top
50+
\ bottom
51+
\ high
52+
\ middle
53+
\ low
54+
\ toggle
55+
\ invert
56+
\ invert-below
57+
\ unselect
58+
\ glob-select
59+
\ glob-unselect
60+
\ calcdirsize
61+
\ clearmaps
62+
\ copy
63+
\ cut
64+
\ paste
65+
\ clear
66+
\ sync
67+
\ draw
68+
\ redraw
69+
\ load
70+
\ reload
71+
\ echo
72+
\ echomsg
73+
\ echoerr
74+
\ cd
75+
\ select
76+
\ delete
77+
\ rename
78+
\ source
79+
\ push
80+
\ read
81+
\ shell
82+
\ shell-pipe
83+
\ shell-wait
84+
\ shell-async
85+
\ find
86+
\ find-back
87+
\ find-next
88+
\ find-prev
89+
\ search
90+
\ search-back
91+
\ search-next
92+
\ search-prev
93+
\ filter
94+
\ setfilter
95+
\ mark-save
96+
\ mark-load
97+
\ mark-remove
98+
\ tag
99+
\ tag-toggle
100+
\ cmd-escape
101+
\ cmd-complete
102+
\ cmd-menu-complete
103+
\ cmd-menu-complete-back
104+
\ cmd-menu-accept
105+
\ cmd-enter
106+
\ cmd-interrupt
107+
\ cmd-history-next
108+
\ cmd-history-prev
109+
\ cmd-left
110+
\ cmd-right
111+
\ cmd-home
112+
\ cmd-end
113+
\ cmd-delete
114+
\ cmd-delete-back
115+
\ cmd-delete-home
116+
\ cmd-delete-end
117+
\ cmd-delete-unix-word
118+
\ cmd-yank
119+
\ cmd-transpose
120+
\ cmd-transpose-word
121+
\ cmd-word
122+
\ cmd-word-back
123+
\ cmd-delete-word
124+
\ cmd-delete-word-back
125+
\ cmd-capitalize-word
126+
\ cmd-uppercase-word
127+
\ cmd-lowercase-word
128+
\ anchorfind
129+
\ autoquit
130+
\ borderfmt
131+
\ cleaner
132+
\ copyfmt
133+
\ cursoractivefmt
134+
\ cursorparentfmt
135+
\ cursorpreviewfmt
136+
\ cutfmt
137+
\ dircache
138+
\ dircounts
139+
\ dirfirst
140+
\ dironly
141+
\ dirpreviews
142+
\ drawbox
143+
\ dupfilefmt
144+
\ errorfmt
145+
\ filesep
146+
\ findlen
147+
\ globfilter
148+
\ globsearch
149+
\ hidden
150+
\ hiddenfiles
151+
\ hidecursorinactive
152+
\ history
153+
\ icons
154+
\ ifs
155+
\ ignorecase
156+
\ ignoredia
157+
\ incfilter
158+
\ incsearch
159+
\ info
160+
\ infotimefmtnew
161+
\ infotimefmtold
162+
\ mouse
163+
\ number
164+
\ numberfmt
165+
\ period
166+
\ preserve
167+
\ preview
168+
\ previewer
169+
\ promptfmt
170+
\ ratios
171+
\ relativenumber
172+
\ reverse
173+
\ roundbox
174+
\ ruler
175+
\ rulerfmt
176+
\ scrolloff
177+
\ selectfmt
178+
\ selmode
179+
\ shell
180+
\ shellflag
181+
\ shellopts
182+
\ sixel
183+
\ smartcase
184+
\ smartdia
185+
\ sortby
186+
\ statfmt
187+
\ tabstop
188+
\ tagfmt
189+
\ tempmarks
190+
\ timefmt
191+
\ truncatechar
192+
\ truncatepct
193+
\ waitmsg
194+
\ wrapscan
195+
\ wrapscroll
196+
\ pre-cd
197+
\ on-cd
198+
\ on-select
199+
\ on-redraw
200+
\ on-quit
201+
"}}}
202+
203+
"{{{ Special Matching
204+
syn match lfSpecial '<.*>\|\\.'
205+
"}}}
206+
207+
"{{{ Shell Script Matching for cmd
208+
let s:shell_syntax = get(g:, 'lf_shell_syntax', "syntax/sh.vim")
209+
let s:shell_syntax = get(b:, 'lf_shell_syntax', s:shell_syntax)
210+
unlet b:current_syntax
211+
exe 'syn include @Shell '.s:shell_syntax
212+
let b:current_syntax = "lf"
213+
syn region lfIgnore start=".{{\n" end="^}}"
214+
\ keepend contains=lfExternalShell,lfExternalPatch
215+
syn match lfShell '\$[a-zA-Z].*$
216+
\\|:[a-zA-Z].*$
217+
\\|%[a-zA-Z].*$
218+
\\|![a-zA-Z].*$
219+
\\|&[a-zA-Z].*$'
220+
\ transparent contains=@Shell,lfExternalPatch
221+
syn match lfExternalShell "^.*$" transparent contained contains=@Shell
222+
syn match lfExternalPatch "^\s*cmd\ .*\ .{{$\|^}}$" contained
223+
"}}}
224+
225+
"{{{ Link Highlighting
226+
hi def link lfComment Comment
227+
hi def link lfVar Type
228+
hi def link lfSpecial Special
229+
hi def link lfString String
230+
hi def link lfKeyword Statement
231+
hi def link lfOptions Constant
232+
hi def link lfConstant Constant
233+
hi def link lfExternalShell Normal
234+
hi def link lfExternalPatch Special
235+
hi def link lfIgnore Special
236+
"}}}

src/testdir/test_filetype.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ def s:GetFilenameChecks(): dict<list<string>>
409409
ledger: ['file.ldg', 'file.ledger', 'file.journal'],
410410
less: ['file.less'],
411411
lex: ['file.lex', 'file.l', 'file.lxx', 'file.l++'],
412+
lf: ['lfrc'],
412413
lftp: ['lftp.conf', '.lftprc', 'anylftp/rc', 'lftp/rc', 'some-lftp/rc'],
413414
lhaskell: ['file.lhs'],
414415
libao: ['/etc/libao.conf', '/.libao', 'any/.libao', 'any/etc/libao.conf'],

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
778,
707709
/**/
708710
777,
709711
/**/

0 commit comments

Comments
 (0)