Merge branch 'multi_ft' into dev
This allows setting multiple filetypes at the same time e.g. 'vimwiki.md' Closes #817, resolves #830, resolves #461.
This commit is contained in:
		@@ -341,7 +341,7 @@ function! vimwiki#base#open_link(cmd, link, ...) abort
 | 
				
			|||||||
  if is_wiki_link
 | 
					  if is_wiki_link
 | 
				
			||||||
    if a:0
 | 
					    if a:0
 | 
				
			||||||
      let vimwiki_prev_link = [a:1, []]
 | 
					      let vimwiki_prev_link = [a:1, []]
 | 
				
			||||||
    elseif &filetype ==# 'vimwiki'
 | 
					    elseif vimwiki#u#ft_is_vw()
 | 
				
			||||||
      let vimwiki_prev_link = [vimwiki#path#current_wiki_file(), getpos('.')]
 | 
					      let vimwiki_prev_link = [vimwiki#path#current_wiki_file(), getpos('.')]
 | 
				
			||||||
    endif
 | 
					    endif
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
@@ -437,7 +437,7 @@ function! vimwiki#base#goto(...) abort
 | 
				
			|||||||
        \ vimwiki#vars#get_wikilocal('path') . key . vimwiki#vars#get_wikilocal('ext'),
 | 
					        \ vimwiki#vars#get_wikilocal('path') . key . vimwiki#vars#get_wikilocal('ext'),
 | 
				
			||||||
        \ anchor,
 | 
					        \ anchor,
 | 
				
			||||||
        \ vimwiki_prev_link,
 | 
					        \ vimwiki_prev_link,
 | 
				
			||||||
        \ &filetype ==# 'vimwiki')
 | 
					        \ vimwiki#u#ft_is_vw())
 | 
				
			||||||
endfunction
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -853,8 +853,8 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) abort
 | 
				
			|||||||
    " Make sure no other plugin takes ownership over the new file. Vimwiki
 | 
					    " Make sure no other plugin takes ownership over the new file. Vimwiki
 | 
				
			||||||
    " rules them all! Well, except for directories, which may be opened with
 | 
					    " rules them all! Well, except for directories, which may be opened with
 | 
				
			||||||
    " Netrw
 | 
					    " Netrw
 | 
				
			||||||
    if &filetype !=# 'vimwiki' && fname !~? '\m/$'
 | 
					    if !vimwiki#u#ft_is_vw() && fname !~? '\m/$'
 | 
				
			||||||
      setfiletype vimwiki
 | 
					      call vimwiki#u#ft_set()
 | 
				
			||||||
    endif
 | 
					    endif
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
  if a:anchor !=? ''
 | 
					  if a:anchor !=? ''
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -671,7 +671,7 @@ endfunction
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function! vimwiki#tbl#format(lnum, ...) abort
 | 
					function! vimwiki#tbl#format(lnum, ...) abort
 | 
				
			||||||
  if !(&filetype ==? 'vimwiki')
 | 
					  if !vimwiki#u#ft_is_vw()
 | 
				
			||||||
    return
 | 
					    return
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
  let line = getline(a:lnum)
 | 
					  let line = getline(a:lnum)
 | 
				
			||||||
@@ -754,7 +754,7 @@ endfunction
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function! vimwiki#tbl#reset_tw(lnum) abort
 | 
					function! vimwiki#tbl#reset_tw(lnum) abort
 | 
				
			||||||
  if !(&filetype ==? 'vimwiki')
 | 
					  if !vimwiki#u#ft_is_vw()
 | 
				
			||||||
    return
 | 
					    return
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
  let line = getline(a:lnum)
 | 
					  let line = getline(a:lnum)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -108,3 +108,27 @@ function! vimwiki#u#is_codeblock(lnum) abort
 | 
				
			|||||||
    return 0
 | 
					    return 0
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
endfunction
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Sets the filetype to vimwiki
 | 
				
			||||||
 | 
					" If g:vimwiki_filetypes variable is set
 | 
				
			||||||
 | 
					" the filetype will be vimwiki.<ft1>.<ft2> etc.
 | 
				
			||||||
 | 
					function! vimwiki#u#ft_set()
 | 
				
			||||||
 | 
					  let ftypelist = vimwiki#vars#get_global('filetypes')
 | 
				
			||||||
 | 
					  let ftype = 'vimwiki'
 | 
				
			||||||
 | 
					  for ftypeadd in ftypelist
 | 
				
			||||||
 | 
					    let ftype = ftype . '.' . ftypeadd
 | 
				
			||||||
 | 
					  endfor
 | 
				
			||||||
 | 
					  let &filetype = ftype
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Returns: 1 if filetype is vimwiki, 0 else
 | 
				
			||||||
 | 
					" If multiple fileytpes are in use 1 is returned only if the
 | 
				
			||||||
 | 
					" first ft is vimwiki which should always be the case unless
 | 
				
			||||||
 | 
					" the user manually changes it to something else
 | 
				
			||||||
 | 
					function! vimwiki#u#ft_is_vw()
 | 
				
			||||||
 | 
					  if split(&filetype, '\.')[0] ==? 'vimwiki'
 | 
				
			||||||
 | 
					    return 1
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    return 0
 | 
				
			||||||
 | 
					  endif
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -162,6 +162,7 @@ function! s:read_global_settings_from_user() abort
 | 
				
			|||||||
        \ 'folding': {'type': type(''), 'default': '', 'possible_values': ['', 'expr', 'syntax',
 | 
					        \ 'folding': {'type': type(''), 'default': '', 'possible_values': ['', 'expr', 'syntax',
 | 
				
			||||||
        \     'list', 'custom', ':quick', 'expr:quick', 'syntax:quick', 'list:quick',
 | 
					        \     'list', 'custom', ':quick', 'expr:quick', 'syntax:quick', 'list:quick',
 | 
				
			||||||
        \     'custom:quick']},
 | 
					        \     'custom:quick']},
 | 
				
			||||||
 | 
					        \ 'filetypes': {'type': type([]), 'default': []},
 | 
				
			||||||
        \ 'global_ext': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
 | 
					        \ 'global_ext': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
 | 
				
			||||||
        \ 'hl_cb_checked': {'type': type(0), 'default': 0, 'min': 0, 'max': 2},
 | 
					        \ 'hl_cb_checked': {'type': type(0), 'default': 0, 'min': 0, 'max': 2},
 | 
				
			||||||
        \ 'hl_headers': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
 | 
					        \ 'hl_headers': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3384,6 +3384,20 @@ The default is to enable all key mappings except the mouse: >
 | 
				
			|||||||
    \ }
 | 
					    \ }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					*g:vimwiki_filetypes*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					A list of additional fileypes that should be registered to vimwiki files: >
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  let g:vimwiki_filetypes = ['markdown', 'pandoc']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Would result in the filetype being set to `vimwiki.markdown.pandoc`. This can
 | 
				
			||||||
 | 
					be used to enable third party plugins such as custom folding. WARNING: this
 | 
				
			||||||
 | 
					option can allow other plugins to overwrite vimwiki settings and operation so
 | 
				
			||||||
 | 
					take care when using it. Any plugin that uses a set filetype will be enabled.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The default is `[ ]`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
==============================================================================
 | 
					==============================================================================
 | 
				
			||||||
13. Getting help                                                *vimwiki-help*
 | 
					13. Getting help                                                *vimwiki-help*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,7 +89,7 @@ function! s:setup_new_wiki_buffer() abort
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  " this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
 | 
					  " this makes that ftplugin/vimwiki.vim and afterwards syntax/vimwiki.vim are
 | 
				
			||||||
  " sourced
 | 
					  " sourced
 | 
				
			||||||
  setfiletype vimwiki
 | 
					  call vimwiki#u#ft_set()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
endfunction
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -114,8 +114,8 @@ function! s:setup_buffer_win_enter() abort
 | 
				
			|||||||
    return
 | 
					    return
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if &filetype !=# 'vimwiki'
 | 
					  if !vimwiki#u#ft_is_vw()
 | 
				
			||||||
    setfiletype vimwiki
 | 
					    call vimwiki#u#ft_set()
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  call s:set_windowlocal_options()
 | 
					  call s:set_windowlocal_options()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user