cespare / vim-toml

Vim syntax for TOML
MIT License
625 stars 40 forks source link

The plugin does not load itself? #54

Closed thanhnguyen2187 closed 4 years ago

thanhnguyen2187 commented 4 years ago

Hi,

I am a pretty new Vim user myself and trying to turn Vim into a all-purpose code editor. Python and Javascript syntax highlighting worked for me, but TOML one did not and I cannot find out why.

Here is my .vimrc:

""""""""""""""""""""""""""""""""""""""""
" Essentials                           " 
""""""""""""""""""""""""""""""""""""""""

set nu
set rnu
" set nowrap
set nocompatible
set so=999
set encoding=utf-8
syntax on

filetype plugin on
filetype plugin indent on

" Options to fix tmux
set background=dark
set t_Co=256

""""""""""""""""""""""""""""""""""""""""
" Vundle                               "
""""""""""""""""""""""""""""""""""""""""

set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

    " Essentials
    Plugin 'VundleVim/Vundle.vim'
    Plugin 'Valloric/YouCompleteMe'
        nnoremap <leader>gg :YcmCompleter GoTo<CR>
        nnoremap <leader>gr :YcmCompleter GoToReferences<CR>
        nnoremap <leader>rr :YcmCompleter RefactorRename 
        nnoremap <leader>rf :YcmCompleter Format<CR>
    let g:ycm_autoclose_preview_window_after_completion=1
    let g:ycm_python_binary_path='python3'
    Plugin 'vim-syntastic/syntastic'
    Plugin 'tpope/vim-surround'
    Plugin 'tpope/vim-repeat'
    Plugin 'jiangmiao/auto-pairs'
    Plugin 'Chiel92/vim-autoformat'

    " Python
    Plugin 'vim-scripts/indentpython.vim'
    Plugin 'nvie/vim-flake8'
    let python_highlight_all=1
    au BufNewFile,BufRead *.py 
        \ set
        \ tabstop=4
        \ softtabstop=4
        \ shiftwidth=4
        \ textwidth=79
        \ expandtab
        \ autoindent

    " Javascript
    Plugin 'pangloss/vim-javascript'
    au BufNewFile,BufRead *.js
        \ set
        \ tabstop=4
        \ softtabstop=4
        \ shiftwidth=4
        \ expandtab
        \ autoindent

    " HTML, CSS
    Plugin 'mattn/emmet-vim'
    au BufNewFile,BufRead *.html,*.css
        \ set
        \ tabstop=4
        \ softtabstop=4
        \ shiftwidth=4
        \ expandtab
        \ autoindent

    " JSON, YML, TOML
    Plugin 'cespare/vim-toml'

call vundle#end()

When I edit a file named pyproject.toml with the following content:

[tool.poetry]
name = "d3js-toy"
version = "0.1.0"
description = ""
authors = ["Thanh Nguyen <thanhnguyen2187@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.8"
flask = "^1.1.2"

[tool.poetry.dev-dependencies]
pytest = "^6.1"

[tool.poetry.scripts]
debug = "d3js_toy.entry_point:debug"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

The plugin refuse to load itself:

image

Here is the output of :scriptnames in Vim:

  1: /usr/share/vim/vimrc
  2: /usr/share/vim/vim81/debian.vim
  3: /usr/share/vim/vim81/syntax/syntax.vim
  4: /usr/share/vim/vim81/syntax/synload.vim
  5: /usr/share/vim/vim81/syntax/syncolor.vim
  6: /usr/share/vim/vim81/filetype.vim
  7: ~/.vimrc
  8: /usr/share/vim/vim81/syntax/nosyntax.vim
  9: /usr/share/vim/vim81/ftplugin.vim
 10: /usr/share/vim/vim81/indent.vim
 11: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim
 12: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim
 13: ~/.vim/bundle/YouCompleteMe/plugin/youcompleteme.vim
 14: ~/.vim/bundle/syntastic/plugin/syntastic/autoloclist.vim
 15: ~/.vim/bundle/syntastic/plugin/syntastic/balloons.vim
 16: ~/.vim/bundle/syntastic/plugin/syntastic/checker.vim
 17: ~/.vim/bundle/syntastic/plugin/syntastic/cursor.vim
 18: ~/.vim/bundle/syntastic/plugin/syntastic/highlighting.vim
 19: ~/.vim/bundle/syntastic/plugin/syntastic/loclist.vim
 20: ~/.vim/bundle/syntastic/plugin/syntastic/modemap.vim
 21: ~/.vim/bundle/syntastic/plugin/syntastic/notifiers.vim
 22: ~/.vim/bundle/syntastic/plugin/syntastic/registry.vim
 23: ~/.vim/bundle/syntastic/plugin/syntastic/signs.vim
 24: ~/.vim/bundle/syntastic/plugin/syntastic.vim
 25: ~/.vim/bundle/syntastic/autoload/syntastic/util.vim
 26: ~/.vim/bundle/vim-surround/plugin/surround.vim
 27: ~/.vim/bundle/auto-pairs/plugin/auto-pairs.vim
 28: ~/.vim/bundle/vim-autoformat/plugin/autoformat.vim
 29: ~/.vim/bundle/vim-autoformat/plugin/defaults.vim
 30: ~/.vim/bundle/vim-autoformat/plugin/utils.vim
 31: ~/.vim/bundle/emmet-vim/plugin/emmet.vim
 32: /usr/share/vim/vim81/plugin/getscriptPlugin.vim
 33: /usr/share/vim/vim81/plugin/gzip.vim
 34: /usr/share/vim/vim81/plugin/logiPat.vim
 35: /usr/share/vim/vim81/plugin/manpager.vim
 36: /usr/share/vim/vim81/plugin/matchparen.vim
 37: /usr/share/vim/vim81/plugin/netrwPlugin.vim
 38: /usr/share/vim/vim81/plugin/rrhelper.vim
 39: /usr/share/vim/vim81/plugin/spellfile.vim
 40: /usr/share/vim/vim81/plugin/tarPlugin.vim
 41: /usr/share/vim/vim81/plugin/tohtml.vim
 42: /usr/share/vim/vim81/plugin/vimballPlugin.vim
 43: /usr/share/vim/vim81/plugin/zipPlugin.vim
 44: ~/.vim/bundle/syntastic/autoload/syntastic/log.vim

I am using Ubuntu 20.04. Vim's version is 8.1 and Vundle's version is the latest one from Git.

Thanks for your help.

cespare commented 4 years ago

I don't use Vundle and this is really a question about Vundle, not vim-toml. Everything this plugin does is the totally standard vim boilerplate that all plugins use.

That said, I was able to get a minimal vimrc working with Vundle and vim-toml:

$ cat /tmp/vim/vimrc
set nocompatible
filetype off
set rtp+=/tmp/vim/bundle/Vundle.vim
call vundle#begin('/tmp/vim/bundle/')
Plugin 'VundleVim/Vundle.vim'
Plugin 'cespare/vim-toml'
call vundle#end()
filetype plugin indent on
syntax on
$ vim --noplugin -u /tmp/vim/vimrc /tmp/x.toml
... (run :PluginInstall inside vim)...

screen_20201006162132

I suspect the problem is that the ftdetect rules aren't being loaded. You can check by running :set ft when you're editing a toml file and see if it says filetype=toml (I bet it doesn't). You can also run :set ft=toml to see if setting the filetype makes the syntax work.

I'm pretty sure the problem with your vimrc is that these lines

syntax on
filetype plugin indent on

need to be after call vundle#end(). Read the Vundle instructions carefully -- ordering matters a lot with loading Vim configuration files and the directions say to put your configuration options after loading Vundle. I think that with the exception of

set nocompatible
filetype off

it would be best to put all your config options after the Vundle section.

I'll close this issue since there's no indication this is a vim-toml problem.

thanhnguyen2187 commented 4 years ago

Thanks a lot for the help. I moved my personal configurations after Vundle's ones and things work fine now. It truly was my fault for not reading the instructions carefully.

cespare commented 4 years ago

No worries. Glad to hear it's working.