Here is a part of my ftplugin/fortran_state.vim
" Check python modules and install{{{1
if !executable('fprettify') || !executable('fortls') || !executable('unidecode')
:let choice =confirm("Some python dependencies doesn't exists! Install them?", "&Yes\n&No(use fallback)")
if !executable('fprettify')
:call install_deps#install_fprettify()
endif
if !executable('fortls')
:call install_deps#install_fortls()
endif
if !executable('unidecode')
:call install_deps#install_unidecode()
endif
endif
"}}}
The intention is these block will be executed and install the dependencies only when they are not installed (obviously!) Problem is, even they are installed and in path, this block is executed every time I open a fortran file.
pip3 install --user fortran-language-server fprettify unidecode
Requirement already satisfied: fortran-language-server in ~/.local/lib/python3.9/site-packages (1.12.0)
Requirement already satisfied: fprettify in ~.local/lib/python3.9/site-packages (0.3.7)
Requirement already satisfied: unidecode in ~/.local/lib/python3.9/site-packages (1.1.2)
Requirement already satisfied: configargparse in ~/.local/lib/python3.9/site-packages (from fprettify) (1.2.3)
which fprettify
~/.local/bin/fprettify
which fortls
~/.local/bin/fortls
which unidecode
~/.local/bin/unidecode
One odd thing is installation is going on even if I select No(Use fallback)
.
The install_deps
is from autoload
, with:
function! install_deps#install_fprettify()
echom "Installing fprettify"
:execute ':!pip3 install fprettify --user -q'
endfunction
function! install_deps#install_unidecode()
echom "Installing unidecode"
:execute ':!pip3 install unidecode --user -q'
endfunction
function! install_deps#install_fortls()
echom "Installing fortls"
:execute ':!pip3 install fortran-language-server --user -q'
endfunction
So,it looks like if block
and choice
does not work as I think.
What I am doing wrong here?
Update
Reply to Ben: I have used:
let choice =confirm("Some python dependencies doesn't exists! Install them?", "&Yes\n&No(use fallback)") echo choice
If I chose Yes, confirm is 1, with No, its 2. But, code should not go to choice
at all when all of them are already installed. Why the code is reading that choice line?
:echo $PATH
while inside Vim.confirm
, have you?ftplugin/*.vim
you don't need to type the colon before commands (i.e. justcall install_deps#install_fprettify()
, not:call install_deps#install_fprettify()
)