Skip to content

Commit 6505dc6

Browse files
dkearnschrisbra
authored andcommitted
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: #18208 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent efb913a commit 6505dc6

4 files changed

Lines changed: 786 additions & 6 deletions

File tree

.github/MAINTAINERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ runtime/ftplugin/nginx.vim @chr4
239239
runtime/ftplugin/nim.vim @ribru17
240240
runtime/ftplugin/nroff.vim @averms
241241
runtime/ftplugin/nsis.vim @k-takata
242-
runtime/ftplugin/nu.vim @mrcjkb
242+
runtime/ftplugin/nu.vim @elkasztano
243243
runtime/ftplugin/octave.vim @dkearns
244244
runtime/ftplugin/ondir.vim @jparise
245245
runtime/ftplugin/opencl.vim @Freed-Wu
@@ -380,6 +380,7 @@ runtime/indent/mma.vim @dkearns
380380
runtime/indent/mojo.vim @ribru17
381381
runtime/indent/nginx.vim @chr4
382382
runtime/indent/nsis.vim @k-takata
383+
runtime/indent/nu.vim @elkasztano
383384
runtime/indent/occam.vim @dkearns
384385
runtime/indent/perl.vim @petdance
385386
runtime/indent/php.vim @2072
@@ -568,6 +569,7 @@ runtime/syntax/ninja.vim @nico
568569
runtime/syntax/nix.vim @equill
569570
runtime/syntax/nroff.vim @jmarshall
570571
runtime/syntax/nsis.vim @k-takata
572+
runtime/syntax/nu.vim @elkasztano
571573
runtime/syntax/odin.vim @habamax
572574
runtime/syntax/omnimark.vim @kennypete
573575
runtime/syntax/ondir.vim @jparise

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 <marc@jakobi.dev>
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)