Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

uga-rosa/scorpeon.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WIP

example

scorpeon.vim

Syntax highlight using VSCode's textmate grammar as is.

VSCode is the most popular editor in the world and is officially supported by the largest number of language developers. This plugin allows VSCode's syntax highlighting definitions to be used directly in vim/neovim.

Requirements

Usage

This plugin can use the directory structure of VSCode extensions as it is. Since VSCode's main body includes extensions for many well-known languages, I recommend to use it.

To manage manually, do the following.

git clone https://github.com/microsoft/vscode.git --depth 1
mkdir -p ~/.cache/scorpeon
mv vscode/extensions ~/.cache/scorpeon

Any VSCode extension can be easily added.

# Add support for Nim.
git clone https://github.com/saem/vscode-nim.git ~/.cache/scorpeon/extensions/nim

You must define the following variable.

" string or an array of string
let g:scorpeon_extensions_path = expand('~/.cache/scorpeon/extensions')

You can also use the plugin manager to manage them. See advanced settings.

You can enable/disable highlight with the following commands. Enabling highlight is buffer-local.

:ScorpeonHighlightEnable
:ScorpeonHighlightDisable

g:scorpeon_highlight can be set to automatically enable it for specific file types.
enable is a boolean or an array. Default enable is v:false. Highlight is enabled when the an array enable contains &ft or a boolean enable is v:true.
disable is meaningful when the result of enable evaluate to v:true. disable is an array or a function (no arguments). Default disable is []. If an array disable contains &ft or the function disable returns truthy, highlight is not enabled.
In the following example, it is only enabled when the file type is typescript or nim and the file size is less than 1MB.

let g:scorpeon_highlight = {
      \ 'enable': ['typescript', 'nim'],
      \ 'disable': { -> getfsize(expand('%')) > 1 * 1024 * 1024 }
      \}

Customize

You can customize default rule via defining highlight group. See plugin/scorpeon.vim for default definitions. Highlight names correspond to scope names, and the general naming convention for scope names can be found here (12.4).

It can be customized by specifying a highlight group corresponding to the scope name. For example, the following configuration will highlight commented parts of typescript with Error.

let g:scorpeon_rule = {
      \ 'source.ts': {
      \   'comment': 'Error'
      \ }
      \}

This command is useful to find out the scope name.

:ScorpeonShowScope

Advanced settings

Managing extensions with dein.vim

Here is an example of managing with dein.vim.

let $CACHE = expand('~/.cache')
let g:scorpeon_extensions_path = [
  \ expand('$CACHE/vscode/extensions'),
  \ expand('$CACHE/scorpeon'),
  \ ]
[[plugins]]
repo = 'microsoft/vscode'
if = 0
merged = 0
type__depth = 1
path = '$CACHE/vscode'

[[plugins]]
repo = 'oovm/vscode-toml'
if = 0
merged = 0
type__depth = 1
path = '$CACHE/scorpeon/toml'

[[plugins]]
repo = 'emilast/vscode-logfile-highlighter'
if = 0
merged = 0
type__depth = 1
path = '$CACHE/scorpeon/log'

About

Syntax highlight using VSCode's textmate grammar as is.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published