I closed a vim window completely (something I rarely do) and when I opened it back up my syntax highlighting for jsx files stopped.
I had some other windows open and inside these the syntax highlighting for jsx was still working.
I compared the filetypes in both and could see that the ones that were still working were set to javascript.jsx and the exact same files in my new window had a filetype of javascriptreact.
Then I shut down all windows to see if reloading all would have an effect, and now all my .jsx files come up with filetype of javascriptreact with no proper syntax highlighting (especially jsx parts).
I didn't intentionally change any config options that I'm aware of, and am using vim-jsx plugin.
Does anyone have any idea of what might be going on? I am getting the same behavior in terminal Vim and in MacVim.
It's worth noting that when I manually set the filetype back to javascript.jsx it doesn't have an effect.
Help!
Ok, this is embarrassing, but apparently this line got removed from my .vimrc.
execute pathogen#infect()
So none of the plugins in ~/.vim/bundle were loading. Still not quite sure how that happened, but I suspect carelessness on my part rather than foul play.
Anyway. I survived to code another day...
Related
I uninstalled vim74 and compiled vim81 and installed it. However I found it strange, comparing to vim74. When there's no .vimrc file under HOME dir, I open a c++ file and syntax highlight is working and I can use Backspace to delete letters. However when I add a .vimrc under HOME dir and just put set number into it, when the c++ source file is opened, no highlight, and Backspace not working. Why is that ? I used to add some configurations in .vimrc under vim74 before, and this situation never happens.
After complaints that Vim in its default configuration is hard to use (especially for beginners), it was decided to enable a default configuration if the user hasn't created his own ~/.vimrc (yet). This was introduced with Vim 8.0, and explains what you're seeing (namely: syntax highlighting and sensible backspace behavior). Read more about the details at :help defaults.vim.
The help also has instructions how to keep the defaults when adding your own ~/.vimrc configuration:
If you create your own .vimrc, it is recommended to add these lines somewhere
near the top:
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
Then Vim works like before you had a .vimrc.
Tip: Don't go all crazy with adding various snippets (especially not those you don't fully understand) and plugins to your ~/.vimrc, even though the Internet is full of them. Rather, build it up gradually, depending on needs, and back up your understanding with careful studying of the excellent :help. Also, avoid pre-packaged Vim distributions; they're even worse.
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:
Does enabling syntax explicitly fix your problem? :syntax enable
Is filetype detection on? :filetype
Does vim recognize this as a sass file? :set filetype?
Check to make sure your script directories are in the runtime path :set runtimepath?
Does manually loading the syntax file change anything? :runtime! vimfiles/syntax/sass.vim
Also check if syntax highlighting works for other filetypes.
The answers to each point are:
Nothing changed, syntax remains exactly the same.
running :filetype returns filetype detection:ON plugin:ON indent:ON
running :set filetype? returns filetype=sass
running :set runtimepath? returns a long list of ~/.vim/bundle/[PATH] entries of which none include sass in any form
running :runtime! ~/.vim/bundle/vim-haml/syntax/sass.vim also changes nothing
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!
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 :)
I am using mac vim in terminal via /Applications/MacVim.app/Contents/vim
By now I didn't really care about what was in the MacVim directory in /Applications/MacVim.app/Contents/Resources/vim/runtime
and still somehow I had proper syntax highlighting etc.. I guess my vim loaded the files from macvim?
Somehow I messed arround with snipmate and all the syntax highlighting stopped to work. Filetypes are correct, but no highlighting. So I copied the syntax folder from the macvim app to my ~/.vim/syntax and it worked like a charm. Is there a way how I can use the ones from the app again?
Thanks for any help
Copying the syntax to your own ~/.vim/ directory effectively forks the factory-defaults. The downside is that you now have to update your copy whenever Macvim is updated.
The key to figuring out the problems is the 'runtimepath' setting. By modifying that (in your ~/.vimrc), you should be able to include the proper runtime files (and that is not just syntax, but also filetype plugins, should you have :filetype plugin on). BTW, it's unlikely this is caused by snipMate.
:set runtimepath?
Also, the :scriptnames command tells you exactly which scripts have been sourced so far.
I'm trying to detect Go files in vim. I've set this up normally on other computers but this one is stuck.
:set filetype?
filetype=go
So it knows that it's a go file, but isn't triggering the syntax highlighting.
However,
:set filetype=go
triggers it correctly.
:filetype detect
doesn't work, and reopening the file
:e!
turns syntax highlighting off, even though filetype remains set to "go".
I have
set rtp+=/usr/local/go/misc/vim
filetype plugin indent on
syntax on
in my .vimrc (as the instructions say).
What's going on? I suspect there's some other configuration that's undoing the syntax highlighting, but lack the knowledge of where to find it.
I'm not sure exactly what the problem is… However, you can try :scriptnames to see what files were loaded by Vim.
One step further, you can set verbose=9 in your .vimrc and restart Vim. Careful, this is really verbose, try to tweak that number down.
i use vim to edit different filetypes.
it seems vim can load the filetype plugin correctly, for different filetypes the highlight, indent and comment are all working well.
but the menubar seems not working.
eg. i installed vim-latex, therefore after i open a .tex file, the menu-bar has all the menus Tex-suite, Tex-enviroment, Tex-Math, etc.
but when i switch back to a .py file, these menus are still there... and even the keymap for .tex file compling is still there. when i type <leader>ll, vim still compiles the .tex file in previous buffer...
How should i reset vim menus (and the keymaps) when a different filetype is loaded?
thanks!
I didn't know vim-latex before, but it looks like a powerful suite that totally takes over Vim, and currently does not support undoing its massive customizations once it's been loaded.
You can get rid of the menu via
:aunmenu TeX-Suite
and likewise remove the mapping via
:nunmap <buffer> <Leader>ll
But I guess simply quitting Vim and re-launching it is the easiest, pragmatic solution.
Of course, you can file enhancement requests against the project, but I guess this is not high on their agenda, and some people may find the toggling of the menu when switching buffers more annoying than the lingering menu.