mirror of
https://github.com/vim/vim.git
synced 2025-07-25 10:54:51 -04:00
patch 9.1.0865: filetype: org files are not recognized
Problem: filetype: org files are not recognized Solution: detect '*.org' files as 'org' filetype, include filetype and syntax plugin (Luca Saccarola) closes: #16054 Signed-off-by: Luca Saccarola <github.e41mv@aleeas.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
4bd9b2b246
commit
0684800c85
@ -1,4 +1,4 @@
|
|||||||
*filetype.txt* For Vim version 9.1. Last change: 2024 Nov 12
|
*filetype.txt* For Vim version 9.1. Last change: 2024 Nov 14
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -843,6 +843,12 @@ To enable folding use this: >
|
|||||||
let g:markdown_recommended_style = 0
|
let g:markdown_recommended_style = 0
|
||||||
|
|
||||||
|
|
||||||
|
ORG *ft-org-plugin*
|
||||||
|
|
||||||
|
To enable folding use this: >
|
||||||
|
let g:org_folding = 1
|
||||||
|
<
|
||||||
|
|
||||||
PDF *ft-pdf-plugin*
|
PDF *ft-pdf-plugin*
|
||||||
|
|
||||||
Two maps, <C-]> and <C-T>, are provided to simulate a tag stack for navigating
|
Two maps, <C-]> and <C-T>, are provided to simulate a tag stack for navigating
|
||||||
|
@ -1472,6 +1472,9 @@ au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md
|
|||||||
\ setf markdown |
|
\ setf markdown |
|
||||||
\ endif
|
\ endif
|
||||||
|
|
||||||
|
" Org (Emacs' org-mode)
|
||||||
|
au BufNewFile,BufRead *.org setf org
|
||||||
|
|
||||||
" Mason (it used to include *.comp, are those Mason files?)
|
" Mason (it used to include *.comp, are those Mason files?)
|
||||||
au BufNewFile,BufRead *.mason,*.mhtml setf mason
|
au BufNewFile,BufRead *.mason,*.mhtml setf mason
|
||||||
|
|
||||||
|
37
runtime/ftplugin/org.vim
Normal file
37
runtime/ftplugin/org.vim
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
" Vim filetype plugin file
|
||||||
|
" Language: Org
|
||||||
|
" Maintainer: Luca Saccarola <github.e41mv@aleeas.com>
|
||||||
|
" Last Change: 2024 Nov 14
|
||||||
|
|
||||||
|
if exists("b:did_ftplugin")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
|
if exists('b:undo_ftplugin')
|
||||||
|
let b:undo_ftplugin .= "|setl cms< com< fo< flp<"
|
||||||
|
else
|
||||||
|
let b:undo_ftplugin = "setl cms< com< fo< flp<"
|
||||||
|
endif
|
||||||
|
|
||||||
|
setl commentstring=#\ %s
|
||||||
|
setl comments=fb:*,fb:-,fb:+,b:#,b:\:
|
||||||
|
|
||||||
|
setl formatoptions+=nql
|
||||||
|
setl formatlistpat=^\\s*\\(\\(\\d\\|\\a\\)\\+[.)]\\|[+-]\\)\\s\\+
|
||||||
|
|
||||||
|
function OrgFoldExpr()
|
||||||
|
let l:depth = match(getline(v:lnum), '\(^\*\+\)\@<=\( .*$\)\@=')
|
||||||
|
if l:depth > 0 && synIDattr(synID(v:lnum, 1, 1), 'name') =~# '\m^orgHeadline'
|
||||||
|
return ">" . l:depth
|
||||||
|
endif
|
||||||
|
return "="
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
if has("folding") && get(g:, 'org_folding', 0)
|
||||||
|
setl foldexpr=OrgFoldExpr()
|
||||||
|
setl foldmethod=expr
|
||||||
|
let b:undo_ftplugin .= "|setl foldexpr< foldmethod<"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" vim: ts=8 sts=2 sw=2 et
|
71
runtime/syntax/org.vim
Normal file
71
runtime/syntax/org.vim
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: Org
|
||||||
|
" Maintainer: Luca Saccarola <github.e41mv@aleeas.com>
|
||||||
|
" Last Change: 2024 Nov 14
|
||||||
|
"
|
||||||
|
" Reference Specification: Org mode manual
|
||||||
|
" GNU Info: `$ info Org`
|
||||||
|
" Web: <https://orgmode.org/manual/index.html>
|
||||||
|
|
||||||
|
" Quit when a (custom) syntax file was already loaded
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:current_syntax = 'org'
|
||||||
|
|
||||||
|
syn case ignore
|
||||||
|
|
||||||
|
" Bold
|
||||||
|
syn region orgBold matchgroup=orgBoldDelimiter start="\(^\|[- '"({\]]\)\@<=\*\ze[^ ]" end="^\@!\*\([^\k\*]\|$\)\@=" keepend
|
||||||
|
hi def link orgBold markdownBold
|
||||||
|
hi def link orgBoldDelimiter orgBold
|
||||||
|
|
||||||
|
" Italic
|
||||||
|
syn region orgItalic matchgroup=orgItalicDelimiter start="\(^\|[- '"({\]]\)\@<=\/\ze[^ ]" end="^\@!\/\([^\k\/]\|$\)\@=" keepend
|
||||||
|
hi def link orgItalic markdownItalic
|
||||||
|
hi def link orgItalicDelimiter orgItalic
|
||||||
|
|
||||||
|
" Strikethrogh
|
||||||
|
syn region orgStrikethrough matchgroup=orgStrikethroughDelimiter start="\(^\|[ '"({\]]\)\@<=+\ze[^ ]" end="^\@!+\([^\k+]\|$\)\@=" keepend
|
||||||
|
hi def link orgStrikethrough markdownStrike
|
||||||
|
hi def link orgStrikethroughDelimiter orgStrikethrough
|
||||||
|
|
||||||
|
" Underline
|
||||||
|
syn region orgUnderline matchgroup=orgUnderlineDelimiter start="\(^\|[- '"({\]]\)\@<=_\ze[^ ]" end="^\@!_\([^\k_]\|$\)\@=" keepend
|
||||||
|
|
||||||
|
" Headlines
|
||||||
|
syn match orgHeadline "^\*\+\s\+.*$" keepend
|
||||||
|
hi def link orgHeadline Title
|
||||||
|
|
||||||
|
" Line Comment
|
||||||
|
syn match orgLineComment /^\s*#\s\+.*$/ keepend
|
||||||
|
hi def link orgLineComment Comment
|
||||||
|
|
||||||
|
" Block Comment
|
||||||
|
syn region orgBlockComment matchgroup=orgBlockCommentDelimiter start="\c^\s*#+BEGIN_COMMENT" end="\c^\s*#+END_COMMENT" keepend
|
||||||
|
hi def link orgBlockComment Comment
|
||||||
|
hi def link orgBlockCommentDelimiter Comment
|
||||||
|
|
||||||
|
" Lists
|
||||||
|
syn match orgUnorderedListMarker "^\s*[-+]\s\+" keepend
|
||||||
|
hi def link orgUnorderedListMarker markdownOrderedListMarker
|
||||||
|
syn match orgOrderedListMarker "^\s*\(\d\|\a\)\+[.)]\s\+" keepend
|
||||||
|
hi def link orgOrderedListMarker markdownOrderedListMarker
|
||||||
|
"
|
||||||
|
" Verbatim
|
||||||
|
syn region orgVerbatimInline matchgroup=orgVerbatimInlineDelimiter start="\(^\|[- '"({\]]\)\@<==\ze[^ ]" end="^\@!=\([^\k=]\|$\)\@=" keepend
|
||||||
|
hi def link orgVerbatimInline markdownCodeBlock
|
||||||
|
hi def link orgVerbatimInlineDelimiter orgVerbatimInline
|
||||||
|
syn region orgVerbatimBlock matchgroup=orgVerbatimBlockDelimiter start="\c^\s*#+BEGIN_.*" end="\c^\s*#+END_.*" keepend
|
||||||
|
hi def link orgVerbatimBlock orgCode
|
||||||
|
hi def link orgVerbatimBlockDelimiter orgVerbatimBlock
|
||||||
|
|
||||||
|
" Code
|
||||||
|
syn region orgCodeInline matchgroup=orgCodeInlineDelimiter start="\(^\|[- '"({\]]\)\@<=\~\ze[^ ]" end="^\@!\~\([^\k\~]\|$\)\@=" keepend
|
||||||
|
highlight def link orgCodeInline markdownCodeBlock
|
||||||
|
highlight def link orgCodeInlineDelimiter orgCodeInline
|
||||||
|
syn region orgCodeBlock matchgroup=orgCodeBlockDelimiter start="\c^\s*#+BEGIN_SRC.*" end="\c^\s*#+END_SRC" keepend
|
||||||
|
highlight def link orgCodeBlock markdownCodeBlock
|
||||||
|
highlight def link orgCodeBlockDelimiter orgCodeBlock
|
||||||
|
|
||||||
|
" vim: ts=8 sts=2 sw=2 et
|
@ -2724,4 +2724,14 @@ func Test_make_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_org_file()
|
||||||
|
filetype on
|
||||||
|
|
||||||
|
call writefile(['* org Headline', '*some bold text*', '/some italic text/'], 'Xfile.org', 'D')
|
||||||
|
split Xfile.org
|
||||||
|
call assert_equal('org', &filetype)
|
||||||
|
|
||||||
|
filetype off
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
865,
|
||||||
/**/
|
/**/
|
||||||
864,
|
864,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user