cannot get SASS (indent style!) syntax highlighting to work in VIM 8

谁说胖子不能爱 提交于 2019-12-25 09:35:10

问题


VIM VERSION: VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 2 2017 03:55:34)

I'm using a number of plugins with vim in order to make things work. I install them via the package manager Vundle, my .vimrc can be found in my dotfiles repository on github

Today, I tried to edit a SASS file with vim, however - the SASS file looks like a color-circus:

I've followed some steps from this answer which include:

  1. Does enabling syntax explicitly fix your problem? :syntax enable
  2. Is filetype detection on? :filetype
  3. Does vim recognize this as a sass file? :set filetype?
  4. Check to make sure your script directories are in the runtime path :set runtimepath?
  5. Does manually loading the syntax file change anything? :runtime! vimfiles/syntax/sass.vim
  6. Also check if syntax highlighting works for other filetypes.

The answers to each point are:

  1. Nothing changed, syntax remains exactly the same.
  2. running :filetype returns filetype detection:ON plugin:ON indent:ON
  3. running :set filetype? returns filetype=sass
  4. running :set runtimepath? returns a long list of ~/.vim/bundle/[PATH] entries of which none include sass in any form
  5. running :runtime! ~/.vim/bundle/vim-haml/syntax/sass.vim also changes nothing
  6. Syntax highlighting works for everything except SASS so far.

Additionally, I've tried adding some plugins from http://vimawesome.com/. They all seem to be packages that either support a different package which should be supported by default or they do not support SASS (in addition to SCSS) highlighting.

This is, what I came up with in the end, still making no difference:

Plugin 'tpope/vim-haml'
Plugin 'JulesWang/css.vim'
Plugin 'hail2u/vim-css3-syntax'

The plugin tpope/vim-haml however, does have a sass.vim file with it's syntax rules, it's actually the only up-to-date one compared to the rest which all seem to hang at "last updated 5+ years ago".

I basically have two questions, which I hope, more experienced vimologists will be able to answer, or point me in the right direction of fixing it myself:

  • Is there any known properly updated SASS (indent syntax) plugin that I missed?
  • If the above question is "no", then how could I get the tpope/vim-haml sass syntax file loaded for all my sass files?

I'm using SASS since, coming from Atom, it is less typing. I would prefer to keep the sass syntax if possible! (I am aware of conversion plugins but for the sake of my colleagues I would like to refrain from using any)

Thanks in advance!


回答1:


Answer

It was the colorscheme I was using, it caused severe formatting issues for my SASS files.

TLDR;

I was using roosta/srcery and just tried an alternate colorscheme to test if the sass file would look more "sane", it now looks like this (using a random colorscheme):

What we see here is still not perfect, but at least "sane" (I can understand why CSS3 flex properties aren't highlighted yet for instance), I'm simply going to try inform the author of the (really nice nonetheless) colorscheme to see if he is interested in improving it for SASS.

My lesson here, is that one should look at every aspect, I was thinking in the wrong direction and kept on going for too long as a result. When @romainl pointed out it looked fine using just regular-builtin-vim I started expecting a Plugin (a colorscheme) to be the suspect which solved my issue :)



来源:https://stackoverflow.com/questions/43919929/cannot-get-sass-indent-style-syntax-highlighting-to-work-in-vim-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!