Skip to content

Commit 72755b3

Browse files
pbnjchrisbra
authored andcommitted
patch 9.1.1042: filetype: just files are not recognized
Problem: filetype: just files are not recognized Solution: adjust filetype detection pattern, detect just shebang line, include just ftplugin, indent and syntax plugin (Peter Benjamin) closes: #16466 Signed-off-by: Peter Benjamin <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent c273f1a commit 72755b3

File tree

8 files changed

+486
-3
lines changed

8 files changed

+486
-3
lines changed

.github/MAINTAINERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ runtime/ftplugin/json.vim @dbarnett
208208
runtime/ftplugin/json5.vim @dkearns
209209
runtime/ftplugin/jsonc.vim @izhakjakov
210210
runtime/ftplugin/julia.vim @carlobaldassi
211+
runtime/ftplugin/just.vim @pbnj
211212
runtime/ftplugin/jq.vim @vito-c
212213
runtime/ftplugin/kconfig.vim @chrisbra
213214
runtime/ftplugin/kdl.vim @imsnif @jiangyinzuo
@@ -354,6 +355,7 @@ runtime/indent/javascript.vim @bounceme
354355
runtime/indent/json.vim @elzr
355356
runtime/indent/jsonc.vim @izhakjakov
356357
runtime/indent/julia.vim @carlobaldassi
358+
runtime/indent/just.vim @pbnj
357359
runtime/indent/kdl.vim @imsnif @jiangyinzuo
358360
runtime/indent/kotlin.vim @udalov
359361
runtime/indent/krl.vim @KnoP-01
@@ -512,6 +514,7 @@ runtime/syntax/jjdescription.vim @gpanders
512514
runtime/syntax/json.vim @vito-c
513515
runtime/syntax/jsonc.vim @izhakjakov
514516
runtime/syntax/julia.vim @carlobaldassi
517+
runtime/syntax/just.vim @pbnj
515518
runtime/syntax/jq.vim @vito-c
516519
runtime/syntax/karel.vim @kirillmorozov
517520
runtime/syntax/kconfig.vim @chrisbra

runtime/autoload/dist/script.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ vim9script
44
# Invoked from "scripts.vim" in 'runtimepath'
55
#
66
# Maintainer: The Vim Project <https://github.com/vim/vim>
7-
# Last Change: 2023 Aug 10
7+
# Last Change: 2025 Jan 20
88
# Former Maintainer: Bram Moolenaar <[email protected]>
99

1010
export def DetectFiletype()
@@ -133,6 +133,9 @@ export def Exe2filetype(name: string, line1: string): string
133133
elseif name =~ 'node\(js\)\=\>\|js\>' || name =~ 'rhino\>'
134134
return 'javascript'
135135

136+
elseif name =~# 'just'
137+
return 'just'
138+
136139
# BC calculator
137140
elseif name =~ '^bc\>'
138141
return 'bc'

runtime/filetype.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim support file to detect file types
22
"
33
" Maintainer: The Vim Project <https://github.com/vim/vim>
4-
" Last Change: 2025 Jan 15
4+
" Last Change: 2025 Jan 20
55
" Former Maintainer: Bram Moolenaar <[email protected]>
66

77
" Listen very carefully, I will say this only once
@@ -1292,7 +1292,7 @@ au BufNewFile,BufRead *.jsonnet,*.libsonnet setf jsonnet
12921292
au BufNewFile,BufRead *.jl setf julia
12931293

12941294
" Just
1295-
au BufNewFile,BufRead [jJ]ustfile,.justfile,*.just setf just
1295+
au BufNewFile,BufRead \c{,*.}justfile,\c*.just setf just
12961296

12971297
" KAREL
12981298
au BufNewFile,BufRead *.kl setf karel

runtime/ftplugin/just.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
" Vim ftplugin file
2+
" Language: Justfile
3+
" Maintainer: Peter Benjamin <@pbnj>
4+
" Last Change: 2025 Jan 19
5+
" Credits: The original author, Noah Bogart <https://github.com/NoahTheDuke/vim-just/>
6+
7+
" Only do this when not done yet for this buffer
8+
if exists("b:did_ftplugin")
9+
finish
10+
endif
11+
let b:did_ftplugin = 1
12+
13+
setlocal iskeyword+=-
14+
setlocal comments=n:#
15+
setlocal commentstring=#\ %s
16+
17+
let b:undo_ftplugin = "setlocal iskeyword< comments< commentstring<"

runtime/indent/just.vim

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
" Vim indent file
2+
" Language: Justfile
3+
" Maintainer: Peter Benjamin <@pbnj>
4+
" Last Change: 2025 Jan 19
5+
" Credits: The original author, Noah Bogart <https://github.com/NoahTheDuke/vim-just/>
6+
7+
" Only load this indent file when no other was loaded yet.
8+
if exists("b:did_indent")
9+
finish
10+
endif
11+
let b:did_indent = 1
12+
13+
setlocal indentexpr=GetJustfileIndent()
14+
setlocal indentkeys=0},0),!^F,o,O,0=''',0=\"\"\"
15+
16+
let b:undo_indent = "setlocal indentexpr< indentkeys<"
17+
18+
if exists("*GetJustfileIndent")
19+
finish
20+
endif
21+
22+
function GetJustfileIndent()
23+
if v:lnum < 2
24+
return 0
25+
endif
26+
27+
let prev_line = getline(v:lnum - 1)
28+
let last_indent = indent(v:lnum - 1)
29+
30+
if getline(v:lnum) =~ "\\v^\\s+%([})]|'''$|\"\"\"$)"
31+
return last_indent - shiftwidth()
32+
elseif prev_line =~ '\V#'
33+
return last_indent
34+
elseif prev_line =~ "\\v%([:{(]|^.*\\S.*%([^']'''|[^\"]\"\"\"))\\s*$"
35+
return last_indent + shiftwidth()
36+
elseif prev_line =~ '\\$'
37+
if v:lnum == 2 || getline(v:lnum - 2) !~ '\\$'
38+
if prev_line =~ '\v:\=@!'
39+
return last_indent + shiftwidth() + shiftwidth()
40+
else
41+
return last_indent + shiftwidth()
42+
endif
43+
endif
44+
elseif v:lnum > 2 && getline(v:lnum - 2) =~ '\\$'
45+
return last_indent - shiftwidth()
46+
elseif prev_line =~ '\v:\s*%(\h|\()' && prev_line !~ '\V:='
47+
return last_indent + shiftwidth()
48+
endif
49+
50+
return last_indent
51+
endfunction

0 commit comments

Comments
 (0)