formatter finding implemented
This commit is contained in:
parent
1dbdb9eee4
commit
e94180e2f4
@ -1,5 +1,7 @@
|
|||||||
let s:prgpath = "autopep8"
|
"Set the formatter name and arguments for this filetype
|
||||||
let s:arguments = " /dev/stdin"
|
let s:prgname = "autopep9"
|
||||||
if executable(s:prgpath)
|
let s:arguments = "/dev/stdin"
|
||||||
let &formatprg=s:prgpath." ".s:arguments
|
|
||||||
endif
|
"Set the formatprg option, if the formatter is installed
|
||||||
|
"globally or in the formatters folder
|
||||||
|
call g:FindFormatter(s:prgname, s:arguments)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
function! s:Autoformat()
|
function! s:Autoformat()
|
||||||
"If a formatprg is specified
|
"If a formatprg is specified
|
||||||
if &formatprg!=""
|
if &formatprg!=""
|
||||||
"echo "formatprg is: ".&formatprg
|
|
||||||
"Save window state
|
"Save window state
|
||||||
let winview=winsaveview()
|
let winview=winsaveview()
|
||||||
"Autoformat code
|
"Autoformat code
|
||||||
@ -16,3 +15,21 @@ endfunction
|
|||||||
|
|
||||||
"Create a command for this
|
"Create a command for this
|
||||||
command! Autoformat call s:Autoformat()
|
command! Autoformat call s:Autoformat()
|
||||||
|
|
||||||
|
"Function for finding and setting the formatter
|
||||||
|
"with the given name, if the formatter is installed
|
||||||
|
"globally or in the formatters folder
|
||||||
|
let s:formatterdir = fnamemodify(expand("<sfile>"), ":h:h")."/formatters/"
|
||||||
|
function! s:FindFormatter(name, args)
|
||||||
|
if executable(a:name)
|
||||||
|
let s:prgpath = a:name
|
||||||
|
else
|
||||||
|
let s:bars = expand("<sfile>")
|
||||||
|
let s:prgpath = s:formatterdir.a:name
|
||||||
|
endif
|
||||||
|
|
||||||
|
if executable(s:prgpath)
|
||||||
|
let &formatprg=s:prgpath." ".a:args
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user