summaryrefslogtreecommitdiffstats
path: root/runtime/autoload
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--runtime/autoload/dist/ft.vim24
-rw-r--r--runtime/autoload/netrw.vim7
2 files changed, 28 insertions, 3 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 1462830..4e7d517 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -10,7 +10,9 @@ vim9script
# faster.
export def Check_inp()
- if getline(1) =~ '^\*'
+ if getline(1) =~ '%%'
+ setf tex
+ elseif getline(1) =~ '^\*'
setf abaqus
else
var n = 1
@@ -280,6 +282,10 @@ export def DtraceCheck()
enddef
export def FTdef()
+ # LaTeX def files are usually generated by docstrip, which will output '%%' in first line
+ if getline(1) =~ '%%'
+ setf tex
+ endif
if get(g:, "filetype_def", "") == "modula2" || IsModula2()
SetFiletypeModula2()
return
@@ -1292,5 +1298,21 @@ export def FTvba()
endif
enddef
+export def Detect_UCI_statements(): bool
+ # Match a config or package statement at the start of the line.
+ const config_or_package_statement = '^\s*\(\(c\|config\)\|\(p\|package\)\)\s\+\S'
+ # Match a line that is either all blank or blank followed by a comment
+ const comment_or_blank = '^\s*\(#.*\)\?$'
+
+ # Return true iff the file has a config or package statement near the
+ # top of the file and all preceding lines were comments or blank.
+ return getline(1) =~# config_or_package_statement
+ \ || getline(1) =~# comment_or_blank
+ \ && ( getline(2) =~# config_or_package_statement
+ \ || getline(2) =~# comment_or_blank
+ \ && getline(3) =~# config_or_package_statement
+ \ )
+enddef
+
# Uncomment this line to check for compilation errors early
# defcompile
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index 2206c21..e2152b0 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -8,6 +8,7 @@
" 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a)
" 2024 Feb 19 by Vim Project: (announce adoption)
" 2024 Feb 29 by Vim Project: handle symlinks in tree mode correctly
+" 2024 Apr 03 by Vim Project: detect filetypes for remote edited files
" Former Maintainer: Charles E Campbell
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
@@ -1803,7 +1804,9 @@ fun! s:NetrwOptionsRestore(vt)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
if !exists("{a:vt}netrw_optionsave")
" call Decho("case ".a:vt."netrw_optionsave : doesn't exist",'~'.expand("<slnum>"))
- if filereadable(expand("%"))
+
+ " filereadable() returns zero for remote files (e.g. scp://localhost//etc/fstab)
+ if filereadable(expand("%")) || expand("%") =~# '^\w\+://\f\+/'
" call Decho("..doing filetype detect anyway")
filetype detect
" call Decho("..settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>"))
@@ -2727,7 +2730,7 @@ fun! netrw#NetWrite(...) range
let url= g:netrw_choice
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_put_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(url,1) )
elseif !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd.">".",16)
+ call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd.">",16)
endif
".........................................