Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

jackokring/doris.nvim

Open more actions menu
 
 

Repository files navigation

A Neovim plugin Mk II

GitHub Workflow Status Lua

     _            _                  _
  __| | ___  _ __(_)___   _ ____   _(_)_ __ ___
 / _` |/ _ \| '__| / __| | '_ \ \ / / | '_ ` _ \
| (_| | (_) | |  | \__ \_| | | \ V /| | | | | | |
 \__,_|\___/|_|  |_|___(_)_| |_|\_/ |_|_| |_| |_|

A template for possible Neovim plugins. It is extended somewhat by me from ellisonleao/nvim-plugin-template to include the basic features of a plugin and possibly some useful additions, definitions and functions.

I just though I'd say remapping insert mode <C-\\> to <esc>a has much improved my nvim experience as it can be used to close the LSP completion dropdown, and so not interfere with use of the actual cursor keys. By default the cursor keys move up and down the LSP completions and not up and down the document. Some purists might say go to normal mode and move about.

The key <C-\\> is actually mapped to some other stuff which I've never used and am not likely to use. I'm still a fan of o instead of i. I like "output". A<cr> was a thing for a while. I'm sure hjkl are right for some, but I'd be happier if the left and right arrows would flow past the beginning and end of lines. It's not "normal." I'm looking into luaSnip now, as I am now enthused enough about not being driven to OCD LSP hell.

I know <C-e> is supposed to be used for this, but on an ISO keyboard, the single finger or tiny motion <C-\\> is possible.

Oh, and I mapped <C-s> to save all buffers keeping the mode, and <C-z> to revert from file, defaulting to a "normal" start. Nice to see formatting of indents auto magical happens on save. The keys [s, zg and z= replace much of what r does. But on with the show.

Novaride

I've added doris/novaride to control the namespace _G. It sets up a proxy to manage override attempts via __newindex. As a consequence of it being just a simple extension of code available online, you can also .track(t) any other tables for protection from overrides. Don't forget to nv() novaride to unnest the protection, and regain a slight amount of speed from removing the protection "virtualization."

It allows local nv = require("doris.novaride").setup() ... and at the end just before return M (or whatever the module is called) a nv(). Added in .untrack(t) which returns a table untracked.

This is a very useful require(), and also manages locale state C. Something in the way some locales may prevent parsing correctly. It's also ǹvim clever, so it doesn't flood fill the loading debug.

Async

A pass-through into the _G namespace of much coroutine things. It's not advanced, and much is from the programming in Lua examples with type definitions to make things easier.

Class

Various classes placed in the _G context. This is a modified plenary OOP library. Everyone's class implementation in Lua is kind of strange.

Util

Miscellaneous utilities such as script_path() to get the path of any script, and shell_quote() for os.system() by the classic '\'' method using '...' for single quote concatenation.

Audio

An audio library for making sounds. It works by making an output stream via a C binary, and piping it into pw-play (pipewire play). The generator audio <args> is a 3 oscillator exponential FM, with a filter per oscillator, and drift that can be applied to volume, frequency and filter cut-off.

So 6 parameter oscillators can be set up with osc() and played with play(), taking a length in seconds and upto 3 oscillators.

Also added say() to use voice synthesis using the espeak-ng package.

Using it

Via lazy.nvim:

return {
  "jackokring/doris.nvim",
  build = "./build.sh"
}

Then require("doris") for all things except require("doris.novaride").setup() with nv() of the .setup() local at the end of a file using Novaride.

This is because Novaride is a utility to check namespace security between its .setup() and nv().

Development

Configuration for development requires using a local redirect similar to the changes below. This then uses the local version based on dir as the location of the repository.

-- doris plugin loader for nvim
return {
  "jackokring/doris.nvim",
  -- **local build**
  dev = true,
  dir = "~/projects/doris.nvim",
  fallback = true,
  -- **build command**
  build = "./build.sh",
  -- **setup options**
  opts = {},
  -- **lazy load info**
  -- lazy = true,
  -- **on event**
  -- event = { "BufEnter", "BufEnter *.lua" },
  -- **on command use**
  -- cmd = { "cmd" },
  -- **on filetype**
  -- ft = { "lua" },
  -- **on keys**
  -- keys = {
  --    -- key tables
  --    {
  --      "<leader>ft",
  --      -- "<cmd>Neotree toggle<cr>",
  --      -- desc = "NeoTree",
  --      -- mode = "n",
  --      -- ft = "lua"
  --    },
  --  },
}

:Lazy reload doris.nvim to bring it upto date by a reload

Features and structure

  • 100% Lua
  • Github actions for:
    • running tests using plenary.nvim and busted
    • check for formatting errors (Stylua)
    • vimdocs auto-generation from README.md file
    • luarocks release (LUAROCKS_API_KEY secret configuration required) this is done by registration with luarocks, getting a LUAROCKS_API_KEY then adding it to the security settings option for secrets.

Features To Do

  • Novaride lua/doris/novaride.lua global namespace anti-clobber
  • More pure help functions in lua/doris/module.lua with pass through
  • Pass through of plenary selected modules using short names
  • Simple Bus module for attachment of functions to signals
  • Output window 80*24 with keyboard capture callback
    • Cursor keys still need redirect
    • "Ghost" character to "use" cursor visibility (normal mode)
    • Tested
  • Audio format:
    • len vol freq filt vol.drift freq.drift filt.drift [mod ...]
  • Network client server for multiplayer
    • Tested
    • Three player
  • Documentation of new additions
  • A mini-game to play using nerd font glyphs
  • A .js file to pass joypad from a browser to a TCP socket for home row keys
  • Investigate .py control of nvim --embed for features
    • For local AI players maybe or just use network layer
  • Added in a template for adding in C native .so production
  • ...

Plugin structure

So plugin/doris.lua loads commands. Main reference is lua/doris.lua with modules in lua/doris keeping all the detail out of the base plugin file.

.
├── lua
│   ├── doris
│   │   ├── audio.lua (pure lua and C audio needs "pw-play")
│   │   ├── util.lua (pure lua utilities)
│   │   ├── novaride.lua (pure lua global context protection)
│   │   └── object.lua (pure plenary lua OOP and functionals)
│   └── doris.lua (nvim lua main module)
├── c
│   ├── audio.c (audio from args "./audio [arg ...]| pw-play --channels=1 -&")
│   ├── doris.c (lua C library)
│   └── doris.h (header for lua C library)
├── build.sh (shell script to compile C shared doris.so)
├── freeze.sh (shell script to freeze venv and extras)
├── require.sh (shell script to make python venv from git pull)
├── yes-no.sh (shell script to get a yes or no)
├── xdg.sh (shell script to include for XDG directories)
├── Makefile (for tests and build)
├── plugin
│   └── doris.lua (nvim new commands loaded)
├── README.md (auto-generation of doc/doris.txt from it)
├── tests
│   ├── minimal_init.lua (test base configuration)
│   └── doris
│       └── doris_spec.lua (tests of doris using plenary)

Sponsor this project

 

Languages

  • Lua 80.9%
  • C 12.7%
  • Shell 5.8%
  • Makefile 0.6%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.