VincentCordobes/vim-translate

Not working when vim/nvim is restarted?

Closed this issue · 5 comments

Thanks a lot for this nice plugin. I tried it with vim (8.1.542) and neovim (0.3.1) (both using vim-plug). The Translate command is available and works as expected once the plugin is installed with PlugInstall. Unfortunately, if vim or nvim is restarted, the Translate command is not available unless vim-translate is reinstalled. I must be missing something?

Could you share your .vimrc?

Sure, here it is:

set nocompatible
filetype plugin indent on
set clipboard=unnamedplus
set showcmd
set path+=**
set wildmenu
if has('nvim')
  if empty(glob('~/.config/nvim/autoload/plug.vim'))
    silent !mkdir -p ~/.config/nvim/autoload
    silent !curl -fLo ~/.config/nvim/autoload/plug.vim
          \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall
  endif
else
  if empty(glob('~/.vim/autoload/plug.vim'))
    silent !mkdir -p ~/.vim/autoload
    silent !curl -fLo ~/.vim/autoload/plug.vim
          \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall
  endif
endif
if has('nvim')
  call plug#begin('~/.local/share/nvim/plugged')
else
  call plug#begin('~/.local/share/vim/plugged')
endif
Plug 'lambdalisue/suda.vim'
cmap w!! w suda://%
cmap write!! w suda://%
Plug 'tpope/vim-obsession'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-unimpaired'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
nnoremap <C-p> :<C-u>FZF<CR>
let g:python_host_prog =  "/usr/sbin/python2"
let g:python3_host_prog =  "/usr/sbin/python3"
Plug 'ervandew/supertab'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<Right>"
let g:UltiSnipsJumpBackwardTrigger="<Left>"
let g:UltiSnipsListSnippets="<c-e>"
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsSnippetsDir='~/.vim/mysnippets'
let g:UltiSnipsSnippetDirectories=["UltiSnips", "mysnippets"]
if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif
let g:deoplete#enable_at_startup = 1
let g:deoplete#auto_complete = 1
Plug 'ludovicchabant/vim-gutentags'
let g:gutentags_ctags_exclude_wildignore = 0
let g:gutentags_cache_dir = "~/.cache/gutentags"
Plug 'terryma/vim-multiple-cursors'
function! Multiple_cursors_before()
    if exists('*deoplete#disable')
        exe 'call deoplete#disable()'
    elseif exists(':NeoCompleteLock') == 2
        exe 'NeoCompleteLock'
    endif
endfunction
function! Multiple_cursors_after()
    if exists('*deoplete#toggle')
        exe 'call deoplete#toggle()'
    elseif exists(':NeoCompleteUnlock') == 2
        exe 'NeoCompleteUnlock'
    endif
endfunction
Plug 'w0rp/ale'
let g:ale_sign_column_always = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\   'python': ['yapf', 'add_blank_lines_for_python_control_statements', 'isort', 'remove_trailing_lines', 'trim_whitespace'],
\   'sh': ['shfmt', 'remove_trailing_lines', 'trim_whitespace'],
\   'php': ['trim_whitespace', 'php_cs_fixer'],
\   'javascript': ['trim_whitespace', 'prettier'],
\   'yaml': ['trim_whitespace', 'remove_trailing_lines'],
\   'markdown': ['trim_whitespace', 'prettier', 'remove_trailing_lines'],
\   'html': ['trim_whitespace', 'remove_trailing_lines'],
\   'json': ['jq', 'prettier']
\}
nmap <silent> [W <Plug>(ale_first)
nmap <silent> [w <Plug>(ale_previous)
nmap <silent> ]w <Plug>(ale_next)
nmap <silent> ]W <Plug>(ale_last)
Plug 'itchyny/lightline.vim'
Plug 'scrooloose/nerdtree', { 'on' : 'NERDTreeToggle' }
Plug 'mbbill/undotree', { 'on' : 'UndotreeToggle' }
Plug 'vim-scripts/gnupg.vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'majutsushi/tagbar', { 'on' : 'TagbarOpen' }
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'dpelle/vim-Grammalecte', { 'on' : 'GrammalecteCheck', 'for': 'markdown' }
Plug 'godlygeek/tabular', { 'for': 'markdown' }
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'davidhalter/jedi-vim', { 'for': 'python' }
call plug#end()
Plug 'wannesm/wmgraphviz.vim'
Plug 'VincentCordobes/vim-translate'
let g:translate#default_languages = {
      \ 'fr': 'en',
      \ 'en': 'fr'
      \ }
set autoread " Reload files changed outside vim
syntax on
set number
set relativenumber
set title
set ruler
set mouse=a " use shift+middle click to paste xsel, see https://unix.stackexchange.com/questions/139578/copy-paste-for-vim-is-not-working-when-mouse-set-mouse-a-is-on
set foldlevelstart=10   " open most folds by default
set tw=80
noremap <Up> gk
noremap <Down> gj
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
augroup filetype_markdown
  autocmd!
  autocmd FileType markdown let g:vim_markdown_folding_disabled = 1 " Don't fold markdown
  autocmd FileType markdown let g:vim_markdown_toc_autofit = 1
  autocmd FileType markdown let g:vim_markdown_auto_insert_bullets = 0
  autocmd FileType markdown let g:vim_markdown_new_list_item_indent = 0
  autocmd FileType markdown set conceallevel=0                      " Show format WYSIWYG
  " autocmd FileType markdown set fo+=a
  autocmd FileType markdown set linebreak
  autocmd FileType markdown iabbrev -> →
  autocmd FileType markdown iabbrev <- ←
augroup END
augroup filetype_python
  autocmd!
  autocmd FileType python set foldmethod=indent
  autocmd FileType python set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣
  " Zeal
  autocmd FileType python nnoremap gz :!zeal "<cword>"&<CR><CR>
augroup END
set gdefault   " Never have to type /g at the end of search / replace
set ignorecase " Case insensitive searching (unless specified)
set incsearch  "
set hlsearch
set autoindent
set shiftwidth=2
set tabstop=2
set shiftround
set expandtab
set cursorline
set colorcolumn=80,100
highlight ColorColumn ctermbg=7
set splitbelow
set splitright
set scrolloff=3
set fileencodings=utf-8
set encoding=utf-8
autocmd BufWritePre * :%s/\s\+$//e
map <silent> <F6> "<Esc>:silent setlocal spell! spelllang=fr<CR>"
map <silent> <F7> "<Esc>:silent setlocal spell! spelllang=en<CR>"
let g:grammalecte_cli_py = '/usr/share/grammalecte-fr/cli.py'
map <Leader>l :Lines<space>
map <Leader>b :Buffers<space>
map <Leader>f :Find<space>
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --color "always" '.shellescape(<q-args>), 1, <bang>0)
command! FGit call fzf#run(fzf#wrap(
  \ {'source': 'git ls-files --exclude-standard --others --modified'}))
if !exists("*CallAntidote")
  function CallAntidote()
    :w
    call system("/usr/local/bin/Antidote ".bufname("%"))
  endfunction
  nmap <silent>  <leader>a  :call CallAntidote()<CR>
endif
function! Slugify() range
  silent! execute a:firstline . "," . a:lastline . 's/[^a-zA-Z0-9-\./]\+/_/'
  silent! execute a:firstline . "," . a:lastline . 's/\([A-Z]\)/\l\1/'
  silent! execute a:firstline . "," . a:lastline . 's/^[_]\+//'
  silent! execute a:firstline . "," . a:lastline . 's/[_]$//'
endfunction

It's not quite minimal :-/

Can you try to put Plug 'VincentCordobes/vim-translate' before call plug#end() ?

As call plug#end() is responsible for updating runtimepath, it has to be called after all thePlug ".."
(you might have the same issue with 'wannesm/wmgraphviz.vim') @aurelg

Thanks a lot, my mistake, it now works perfectly. I wish I haven't posted such a stupid question. :-/

Great 🙂