Skip to content

Commit 6b13f5f

Browse files
zeertzjqdkearns
authored andcommitted
vim-patch:6505dc6: runtime(nu): Add new Nushell runtime files
See: https://github.com/elkasztano/nushell-syntax-vim Thanks to Pete Cruz (@Petesta) for promoting this addition. closes: vim/vim#18208 vim/vim@6505dc6 Co-authored-by: Doug Kearns <[email protected]>
1 parent 3eacfbe commit 6b13f5f

File tree

3 files changed

+783
-5
lines changed

3 files changed

+783
-5
lines changed

runtime/ftplugin/nu.vim

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
" Vim filetype plugin
2-
" Language: Nu
3-
" Maintainer: Marc Jakobi <[email protected]>
4-
" Last Change: 2024 Aug 31
2+
" Language: Nushell
3+
" Maintainer: El Kasztano
4+
" URL: https://github.com/elkasztano/nushell-syntax-vim
5+
" License: MIT <https://opensource.org/license/mit>
6+
" Last Change: 2025 Sep 05
57

6-
if exists('b:did_ftplugin')
8+
if exists("b:did_ftplugin")
79
finish
810
endif
911
let b:did_ftplugin = 1
1012

1113
setlocal commentstring=#\ %s
14+
setlocal comments-=://
15+
setlocal formatoptions=tcroql
1216

13-
let b:undo_ftplugin = 'setl com<'
17+
let b:undo_ftplugin = "setl fo< cms< com<"

runtime/indent/nu.vim

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
" Vim indent file
2+
" Language: Nushell
3+
" Maintainer: El Kasztano
4+
" URL: https://github.com/elkasztano/nushell-syntax-vim
5+
" License: MIT <https://opensource.org/license/mit>
6+
" Last Change: 2025 Sep 05
7+
8+
" Only load if no other indent file is loaded
9+
if exists("b:did_indent")
10+
finish
11+
endif
12+
let b:did_indent = 1
13+
14+
setlocal cindent
15+
setlocal cinoptions=L0,(s,Ws,J1,j1,+0,f5,m1,i0
16+
setlocal cinkeys=0{,0},!^F,o,O,0[,0],0),0#
17+
18+
setlocal autoindent
19+
setlocal indentkeys=0{,0},!^F,o,O,0[,0],0),0#
20+
21+
setlocal shiftwidth=2
22+
setlocal softtabstop=2
23+
setlocal expandtab
24+
25+
setlocal indentexpr=GetNuIndent(v:lnum)
26+
27+
let b:undo_indent = "setl ai< cin< cink< cino< et< inde< indk< sts< sw<"
28+
29+
" only define once
30+
if exists("*GetNuIndent")
31+
finish
32+
endif
33+
34+
let s:save_cpo = &cpo
35+
set cpo&vim
36+
37+
function GetNuIndent(lnum)
38+
let prevlnum = prevnonblank(v:lnum - 1) "get number of last non blank line
39+
let line = getline(a:lnum)
40+
let synname = synIDattr(synID(a:lnum, 1, 1), "name")
41+
if (synname == "nuString") || (synname == "nuComment")
42+
return -1
43+
endif
44+
if getline(prevlnum) =~ '\%(^.*[$\|^.*[\s*#.*$\)'
45+
return (prevlnum > 0) * indent(prevlnum) + shiftwidth()
46+
endif
47+
if getline(v:lnum) =~ "^\s*]\>"
48+
return (prevlnum > 0) * indent(prevlnum) - shiftwidth()
49+
endif
50+
return cindent(a:lnum)
51+
endfunction
52+
53+
let &cpo = s:save_cpo
54+
unlet s:save_cpo

0 commit comments

Comments
 (0)