Gnuplot syntax highlighting for Vim
April 23, 2022 ยท View on GitHub
I built this package from the ground up as a follow up to the work made by James Eberle and Andrew Rasmussen.
Notice
The aim of this package is to provide up-to-date support for gnuplot syntax. I'm basing the support for gnuplot 5.5 which is currently in development.
Installation
Using a plugin manager
This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers:
| Plugin Manager | Install with... |
|---|---|
| Pathogen | git clone https://github.com/dpezto/gnuplot.vim ~/.vim/bundle/gnuplot |
| Vundle | Plugin 'dpezto/gnuplot.vim' |
| Plug | Plug 'dpezto/gnuplot.vim' |
| minpac | call minpac#add('dpezto/gnuplot.vim') |
| pack feature (native Vim 8 package feature) | git clone https://github.com/dpezto/gnuplot.vim ~/.vim/pack/plugins/start/gnuplot |
Manual installation
In order to have vim automatically detect gnuplot files, you need to have
ftplugins enabled (e.g. by having this line in your .vimrc file:
:filetype plugin on
The plugin already sets up some logic to detect gnuplot files. In order that the
gnuplot filetype plugin is loaded correctly, vim needs to be enabled to load
filetype-plugins. This can be ensured by putting a line like this in your
.vimrc:
:filetype plugin on
(see also :filetype-plugin-on).
In case this did not work, you need to setup vim like this:
To have Vim automatically detect gnuplot files, you need to do the following.
-
Create your user runtime directory if you do not have one yet. This directory needs to be in your 'runtime' path. In Unix this would typically the ~/.vim directory, while in Windows this is usually your
/vimfiles directory. Use :echo expand("") to find out, what Vim thinks your user directory is. To create this directory, you can do::!mkdir ~/.vimfor Unix and
:!mkdir ~/vimfilesfor Windows.
-
In that directory you create a file that will detect gnuplot files.
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufNewFile,BufRead *.plt,*.plot,*.gnuplot,*.gnu,*.gp setf gnuplot
augroup END
You save this file as "filetype.vim" in your user runtime diretory:
:w ~/.vim/filetype.vim
- To be able to use your new filetype.vim detection, you need to restart Vim. Vim will then load the gnuplot filetype plugin for all files whose names end with .plt, .plot, .gnuplot, .gnu, .gp.
Status
This began as a personal project since I prefer the results of the plots made with gnuplot, so most of the syntax currently in the file is for my use case. Despite this, the package can handle almost all use cases of gnuplot. I'm looking forward to refine the syntax highlighting.