plugin intelligence

lean
pegasust 2023-07-25 13:24:49 -07:00
parent 7914c40d91
commit fd4ff2cbbc
8 changed files with 65 additions and 16 deletions

View File

@ -0,0 +1,9 @@
# Local nixlib in `nix repl`
Pretty useful for airplane-driven development
```console
nixlib = import <nixpkgs/lib>
nix-repl> nixlib.genAttrs
«lambda @ /nix/var/nix/profiles/per-user/root/channels/nixpkgs/lib/attrsets.nix:619:5»
```

View File

@ -3,7 +3,7 @@
The current [`scripts/vim.dsl`](../scripts/vim.dsl) grabs the upstream supported vim plugins
onto a sqlite database to be stored in memory. We could perform some data exploration via this database
## Explore which plugins should be added to `neovim.nix`
## Example: Explore which plugins should be added to `neovim.nix`
Gather list of plugins need to be added. This can be done simply by adding
a print statement on `WPlug` in `../native_configs/neovim/init.lua` then run neovim

View File

@ -56,7 +56,7 @@
# modules = ./nix/modules;
cellBlocks = let
inherit (std.blockTypes) devshells functions anything installables;
inherit (std.blockTypes) devshells functions anything installables runnables;
in [
(devshells "devshells")
(devshells "userShells")
@ -65,6 +65,7 @@
(anything "home-configs")
(installables "packages")
(anything "lib")
(runnables "formatter")
];
}
{
@ -76,5 +77,6 @@
# TODO: Debug only
homeProfiles = std.pick self [["repo" "home-profiles"]];
formatter = std.harvest self [["repo" "formatter"]];
};
}

View File

@ -18,12 +18,13 @@ endif
local Plug = vim.fn['plug#']
-- prepare a list of installed plugins from rtp
--- @type table<string, boolean>
local installed_plugins = {}
-- NOTE: nvim_list_runtime_paths will expand wildcard paths for us.
for _, path in ipairs(vim.api.nvim_list_runtime_paths()) do
local last_folder_start = path:find("/[^/]*$")
if last_folder_start then
local plugin_name = path:sub(last_folder_start + 1)
local plugin_name = string.lower(path:sub(last_folder_start + 1))
installed_plugins[plugin_name] = true
end
end
@ -31,13 +32,23 @@ end
local wplug_log = require('plenary.log').new({ plugin = 'wplug_log', level = 'debug', use_console = false })
-- Do Plug if plugin not yet linked in `rtp`. This takes care of Nix-compatibility
local function WPlug(plugin_path, ...)
-- hrsh7th/cmp-nvim -> cmp-nvim
local plugin_name = string.lower(plugin_path:match("/([^/]+)$"))
if not installed_plugins[plugin_name] then
wplug_log.info("Plugging " .. plugin_path)
wplug_log.info("Missing in rtp: " .. plugin_name .. " path: " .. plugin_path)
Plug(plugin_path, ...)
end
installed_plugins[plugin_name] = false
end
-- Borked, reason unknown
-- for plugin, plugged in pairs(installed_plugins) do
-- if plugged ~= false then
-- wplug_log.info("Plugin " .. plugin .. " added to rtp but not WPlug-ed")
-- end
-- end
vim.call('plug#begin')
-- libs and dependencies
@ -943,7 +954,12 @@ local setup = {
settings = {
["nil"] = {
formatting = {
command = { "nix", "run", "nixpkgs#alejandra" },
-- NOTE: nil_ls automatically adds the specific path to the filename
-- at the end, so we couldn't really have a fallback mechanism without
-- wrapping.
command = {
"nix", "run", "nixpkgs#alejandra"
},
},
nix = {
flake = {

5
nix/repo/formatter.nix Normal file
View File

@ -0,0 +1,5 @@
{
inputs,
cell,
}:
inputs.nixpkgs.alejandra

View File

@ -84,6 +84,16 @@ in {
# NOTE: this adds path to the wrapped version of neovim
extraPackages = nvim_pkgs;
extraLuaConfig = builtins.readFile "${inputs.self}/native_configs/neovim/init.lua";
/*
* type: (either derivation pluginWithConfigType)
* pluginWithConfigType {
* config: nullOr lines,
* type: enum[],
* optional: (mkType (mkDefault false) bool), # Don't load by default (:packadd)
* plugin: package,
* runtime: (mkType (mkDefault {}) {?})
* }
*/
plugins = let
inherit
(inputs.nixpkgs-latest.legacyPackages.${system}.vimPlugins)

View File

@ -1,4 +1,7 @@
{inputs, cell}: let
{
inputs,
cell,
}: let
# decorator for now, for data collecting :)
nix-conf = a: a;
in {
@ -9,7 +12,7 @@ in {
trusted-users = root htran hungtran hwtr
max-jobs = 8
cores = 12
# default is true for Linux, false for every one else
# default is true for Linux, false for every one else
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-sandbox
sandbox = true
'';
@ -20,7 +23,7 @@ in {
trusted-users = root htran hungtran hwtr
max-jobs = 7
cores = 8
# default is true for Linux, false for every one else
# default is true for Linux, false for every one else
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-sandbox
sandbox = true
'';

View File

@ -1,4 +1,7 @@
#!/usr/bin/env python3 # A simple playground to explore vim plugins that are available in nixpkgs
#!/usr/bin/env python3
"""
A simple playground to explore vim plugins that are available in nixpkgs
"""
import csv
import urllib.request
@ -45,11 +48,11 @@ class VimPlugins:
return self.conn.cursor().execute(query).fetchall()
def vim_plugin_slug(name: str):
def vim_plugin_slug(name: str) -> str:
return name.replace(".", "-").lower()
def name_from_repo(repo: str):
def name_from_repo(repo: str) -> str:
spl = repo.split("/")
return vim_plugin_slug(spl[-1] or spl[-2])
@ -86,7 +89,8 @@ L3MON4D3/LuaSnip
arthurxavierx/vim-caser
~/local_repos/ts-ql
""".split()
need_install_plugins = [plugin.strip() for plugin in need_install_plugins if plugin.strip()]
need_install_plugins = [plugin.strip()
for plugin in need_install_plugins if plugin.strip()]
# Create the GitHub URL list
need_install_plugins_gh = [
@ -104,7 +108,7 @@ arthurxavierx/vim-caser
# Check if the repo is not in the list
repos = [repo for repo, _ in values]
not_in_repo = [name_from_repo(gh) for gh in need_install_plugins_gh if gh not in repos]
print("not in repo", not_in_repo) # nvim-yati, yang-vim, Comment-nvim, inlay-hints-nvim, hlargs-nvim, vim-caser, gruvbox-community
not_in_repo = [name_from_repo(
gh) for gh in need_install_plugins_gh if gh not in repos]
# nvim-yati, yang-vim, Comment-nvim, inlay-hints-nvim, hlargs-nvim, vim-caser, gruvbox-community
print("not in repo", not_in_repo)