bugfix in formatters/ detection
This commit is contained in:
parent
fcc0f5437e
commit
e3e6694087
@ -62,7 +62,7 @@ For Ubuntu type `sudo apt-get install tidy` in a terminal.
|
|||||||
|
|
||||||
How can I change the behaviour of formatters?
|
How can I change the behaviour of formatters?
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
The formatprg for a <filetype> is defined in `g:formatprg_<filetype>`.
|
The formatprg for a `<filetype>` is defined in `g:formatprg_<filetype>`.
|
||||||
The arguments passed to the formatprogram are defined in `g:formatprg_args_<filetype>`.
|
The arguments passed to the formatprogram are defined in `g:formatprg_args_<filetype>`.
|
||||||
So, a complete definition could look like this:
|
So, a complete definition could look like this:
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ function! s:Autoformat()
|
|||||||
"Save window state
|
"Save window state
|
||||||
let winview=winsaveview()
|
let winview=winsaveview()
|
||||||
"Autoformat code
|
"Autoformat code
|
||||||
:silent exe "normal gggqG"
|
silent exe "normal gggqG"
|
||||||
"Recall window state
|
"Recall window state
|
||||||
call winrestview(winview)
|
call winrestview(winview)
|
||||||
else
|
else
|
||||||
echo "No formatter set for filetype ".&filetype
|
echo "No formatter defined for filetype ".&filetype
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -19,6 +19,7 @@ command! Autoformat call s:Autoformat()
|
|||||||
"Function for finding and setting the formatter
|
"Function for finding and setting the formatter
|
||||||
"with the given name, if the formatter is installed
|
"with the given name, if the formatter is installed
|
||||||
"globally or in the formatters folder
|
"globally or in the formatters folder
|
||||||
|
let s:formatterdir = fnamemodify(expand("<sfile>"), ":p:h:h")."/formatters/"
|
||||||
function! s:set_formatprg()
|
function! s:set_formatprg()
|
||||||
"Reset previous formatprg
|
"Reset previous formatprg
|
||||||
set formatprg=""
|
set formatprg=""
|
||||||
@ -35,7 +36,6 @@ function! s:set_formatprg()
|
|||||||
|
|
||||||
"Set correct formatprg path, if it is installed
|
"Set correct formatprg path, if it is installed
|
||||||
if !executable(s:formatprg)
|
if !executable(s:formatprg)
|
||||||
let s:formatterdir = fnamemodify(expand("<sfile>"), ":h:h")."/formatters/"
|
|
||||||
let s:formatprg = s:formatterdir.s:formatprg
|
let s:formatprg = s:formatterdir.s:formatprg
|
||||||
if !executable(s:formatprg)
|
if !executable(s:formatprg)
|
||||||
"Configured formatprg not installed
|
"Configured formatprg not installed
|
||||||
|
Loading…
Reference in New Issue
Block a user