view runtime/ftplugin/context.vim @ 34134:8ae680be2a51

runtime(ftplugin): Use "*" browsefilter pattern to match "All Files" Commit: https://github.com/vim/vim/commit/93197fde0f1db09b1e495cf3eb14a8f42c318b80 Author: Doug Kearns <dougkearns@gmail.com> Date: Sun Jan 14 20:59:02 2024 +0100 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files" Problem: The "*.*" browsefilter pattern only matches all files on Windows (Daryl Lee) Solution: Use "*" to filter on all platforms but keep "*.*" as the label text on Windows. (Fixes #12685, Doug Kearns) The *.* browsefilter pattern used to match "All Files" on Windows is a legacy of the DOS 8.3 filename wildcard matching algorithm. For reasons of backward compatibility this still works on Windows to match all files, even those without an extension. However, this pattern only matches filenames containing a dot on other platforms. This often makes files without an extension difficult to access from the file dialog, e.g., "Makefile" On Windows it is still standard practice to use "*.*" for the filter label so ftplugins should use "All Files (*.*)" on Windows and "All Files (*)" on other platforms. This matches Vim's default browsefilter values. This commit also normalises the browsefilter conditional test to check for the Win32 and GTK GUI features and an unset b:browsefilter. closes: #12759 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 14 Jan 2024 21:15:03 +0100
parents d81556766132
children a3244333f8c4
line wrap: on
line source

vim9script

# Vim filetype plugin file
# Language:           ConTeXt typesetting engine
# Maintainer:         Nicola Vitacolonna <nvitacolonna@gmail.com>
# Former Maintainers: Nikolai Weibull <now@bitwi.se>
# Latest Revision:    2023 Dec 26

if exists("b:did_ftplugin")
  finish
endif

import autoload '../autoload/context.vim'

b:did_ftplugin = 1

if !exists('current_compiler')
  compiler context
endif

b:undo_ftplugin = "setl com< cms< def< inc< sua< fo< ofu<"

setlocal comments=b:%D,b:%C,b:%M,:%
setlocal commentstring=%\ %s
setlocal formatoptions+=tjcroql2
setlocal omnifunc=context.Complete
setlocal suffixesadd=.tex,.mkxl,.mkvi,.mkiv,.mkii

&l:define = '\\\%([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\='
..          'def\|\\font\|\\\%(future\)\=let'
..          '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
..          '\|fam\|insert\|if\)'

&l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)'

if exists("g:loaded_matchit") && !exists("b:match_words")
  b:match_ignorecase = 0
  b:match_skip = 'r:\\\@<!\%(\\\\\)*%'
  b:match_words = '(:),\[:],{:},\\(:\\),\\\[:\\],\\start\(\a\+\):\\stop\1'
  b:undo_ftplugin ..= "| unlet! b:match_ignorecase b:match_words b:match_skip"
endif

if !get(g:, 'no_context_maps', 0) && !get(g:, 'no_plugin_maps', 0)
  const context_regex = {
    'beginsection': '\\\%(start\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>',
    'endsection':   '\\\%(stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>',
    'beginblock':   '\\\%(start\|setup\|define\)',
    'endblock':     '\\\%(stop\|setup\|define\)',
    }

  def UndoMap(mapping: string, modes: string)
    for mode in modes
      b:undo_ftplugin ..= printf(" | silent! execute '%sunmap <buffer> %s'", mode, mapping)
    endfor
  enddef

  def MoveAround(count: number, what: string, flags: string)
    search(context_regex[what], flags .. 's')  # 's' sets previous context mark
    var i = 2
    while i <= count
      search(context_regex[what], flags)
      i += 1
    endwhile
  enddef

  # Macros to move around
  nnoremap <silent><buffer> [[ <scriptcmd>MoveAround(v:count1, "beginsection", "bW")<cr>
  vnoremap <silent><buffer> [[ <scriptcmd>MoveAround(v:count1, "beginsection", "bW")<cr>
  nnoremap <silent><buffer> ]] <scriptcmd>MoveAround(v:count1, "beginsection", "W") <cr>
  vnoremap <silent><buffer> ]] <scriptcmd>MoveAround(v:count1, "beginsection", "W") <cr>
  nnoremap <silent><buffer> [] <scriptcmd>MoveAround(v:count1, "endsection",   "bW")<cr>
  vnoremap <silent><buffer> [] <scriptcmd>MoveAround(v:count1, "endsection",   "bW")<cr>
  nnoremap <silent><buffer> ][ <scriptcmd>MoveAround(v:count1, "endsection",   "W") <cr>
  vnoremap <silent><buffer> ][ <scriptcmd>MoveAround(v:count1, "endsection",   "W") <cr>
  nnoremap <silent><buffer> [{ <scriptcmd>MoveAround(v:count1, "beginblock",   "bW")<cr>
  vnoremap <silent><buffer> [{ <scriptcmd>MoveAround(v:count1, "beginblock",   "bW")<cr>
  nnoremap <silent><buffer> ]} <scriptcmd>MoveAround(v:count1, "endblock",     "W") <cr>
  vnoremap <silent><buffer> ]} <scriptcmd>MoveAround(v:count1, "endblock",     "W") <cr>

  for mapping in ['[[', ']]', '[]', '][', '[{', ']}']
    UndoMap(mapping, 'nv')
  endfor

  # Other useful mappings
  const tp_regex = '?^$\|^\s*\\\(item\|start\|stop\|blank\|\%(sub\)*section\|chapter\|\%(sub\)*subject\|title\|part\)'

  def TeXPar()
    cursor(search(tp_regex, 'bcW') + 1, 1)
    normal! V
    cursor(search(tp_regex, 'W') - 1, 1)
  enddef

  # Reflow paragraphs with mappings like gqtp ("gq TeX paragraph")
  onoremap <silent><buffer> tp <scriptcmd>TeXPar()<cr>
  # Select TeX paragraph
  vnoremap <silent><buffer> tp <scriptcmd>TeXPar()<cr>

  # $...$ text object
  onoremap <silent><buffer> i$ <scriptcmd>normal! T$vt$<cr>
  onoremap <silent><buffer> a$ <scriptcmd>normal! F$vf$<cr>
  vnoremap <buffer> i$ T$ot$
  vnoremap <buffer> a$ F$of$

  for mapping in ['tp', 'i$', 'a$']
    UndoMap(mapping, 'ov')
  endfor
endif

# Commands for asynchronous typesetting
command! -buffer -nargs=? -complete=buffer ConTeXt          context.Typeset(<q-args>)
command! -buffer -nargs=0                  ConTeXtLog       context.Log('%')
command!         -nargs=0                  ConTeXtJobStatus context.JobStatus()
command!         -nargs=0                  ConTeXtStopJobs  context.StopJobs()

# vim: sw=2 fdm=marker