aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/dist/ft.vim17
-rw-r--r--runtime/filetype.vim5
-rw-r--r--runtime/lua/vim/filetype.lua3
-rw-r--r--src/nvim/ex_cmds2.c6
-rw-r--r--src/nvim/testdir/test_cdo.vim45
-rw-r--r--src/nvim/testdir/test_filetype.vim49
6 files changed, 108 insertions, 17 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index c52def1051..959f4be896 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -899,6 +899,23 @@ func dist#ft#FTtf()
setf tf
endfunc
+" Determine if a *.src file is Kuka Robot Language
+func dist#ft#FTsrc()
+ if exists("g:filetype_src")
+ exe "setf " .. g:filetype_src
+ elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|\%(global\s\+\)\?def\>\)'
+ setf krl
+ endif
+endfunc
+
+" Determine if a *.dat file is Kuka Robot Language
+func dist#ft#FTdat()
+ if exists("g:filetype_dat")
+ exe "setf " .. g:filetype_dat
+ elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|defdat\>\)'
+ setf krl
+ endif
+endfunc
" Restore 'cpoptions'
let &cpo = s:cpo_save
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 2f4b03606c..d7a3ec182f 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -947,6 +947,11 @@ au BufNewFile,BufRead *.jl setf julia
" Kixtart
au BufNewFile,BufRead *.kix setf kix
+" Kuka Robot Language
+au BufNewFile,BufRead *.src\c call dist#ft#FTsrc()
+au BufNewFile,BufRead *.dat\c call dist#ft#FTdat()
+au BufNewFile,BufRead *.sub\c setf krl
+
" Kimwitu[++]
au BufNewFile,BufRead *.k setf kwt
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index 65edaed530..0466057d72 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -1427,6 +1427,9 @@ local pattern = {
return "git"
end
end,
+ [".*%.[Dd][Aa][Tt]"] = function() vim.fn["dist#ft#FTdat"]() end,
+ [".*%.[Ss][Rr][Cc]"] = function() vim.fn["dist#ft#FTsrc"]() end,
+ [".*%.[Ss][Uu][Bb]"] = "krl",
-- Neovim only
[".*/queries/.*%.scm"] = "query", -- tree-sitter queries
-- END PATTERN
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index fe1dec7298..ac1d760bce 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -1470,7 +1470,13 @@ void ex_listdo(exarg_T *eap)
size_t qf_idx = qf_get_cur_idx(eap);
+ // Clear 'shm' to avoid that the file message overwrites
+ // any output from the command.
+ p_shm_save = vim_strsave(p_shm);
+ set_option_value("shm", 0L, "", 0);
ex_cnext(eap);
+ set_option_value("shm", 0L, (char *)p_shm_save, 0);
+ xfree(p_shm_save);
// If jumping to the next quickfix entry fails, quit here.
if (qf_get_cur_idx(eap) == qf_idx) {
diff --git a/src/nvim/testdir/test_cdo.vim b/src/nvim/testdir/test_cdo.vim
index aa2e4f1a8c..dbed7df4ac 100644
--- a/src/nvim/testdir/test_cdo.vim
+++ b/src/nvim/testdir/test_cdo.vim
@@ -1,30 +1,29 @@
" Tests for the :cdo, :cfdo, :ldo and :lfdo commands
-if !has('quickfix')
- throw 'Skipped: quickfix feature missing'
-endif
+source check.vim
+CheckFeature quickfix
" Create the files used by the tests
-function SetUp()
+func SetUp()
call writefile(["Line1", "Line2", "Line3"], 'Xtestfile1')
call writefile(["Line1", "Line2", "Line3"], 'Xtestfile2')
call writefile(["Line1", "Line2", "Line3"], 'Xtestfile3')
-endfunction
+endfunc
" Remove the files used by the tests
-function TearDown()
+func TearDown()
call delete('Xtestfile1')
call delete('Xtestfile2')
call delete('Xtestfile3')
-endfunction
+endfunc
" Returns the current line in '<filename> <linenum>L <column>C' format
-function GetRuler()
+func GetRuler()
return expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C'
-endfunction
+endfunc
" Tests for the :cdo and :ldo commands
-function XdoTests(cchar)
+func XdoTests(cchar)
enew
" Shortcuts for calling the cdo and ldo commands
@@ -133,10 +132,10 @@ function XdoTests(cchar)
exe XdoCmd
call assert_equal(['Xtestfile3 3L 1C'], l)
-endfunction
+endfunc
" Tests for the :cfdo and :lfdo commands
-function XfdoTests(cchar)
+func XfdoTests(cchar)
enew
" Shortcuts for calling the cfdo and lfdo commands
@@ -190,16 +189,28 @@ function XfdoTests(cchar)
exe XfdoCmd
call assert_equal(['Xtestfile2 2L 5C'], l)
-endfunction
+endfunc
" Tests for cdo and cfdo
-function Test_cdo()
+func Test_cdo()
call XdoTests('c')
call XfdoTests('c')
-endfunction
+endfunc
" Tests for ldo and lfdo
-function Test_ldo()
+func Test_ldo()
call XdoTests('l')
call XfdoTests('l')
-endfunction
+endfunc
+
+" Test for making 'shm' doesn't interfere with the output.
+func Test_cdo_print()
+ enew | only!
+ cgetexpr ["Xtestfile1:1:Line1", "Xtestfile2:1:Line1", "Xtestfile3:1:Line1"]
+ cdo print
+ call assert_equal('Line1', Screenline(&lines))
+ call assert_equal('Line1', Screenline(&lines - 3))
+ call assert_equal('Line1', Screenline(&lines - 6))
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 720c003ace..a31ff50a48 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -290,6 +290,7 @@ let s:filename_checks = {
\ 'kivy': ['file.kv'],
\ 'kix': ['file.kix'],
\ 'kotlin': ['file.kt', 'file.ktm', 'file.kts'],
+ \ 'krl': ['file.sub', 'file.Sub', 'file.SUB'],
\ 'kscript': ['file.ks'],
\ 'kwt': ['file.k'],
\ 'lace': ['file.ace', 'file.ACE'],
@@ -842,6 +843,30 @@ func Test_d_file()
filetype off
endfunc
+func Test_dat_file()
+ filetype on
+
+ call writefile(['&ACCESS'], 'datfile.dat')
+ split datfile.dat
+ call assert_equal('krl', &filetype)
+ bwipe!
+ call delete('datfile.dat')
+
+ call writefile([' DEFDAT datfile'], 'datfile.Dat')
+ split datfile.Dat
+ call assert_equal('krl', &filetype)
+ bwipe!
+ call delete('datfile.Dat')
+
+ call writefile(['', 'defdat datfile'], 'datfile.DAT')
+ split datfile.DAT
+ call assert_equal('krl', &filetype)
+ bwipe!
+ call delete('datfile.DAT')
+
+ filetype off
+endfunc
+
func Test_dep3patch_file()
filetype on
@@ -1284,6 +1309,30 @@ func Test_pp_file()
filetype off
endfunc
+func Test_src_file()
+ filetype on
+
+ call writefile(['&ACCESS'], 'srcfile.src')
+ split srcfile.src
+ call assert_equal('krl', &filetype)
+ bwipe!
+ call delete('srcfile.src')
+
+ call writefile([' DEF srcfile()'], 'srcfile.Src')
+ split srcfile.Src
+ call assert_equal('krl', &filetype)
+ bwipe!
+ call delete('srcfile.Src')
+
+ call writefile(['', 'global def srcfile()'], 'srcfile.SRC')
+ split srcfile.SRC
+ call assert_equal('krl', &filetype)
+ bwipe!
+ call delete('srcfile.SRC')
+
+ filetype off
+endfunc
+
func Test_tex_file()
filetype on