Julia syntax highlighting in julia-vim - vim

I use gvim with julia-vim for editing julia code. I am using julia 0.5 on a mac and installed julia-vim with vundle.
My problem is that files with the .jl extension do not have appropriate highlighting. For example, if is highlighted but for is not. Any solution for this?

.jl files are sometimes recognized as lisp files by default, (blame Sawfish) so that's probably the syntax highlighting you're getting. (type defun and progn and etc and see if the pretty colors pop up)
You were close when you said the correct solution was :set syntax=julia, what you need is to set filetype plus some autocmd magicks to make that happen every time you open a .jl file.
Put something like this in some file (e.g. jl.vim) in your ftdetect directory:
autocmd BufRead,BufNewFile *.jl :set filetype=julia
And that should do it.
Addendum 1: Changing filetype instead of syntax may be required to trigger additional features like the LaTeX expansions depending on the root of your problem, so that's what I am using.
Addendum 2: Note that this should've been handled by the julia-vim plugin, but conflicts with other scripts can mess with that. You can use :scriptnames to see what scripts have been loaded and in what order, and try to debug what could be causing the conflict, if you think that's worth the trouble.
Addendum 3: Also related is that Vundle has some specific configurations that need to be made when it comes to filetypes, so that could also be causing this. However, I've seen this and similar problems happen outside Vundle for any number of reasons so I still believe that the solution at the top is the best one, and will possibly prevent some future headaches.

After testing julia-vim I think the issue is likely with the color scheme you are using.
Try using a different one.
:colorscheme desert
I tried it with the built-in desert and both if and for were highlighted (see below).

I found that the instructions here worked a treat. Namely
git clone https://github.com/JuliaEditorSupport/julia-vim.git
mkdir -p ~/.vim
cp -R julia-vim/* ~/.vim
Note: I realise that the OP claims to have already installed Julia-Vim using Vundle, but I came to this question because Vim was automatically using LISP syntax highlighting for me, and the above was enough for me. So I am sharing in case anyone comes from the same boat as me (i.e. the problem is not Vundle related) :)

Related

vim81 configuration wrong after I added .vimrc

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.

Can you view the default Vim settings?

I’m starting to learn about creating my own .vimrc file and I keep noticing features that are missing with my custom version that were present in the default setup.
I was wondering if it is possible to view the default settings, so I can compare them to my own and look up all the standard inclusions I don't know to learn more about them.
I searched and couldn’t find an answer online, and if the reason why there isn’t one is that the answer to this question is glaringly obvious, I’m really sorry; I’m still a bit of a noob :p
No worries, it’s a perfectly valid question. Unfortunately, the answer is a bit complicated. First of all, Vim has certain defaults that are documented in the built-in help system.
Some of them are only used when Vi compatibility mode is disabled, and that’s the first customisation most people make:
:set nocompatible
On top of that, many distributions provide their own custom config, for example Debian/Ubuntu comes with /etc/vim/vimrc. To makes things even more confusing, Vim 8 comes with a sane configuration (called default.vim) that only gets applied when ~/.vimrc is not found. Not to mention that NeoVim comes with its own set of defaults.
In practice, I suggest to explicitly set any options you care about to make sure your config is portable between systems and versions of Vim. To see the current value of a given option, use a question mark:
:set showcmd?
To learn more about a given option (including the default value), use Vim’s comprehensive help system:
:help showcmd
Finally, you might want to check my annotated .vimrc for some inspiration, and there is also the vim-sensible plugin that provides some sane defaults most people would agree to.
The easiest way to see “vanilla” Vim options is to start it using:
$ vim -u NONE -N
It will start Vim without any of your customizations or plugins, but still in ‘nocompatible’ mode (i.e., basically, running full-fledged Vim, instead of its stripped down version emulating Vi).
Then, you can execute the following commands:
:set all
:map
:command
:let
:function
:autocmd
to see all options, mappings, commands, variables, functions, and auto-commands, respectively, that are currently in effect. (I cannot promise I haven’t forgotten a customization category.)
Vim also comes with a bunch of basic configurations that is skipped by the -u NONE option, that you can also include while still excluding your .vimrc, by using -u NORC, instead.
Based on #Amadan's answer, I came up with this file (ShowAllDefaults.vim) and command to run it and capture the output.
. In the mean time, learning that, if you have files under ~/.vim, they get executed if you use this:
vim -u ShowAllDefaults.vim -N +q
So the correct way to do it is:
vim -u NONE -N +"source ShowAllDefaults.vim" +q
Contents of ShowAllDefaults.vim:
set verbosefile=/tmp/ShowAllDefaults.log
set all
map
command
let
function
autocmd
I am trying after long time to get familiar with vim also, and I came across this because I had same question.
How I found answer from within vim was to pull up help on defaults and it explained to get defaults along with .vimrc for newer users and also gave the path to default script so you could open it right up in your editor and read & compare it.
I am not going to give my exact path because that might change in different versions, so best to get it from help documents inside vim.

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

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 :)

Does anyone have extra «» generated from lh-brackets

Can't seem to find any reason for this, but I have been using Ycm, syntastic, and all the lh- plugins with vim for a while now. In the case of lh-brackets, I used to have a problem with it generating "«»" every time it 'automatically' generated the other bracket, paren, quote, etc. But it was only happening in .vim files, so i turned it off for vim files in my vimrc. Now nothing has changed, no new scripts installed, and all of the sudden, this happens with ALL files (cpp, h, pl, py, etc). Like i said, not using heavy customization, and everything is default except the disabling of lh-brackets when editing vim files, but that has now become a hotkey since i cant use it anywhere.
My Question is this: does anyone have this or similar problem with lh-brackets, and if so, any idea how to fix it, or is there some setting I am missing?
My first thoughts are to go though and check any updated vim scripts (this just happened a day ago) that could have been updated when doing an apt-get upgrade (like debian.vim) but after that I've got nothing...
The placeholders characters can be jumped to (:h <Plug>MarkersJumpF -> <C-J> with vim, <m-ins> with gvim). That's their purpose.
If you have installed lh-cpp, see :h lh-cpp-first-steps, you'll find a quick guide to my C++ suite (and lh-brackets incidentally).
EDIT: The plugin was badly designed. I've patched the plugin to rely on g:usemarks in order to fix the ergonomic of plugin .
In the (now-) past, if you wanted to set b:usemarks to 0, you'd have needed to add an autocommand that'd set b:usemarks to 0 in all new buffers.
Now, (lh-brackets v2.2.0), if you want to always disable the placeholders/marker characters, you need to set g:usemarks to 0, not b:usemarks. Buffer-local variables are meant to be set from ftplugins, or tree/project-local plugins which are supported thanks to plugins like local_vimrc.
And as romainl has pointed out, don't hesitate to use the bug trackers, or even to contact me.
hmm found it:
:let b:usemarks=0
now needs to be set, apparently that was a marker for integration to another plugin, though i dont use it.

vim, pathogen, and load order of ftplugin files

I've been using Vim and pathogen for a while, and things were working fine, but recently I've started having load order issues with my ftplugin configuration.
The specific problem I'm having right now is that python-mode is overriding my ftplugin settings. I've got a ~/.vim/ftplugin/python.vim that contains the following line:
setlocal textwidth=119
python-mode comes with its own ftplugin file, which also sets textwidth, in ~/.vim/bundle/python-mode/ftplugin/python/pymode.vim.
The problem is that Vim is now loading python-mode's ftplugin file after my ftplugin file, so I'm ending up with its textwidth=79. I recently had to reinstall MacPorts, and I think something must have changed in the stock configuration.
I've tried various tricks involving turning filetype/plugin detection off before invoking pathogen, per various other answers, but none of them are helping.
Through the use of verbose set textwidth? and some echomsg debugging, I know that both ftplugin files are being invoked, and that they're being invoked in the wrong (for my needs) order.
Is there any way to force Vim/pathogen to invoke my ftplugin files after those of the plugins?
I've even tried putting my settings into ~/.vim/after/plugin/pymode.vim, but that's loaded immediately after pathogen sets up the plugin, so it still runs before ftplugin files, which only get loaded once I edit a Python file.
It turns out that maybe this never worked the way I thought. I didn't realize that Vim also supported ~/.vim/after/ftplugin, so I was able to move my overrides to ~/.vim/after/ftplugin/python.vim and get the behavior I was expecting. I'm loath to answer my own questions on SO, but hopefully this will help someone else.
Plain Vim loads the plugin scripts in alphabetical order. This is from :help load-plugins
... all directories in the 'runtimepath' option will be
searched for the "plugin" sub-directory and all files ending in ".vim"
will be sourced (in alphabetical order per directory), also in
subdirectories.
So you can set plugin loading order by renaming <filetype>_plugin.vim to <filetype>/35plugin.vim. 35 is your desired loading order. I think this should work with Pathogen too by renaming the plugin directories inside bundle, but I haven't tested it.
I'm still looking for a more general answer to this load-order issue
As far as I know, you can't really do it with Pathogen. It is really easy with NeoBundle. Pathogen is really minimal, it doesn't provide you with a lot of flexibility - it does only one thing and does it well. If you're looking for configurability, I think you're using the wrong tool.
EDIT: Not really sure about ftplugins, but bundles in general are loaded as you specify them (with Vundle/NeoBundle). So I realise that this maybe is not the most relevant of answers.

Resources