jakenvac / nvim-textmate-macos

A textmate-based syntax highlighter for neovim on MAC OS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvim-textmate-macos

A fork of icedman/nvim-textmate to work on Mac OS.

A textmate-based syntax highlighter to nvim - Uses VS code syntax themes/syntax extensions.

Screen Shot

Setup

Building

This plugin uses a native module and must first be compiled.

Note

If you use the lazy.nvim example below, this will all be done for you.

Warning

Run these commands in the installed location of your plugin. For example with lazy.nvim as your plugin manager: ~/share/nvim/lazy/nvim-textmate-macos

Firstly, ensure you have python, luajit, cmake & pkg-config installed:

brew install luajit cmake pkg-config python

Next, make sure homebrew libraries are available to pkg-config:

export PKG_CONFIG_PATH="$(brew --prefix)"/lib/pkg-config:$PKG_CONFIG_PATH"

Now we're ready to build:

make

You can make sure the build output is in the right place with:

stat ./lua/nvim-textmate-macos/textmate.dylib

Config with lazy.nvim

return {
	"jakenvac/nvim-textmate-macos",
    -- these are the default options
    -- when using a different plugin manager use the setup function outlined below
	opts = {
        quick_load = false,
        theme_name = "Monokai",
        override_colorscheme = false,
        debug_scopes = false,
        custom_scope_map = nil,
        extension_paths = {
        	"~/.vscode/extensions/",
        	"~/.editor/extensions/",
        }
    },
    build = {
        "brew install luajit cmake pkg-config",
        'export PKG_CONFIG_PATH="$(brew --prefix)"/lib/pkg-config:$PKG_CONFIG_PATH',
        "make"
        "stat ./lua/nvim-textmate-macos/textmate.dylib"
    },
    -- It is recommended to only load for required file types due to potential slowdown
    ft = {
        "d2",
        "lua"
    }
}

Other plugin managers

require('nvim-textmate').setup({
    quick_load = true,
    -- ...
})

setup options

  • quick_load - defers loading of grammar and theme at the opening of a buffer
  • theme_name - select a textmate format or vscode compatible theme
  • override_colorscheme - apply colorscheme from textmate theme
  • custom_scope_map - add more scope to namespace mapping (see colormap.lua)
  • extension_paths - set vscode extension search path
  • debug_scopes - print scope name under cursor

extensions

Copy vscode theme and grammar extensions to any of these directories:

~/.config/nvim/lua/nvim-textmate/
~/.editor/extensions/
~/.vscode/extensions/

commands

  • TxMtEnable
  • TxMtDisable
  • TxMtToggle
  • TxMtTheme
  • TxMtDebugScopes

known issues

  • a colorscheme must be loaded prior to running nvim-textmate
  • cpp - Some grammars take a bit of time to load. cpp, the largest grammar file causes a visible lag on first load; hence the quick_load option is available.
  • markdown - Other grammars - like markdown will load other grammar languages for inline code and will re-render after the other languages are loaded.
  • scrolling and text editing - syntax highlighting is currently done at these events as a debounced (defer_fn) function.

warning

  • This plugin is just a proof of concept - from a novice lua coder, and much worse - from a non neovim user (not yet at least)

About

A textmate-based syntax highlighter for neovim on MAC OS

License:GNU General Public License v2.0


Languages

Language:C 56.9%Language:JavaScript 33.0%Language:C++ 7.9%Language:Python 1.0%Language:Ruby 0.4%Language:CMake 0.2%Language:Makefile 0.1%Language:SCSS 0.1%Language:Lua 0.1%Language:Shell 0.1%Language:Meson 0.0%Language:HTML 0.0%Language:TypeScript 0.0%Language:Groovy 0.0%Language:CSS 0.0%Language:Perl 0.0%Language:M4 0.0%Language:PowerShell 0.0%Language:Objective-C 0.0%Language:Go 0.0%Language:Clojure 0.0%Language:PHP 0.0%Language:Handlebars 0.0%Language:Less 0.0%Language:Starlark 0.0%Language:Visual Basic .NET 0.0%Language:F# 0.0%Language:CoffeeScript 0.0%Language:Java 0.0%Language:Batchfile 0.0%Language:Rust 0.0%Language:C# 0.0%Language:Dockerfile 0.0%Language:R 0.0%Language:ShaderLab 0.0%Language:Swift 0.0%Language:Pug 0.0%