aboutsummaryrefslogtreecommitdiff
path: root/runtime/indent
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2025-01-20 22:45:47 +0100
committerChristian Clason <ch.clason+github@icloud.com>2025-01-23 09:42:20 +0100
commit8634bd46b26f28fa26950128b0cc585560bd6a9a (patch)
treea02b5a77a93183c56b7f51ea8edf95aa98eb952b /runtime/indent
parent28998e1f8a9cdca27ada7030757b7a47e99ce5b6 (diff)
downloadrneovim-8634bd46b26f28fa26950128b0cc585560bd6a9a.tar.gz
rneovim-8634bd46b26f28fa26950128b0cc585560bd6a9a.tar.bz2
rneovim-8634bd46b26f28fa26950128b0cc585560bd6a9a.zip
vim-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: vim/vim#16466 https://github.com/vim/vim/commit/72755b3c8e91ec90447969b736f080e0de36003d Co-authored-by: Peter Benjamin <petermbenjamin@gmail.com>
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/just.vim51
1 files changed, 51 insertions, 0 deletions
diff --git a/runtime/indent/just.vim b/runtime/indent/just.vim
new file mode 100644
index 0000000000..d7f82b118f
--- /dev/null
+++ b/runtime/indent/just.vim
@@ -0,0 +1,51 @@
+" Vim indent file
+" Language: Justfile
+" Maintainer: Peter Benjamin <@pbnj>
+" Last Change: 2025 Jan 19
+" Credits: The original author, Noah Bogart <https://github.com/NoahTheDuke/vim-just/>
+
+" Only load this indent file when no other was loaded yet.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetJustfileIndent()
+setlocal indentkeys=0},0),!^F,o,O,0=''',0=\"\"\"
+
+let b:undo_indent = "setlocal indentexpr< indentkeys<"
+
+if exists("*GetJustfileIndent")
+ finish
+endif
+
+function GetJustfileIndent()
+ if v:lnum < 2
+ return 0
+ endif
+
+ let prev_line = getline(v:lnum - 1)
+ let last_indent = indent(v:lnum - 1)
+
+ if getline(v:lnum) =~ "\\v^\\s+%([})]|'''$|\"\"\"$)"
+ return last_indent - shiftwidth()
+ elseif prev_line =~ '\V#'
+ return last_indent
+ elseif prev_line =~ "\\v%([:{(]|^.*\\S.*%([^']'''|[^\"]\"\"\"))\\s*$"
+ return last_indent + shiftwidth()
+ elseif prev_line =~ '\\$'
+ if v:lnum == 2 || getline(v:lnum - 2) !~ '\\$'
+ if prev_line =~ '\v:\=@!'
+ return last_indent + shiftwidth() + shiftwidth()
+ else
+ return last_indent + shiftwidth()
+ endif
+ endif
+ elseif v:lnum > 2 && getline(v:lnum - 2) =~ '\\$'
+ return last_indent - shiftwidth()
+ elseif prev_line =~ '\v:\s*%(\h|\()' && prev_line !~ '\V:='
+ return last_indent + shiftwidth()
+ endif
+
+ return last_indent
+endfunction