home/nvim: a better require system + type defs

This commit is contained in:
chayleaf 2023-03-16 23:37:57 +07:00
parent 15e7be9a24
commit 049c95bd9f
13 changed files with 406 additions and 9869 deletions

View file

@ -21,7 +21,7 @@ in {
rust-analyzer
nodePackages.bash-language-server shellcheck
nodePackages.typescript-language-server
clang-tools
clang-tools_latest
nodePackages.vscode-langservers-extracted
nil
marksman

View file

@ -21,7 +21,7 @@ in {
rust-analyzer
nodePackages.bash-language-server shellcheck
nodePackages.typescript-language-server
clang-tools
clang-tools_latest
nodePackages.vscode-langservers-extracted
nil
marksman

View file

@ -85,7 +85,7 @@
else if func.__kind == "prop" then
"${wrapExpr (compileExpr sc func.expr)}.${func.name}"
else if func.__kind == "call" then
"${wrapExpr (compileExpr sc func.func)}(${builtins.concatStringsSep ", " (map (compileExpr sc) (if builtins.isList func.args then func.args else [func.args]))})"
"${wrapExpr (compileExpr sc func._func)}(${builtins.concatStringsSep ", " (map (compileExpr sc) (if builtins.isList func._args then func._args else [func._args]))})"
else if func.__kind == "mcall" then
"${wrapExpr (compileExpr sc func.val)}:${func.name}(${builtins.concatStringsSep ", " (map (compileExpr sc) (if builtins.isList func.args then func.args else [func.args]))})"
else if func.__kind == "tableAttr" then
@ -167,7 +167,7 @@
# Call a function
# corresponding lua code: someFunc()
# expr -> [args] -> expr | expr -> arg1 -> expr
call = func: args: { __kind = "call"; inherit func args; };
call = func: args: { __kind = "call"; _func = func; _args = args; };
# Call a method
# corresponding lua code: someTable:someFunc()
@ -232,12 +232,14 @@
bindrec = vals: func: if builtins.isList vals then { __kind = "letrec"; inherit vals func; } else bindrec [ vals ] func;
# "type definitions" for neovim
defs = pkgs.callPackage ./vim-opts.nix { inherit raw call; };
defs = pkgs.callPackage ./vim-opts.nix { inherit raw call; plugins = config.programs.neovim.plugins; };
reqbind = name: func: bind [ (defs.require name) ] (result: func (defs._reqbind name result._name));
in with defs; let
require = name: call (var "require") [ name ];
setup = plugin: opts: call (prop plugin "setup") [ opts ];
# require = name: call (var "require") [ name ];
# setup = plugin: opts: call (prop plugin "setup") [ opts ];
# vimfn = name: call (raw "vim.fn.${name}");
vimcmd = name: call (raw "vim.cmd.${name}");
vimg = name: prop vim.g name;
keymapSetSingle = opts@{
mode,
lhs,
@ -267,12 +269,16 @@
in (lib.mapAttrsToList (k: {rhs, desc}: keymapSetSingle (opts' // {
lhs = k; inherit rhs;
})) keys) ++ [
(call (prop (require "which-key") "register") [(lib.mapAttrs (k: v: [v.rhs v.desc]) keys) opts'])
(which-key.register [(lib.mapAttrs (k: v: [v.rhs v.desc]) keys) opts'])
];
keymapSetNs = args: keymapSetMulti (args // { mode = "n"; });
kmSetNs = keys: keymapSetNs { inherit keys; };
keymapSetVs = args: keymapSetMulti (args // { mode = "v"; });
kmSetVs = keys: keymapSetVs { inherit keys; };
which-key = req "which-key";
luasnip = req "luasnip";
cmp = req "cmp";
in {
enable = true;
defaultEditor = true;
@ -282,7 +288,7 @@
nodePackages_latest.bash-language-server shellcheck
nodePackages_latest.typescript-language-server
nodePackages_latest.svelte-language-server
clang-tools
clang-tools_latest
nodePackages_latest.vscode-langservers-extracted
nil
marksman
@ -298,11 +304,12 @@
];
# extraPython3Packages = pyPkgs: with pyPkgs; [
# ];
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraLuaConfig = (compile "main" [
(set vim.g.vimsyn_embed "l")
(vim.api.nvim_set_hl [ 0 "NormalFloat" {
bg = "NONE";
}])
(set (vimg "vimsyn_embed") "l")
(bind (vim.api.nvim_create_augroup [ "nvimrc" { clear = true; } ]) (group:
map (au: let au' = lib.filterAttrs (k: v: k != "event") au;
in vim.api.nvim_create_autocmd [ au.event ({
@ -311,10 +318,12 @@
) [
{ event = "FileType";
pattern = ["markdown" "gitcommit"];
# must be a string
callback = defun (set vim.o.colorcolumn "73"); }
{ event = "FileType";
pattern = ["markdown"];
callback = defun (set vim.o.textwidth "72"); }
# must be a number...
callback = defun (set vim.o.textwidth 72); }
{ event = "BufReadPre";
callback = defun (set vim.o.foldmethod "syntax"); }
{ event = "BufWinEnter";
@ -322,13 +331,13 @@
(bind (vim.filetype.match { inherit buf; }) (filetype: [
(vimcmd "folddoc" [ "foldopen!" ])
(ifelse [(eq filetype "gitcommit") [
(vim.cmd {
(call vim.cmd {
cmd = "normal";
bang = true;
args = [ "gg" ];
})
]]
(vim.cmd {
(call vim.cmd {
cmd = "normal";
bang = true;
args = [ "g`\"" ];
@ -337,13 +346,10 @@
])); }
])) # END
]);
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
plugins = with pkgs.vimPlugins; map (x: if x?config && x?plugin then { type = "lua"; } // x else x) [
vim-svelte
plugins = let ps = pkgs.vimPlugins; in map (x: if x?config && x?plugin then { type = "lua"; } // x else x) [
ps.vim-svelte
# TODO remove on next nvim update (0.8.3/0.9)
vim-nix
ps.vim-nix
{ plugin = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "vscode-nvim";
version = "2023-02-10";
@ -354,7 +360,8 @@
sha256 = "sha256-X2IgIjO5NNq7vJdl09hBY1TFqHlsfF1xfllKr4osILI=";
};
};
config = compile "vscode_nvim" (setup (require "vscode") {
config = compile "vscode_nvim" [
((req "vscode").setup {
transparent = true;
color_overrides = {
vscGray = "#745b5f";
@ -371,25 +378,29 @@
vscYellow = "#${config.colors.yellow}";
vscPink = "#cf83c4";
};
}); }
{ plugin = nvim-web-devicons;
config = compile "nvim_web_devicons" (setup (require "nvim-web-devicons") {}); }
{ plugin = nvim-tree-lua;
})
(vim.api.nvim_set_hl [ 0 "NormalFloat" {
bg = "NONE";
}])
]; }
{ plugin = ps.nvim-web-devicons;
config = compile "nvim_web_devicons" ((req "nvim-web-devicons").setup {}); }
{ plugin = ps.nvim-tree-lua;
config = compile "nvim_tree_lua" [
(set vim.g.loaded_netrw 1)
(set vim.g.loaded_netrwPlugin 1)
(set vim.opt.termguicolors true)
(setup (require "nvim-tree") {}) # :help nvim-tree-setup
(set (vimg "loaded_netrw") 1)
(set (vimg "loaded_netrwPlugin") 1)
(set vim.o.termguicolors true)
((req "nvim-tree").setup {}) # :help nvim-tree-setup
(kmSetNs {
"<C-N>" = {
rhs = prop (require "nvim-tree.api") "tree.toggle";
rhs = (req "nvim-tree.api").tree.toggle;
desc = "Toggle NvimTree";
};
})
]; }
vim-sleuth
luasnip
{ plugin = nvim-cmp;
ps.vim-sleuth
ps.luasnip
{ plugin = ps.nvim-cmp;
config = let
border = (name: [
[ "" name ]
@ -401,10 +412,11 @@
[ "" name ]
[ "" name ]
]);
in compile "nvim_cmp" (bind (require "cmp") (cmp:
(setup cmp {
in compile "nvim_cmp" (reqbind "cmp" (cmp:
# call is required because cmp.setup is a table
(call cmp.setup {
snippet = {
expand = { body, ... }: call (prop (require "luasnip") "lsp_expand") body;
expand = { body, ... }: luasnip.lsp_expand body;
};
view = { };
window = {
@ -420,85 +432,77 @@
format = _: vim_item: let kind = prop vim_item "kind"; in [
(set
kind
(string.format ([
(string.format [
"%s %s"
(tableAttr (require "lspkind") kind)
(tableAttr (req "lspkind") kind)
kind
])))
]))
(return vim_item)
];
};
mapping = {
"<C-p>" = call (prop cmp "mapping.select_prev_item") [];
"<C-n>" = call (prop cmp "mapping.select_next_item") [];
"<C-space>" = call (prop cmp "mapping.complete") [];
"<C-e>" = call (prop cmp "mapping.close") [];
"<cr>" = call (prop cmp "mapping.confirm") {
behavior = prop cmp "ConfirmBehavior.Replace";
"<C-p>" = cmp.mapping.select_prev_item [];
"<C-n>" = cmp.mapping.select_next_item [];
"<C-space>" = cmp.mapping.complete [];
"<C-e>" = cmp.mapping.close [];
"<cr>" = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace;
select = false;
};
"<tab>" = call (prop cmp "mapping") [(fallback:
(ifelse [
[(call (prop cmp "visible") [])
# then
(call (prop cmp "select_next_item") [])]
[(call (prop (require "luasnip") "expand_or_jumpable") [])
# then
"<tab>" = call cmp.mapping [(fallback:
(ifelse [[(cmp.visible [])
(cmp.select_next_item [])]
/*elseif*/ [(luasnip.expand_or_jumpable [])
(vim.api.nvim_feedkeys [
(vim.api.nvim_replace_termcodes [ "<Plug>luasnip-expand-or-jump" true true true ])
""
false
])
]]
# else
]] # else
(call fallback [])
))
[ "i" "s" ]
];
"<S-tab>" = call (prop cmp "mapping") [(fallback:
(ifelse [
[(call (prop cmp "visible" ) [])
# then
(call (prop cmp "select_prev_item") [])]
[(call (prop (require "luasnip") "jumpable") [ (-1) ])
# then
"<S-tab>" = call cmp.mapping [(fallback:
(ifelse [[(cmp.visible [])
(cmp.select_prev_item [])]
/*elseif*/ [(luasnip.jumpable [ (-1) ])
(vim.api.nvim_feedkeys [
(vim.api.nvim_replace_termcodes [ "<Plug>luasnip-jump-prev" true true true ])
""
false
])
]]
# else
]] # else
(call fallback [])
))
[ "i" "s" ]
];
};
sources = call (prop cmp "config.sources") [[
sources = cmp.config.sources [[
{ name = "nvim_lsp"; }
{ name = "luasnip"; }
]];
})
)); }
lspkind-nvim
cmp_luasnip
cmp-nvim-lsp
{ plugin = nvim-autopairs;
config = compile "nvim_autopairs" (bind (require "nvim-autopairs.completion.cmp") (cmp_autopairs: [
(setup (require "nvim-autopairs") {
ps.lspkind-nvim
ps.cmp_luasnip
ps.cmp-nvim-lsp
{ plugin = ps.nvim-autopairs;
config = compile "nvim_autopairs" (reqbind "nvim-autopairs.completion.cmp" (cmp_autopairs: [
((req "nvim-autopairs").setup {
disable_filetype = [ "TelescopePrompt" "vim" ];
})
(mcall (prop (require "cmp") "event") "on" [
(mcall cmp.event "on" [
"confirm_done"
(call (prop cmp_autopairs "on_confirm_done") [])
(cmp_autopairs.on_confirm_done [])
])
])); }
{ plugin = comment-nvim;
{ plugin = ps.comment-nvim;
config = compile "comment_nvim" [
(setup (require "Comment") {})
((req "Comment").setup {})
(kmSetNs {
"<space>/" = {
rhs = prop (require "Comment.api") "toggle.linewise.current";
rhs = prop (req "Comment.api").toggle "linewise.current";
desc = "Comment current line";
};
})
@ -509,8 +513,8 @@
};
})
]; }
{ plugin = nvim-lspconfig;
config = compile "nvim_lspconfig" (let setupLsp = lsp: setup (prop (require "lspconfig") lsp); in [
{ plugin = ps.nvim-lspconfig;
config = compile "nvim_lspconfig" (let setupLsp = lsp: builtins.seq (req "lspconfig.server_configurations.${lsp}") (call (prop (req "lspconfig") "${lsp}.setup")); in [
# See `:help vim.diagnostic.*` for documentation on any of the below functions
(kmSetNs {
"<space>e" = {
@ -561,7 +565,7 @@
desc = "Remove a folder from the workspace folders."; };
"<space>wl" = {
rhs = (defun (print [
(vim.inspect [(vim.lsp.buf.list_workspace_folders [])])
(call vim.inspect [(vim.lsp.buf.list_workspace_folders [])])
]));
desc = "List workspace folders."; };
"<space>D" = {
@ -592,7 +596,7 @@
(vim.tbl_extend [
"keep"
(vim.lsp.protocol.make_client_capabilities [])
(call (prop (require "cmp_nvim_lsp") "default_capabilities") [])
((req "cmp_nvim_lsp").default_capabilities [])
])
# BEGIN
] (on_attach: rust_settings: capabilities: [
@ -600,12 +604,13 @@
# LETREC on_attach_rust
(on_attach_rust: client: bufnr: [
(vim.api.nvim_create_user_command ["RustAndroid" (opts: [
(vim.lsp.set_log_level "debug")
(setupLsp "rust_analyzer" {
on_attach = on_attach_rust;
inherit capabilities;
settings = vim.tbl_deep_extend [
"keep"
{ rust-analyzer.cargo.target = "x86_64-linux-android"; }
config.rustAnalyzerAndroidSettings
rust_settings
];
})
@ -642,11 +647,11 @@
]))) # END
])) # END
]); }
{ plugin = which-key-nvim;
{ plugin = ps.which-key-nvim;
config = compile "which_key_nvim" [
(set vim.o.timeout true)
(set vim.o.timeoutlen 500)
(setup (require "which-key") {})
(which-key.setup {})
]; }
];
};

View file

@ -1,39 +1,155 @@
-- globals.lua
-- list all global variables
-- :enew|pu=execute('luafile /path/to/file.lua')
-- list vim vars
-- :new | put! =getcompletion('*', 'var')
-- list events
-- :new | put! =getcompletion('*', 'event')
-- list options
-- :new | put! =getcompletion('*', 'option')
local seen = {}
function dump(t,i)
seen[t]=true
local s={}
local n=0
for k in pairs(t) do
n=n+1 s[n]=k
local result = {}
local function dump2(t, path, res)
seen[t] = path
if path ~= "" then
path = path.."."
end
for k,v in pairs(t) do
k = tostring(k)
if path ~= "" or k ~= "package" then
if type(v) == "table" then
if seen[v] then
if not res[k] then
res[k] = { __kind = "rec", path = seen[v] }
end
else
if not res[k] then
res[k] = {}
end
res[k].__kind = "var"
res[k]._type = "table"
res[k]._name = path..k
dump2(v, path..k, res[k])
end
elseif type(v) == "function" then
local info = debug.getinfo(v)
res[k] = {
__kind = "var",
_name = path..k,
_type = "function",
_minArity = info.nparams
}
if not info.isvararg then
res[k]["maxArity"] = info.nparams
end
else
res[k] = {
__kind = "var", _name = path..k, _type = type(v)
}
end
local p0 = "package.loaded."
local i1 = (i:sub(0, #p0) == p0) and i:sub(#p0+1) or i
local p1 = "package.preload."
local i2 = (i1:sub(0, #p1) == p1) and i1:sub(#p1+1) or i1
for k,v in ipairs(s) do
local v0=t[v]
if type(v0)=="table" and not seen[v0] then
dump(v0,i1..v..".")
elseif v ~= "vim._meta" and v ~= "vim._init_packages" and v ~= "table.clear" and v ~= "table.new" and type(v0) == "function" and i:sub(0, #p1) == p1 then
dump(v0(),i2..v..".")
elseif type(v0) == "function" then
print("function/"..debug.getinfo(v0).nparams.."/"..i..v)
elseif type(v0) ~= "table" then
print(type(v0).."/"..i..v)
end
end
end
dump(_G,"")
local function dumpf(t, path, res)
for k,v in pairs(t.funcs) do
if type(v.args) == "table" then
-- 1 value: min bound
-- 2 values: min and max bound
if #v.args == 1 then
res[k] = {
__kind = "var",
_name = path..k,
_type = "function",
_minArity = v.args[1]
}
elseif #v.args == 2 then
res[k] = {
__kind = "var",
_name = path..k,
_type = "function",
_minArity = v.args[1],
_maxArity = v.args[2]
}
else
print("ERROR")
end
elseif type(v.args) == "number" then
-- exact arg count
res[k] = {
__kind = "var",
_name = path..k,
_type = "function",
_minArity = v.args,
_maxArity = v.args
}
else
-- zero args
res[k] = {
__kind = "var",
_name = path..k,
_type = "function",
_minArity = 0,
_maxArity = 0
}
end
end
end
local function dumpo(t, path, opt, res)
local types = {
bool = "boolean",
string = "string",
number = "number",
}
local key_value_options = {
fillchars = true,
listchars = true,
winhighlight = true,
}
for k,v in pairs(t.options) do
if opt and key_value_options[v.full_name] then
-- kv map
res[v.full_name] = {
__kind = "var",
_name = path..v.full_name,
_type = "table"
}
if type(v.abbreviation) == "string" then
res[path..v.full_name] = { __kind = "rec", path = path..v.full_name, }
end
elseif opt and v.list then
-- list
res[v.full_name] = {
__kind = "var",
_name = path..v.full_name,
_type = "table"
}
if type(v.abbreviation) == "string" then
res[v.abbreviation] = { __kind = "rec", path = path..v.full_name, }
end
elseif not opt then
res[v.full_name] = {
__kind = "var",
_name = path..v.full_name,
_type = types[v.type],
}
if type(v.abbreviation) == "string" then
res[v.abbreviation] = { __kind = "rec", path = path..v.full_name, }
end
end
end
end
local json = require "json"
--- DUMPING BUILTINS
result["vim"] = { __kind = "var", _type = "table", _name = "vim" }
for k in pairs(vim._submodules) do
result["vim"][k] = { __kind = "var", _type = "table", _name = "vim."..k }
dump2(vim[k], "vim."..k, result["vim"][k])
end
dump2(package.loaded["vim.shared"], "vim", result["vim"])
-- for main thread only?
dump2(package.loaded["vim._editor"], "vim", result["vim"])
dump2(_G, "", result)
-- eval.lua from https://github.com/neovim/neovim/blob/674e23f19c509381e2476a3990e21272e362e3a4/src/nvim/eval.lua
dumpf(require("eval"), "vim.fn.", result["vim"]["fn"])
-- https://github.com/neovim/neovim/blob/674e23f19c509381e2476a3990e21272e362e3a4/src/nvim/options.lua
dumpo(require("options"), "vim.o.", false, result["vim"]["o"])
dumpo(require("options"), "vim.opt.", true, result["vim"]["opt"])
print(json.encode(result))

View file

@ -0,0 +1,67 @@
local seen = {}
local result = {}
local function mark(t)
seen[t] = true
for k,v in pairs(t) do
if type(v) == "table" and not seen[v] then
mark(v)
end
end
end
local function dump2(t, path, res)
seen[t] = path
if path ~= "" then
path = path.."."
end
for k,v in pairs(t) do
k = tostring(k)
if path ~= "" or k ~= "package" then
if type(v) == "table" then
if seen[v] then
if not res[k] and seen[v] ~= true then
res[k] = { __kind = "rec", path = seen[v] }
end
else
if not res[k] then
res[k] = {}
end
res[k].__kind = "var"
res[k]._type = "table"
res[k]._name = path..k
dump2(v, path..k, res[k])
end
elseif type(v) == "function" then
local info = debug.getinfo(v)
res[k] = {
__kind = "var",
_name = path..k,
_type = "function",
_minArity = info.nparams
}
if not info.isvararg then
res[k]["maxArity"] = info.nparams
end
else
res[k] = {
__kind = "var", _name = path..k, _type = type(v)
}
end
end
end
end
local json = require "cjson"
-- mark globals before requiring package
mark(_G)
local package = "@package@"
result = { __kind = "var", _type = "table", _name = "" }
dump2(require(package), "", result)
print(json.encode(result))

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -1,69 +1,50 @@
{ lib, raw, call }: let defs = map (line:
if lib.hasPrefix "function/" line then let split = lib.splitString "/" (lib.removePrefix "function/" line); in {
type = "function";
arity = lib.toInt (builtins.elemAt split 0);
value = builtins.elemAt split 1;
} else if lib.hasPrefix "string/" line then {
type = "string";
value = lib.removePrefix "string/" line;
} else if lib.hasPrefix "boolean/" line then {
type = "boolean";
value = lib.removePrefix "boolean/" line;
} else if lib.hasPrefix "number/" line then {
type = "number";
value = lib.removePrefix "number/" line;
} else {
type = "ignore";
value = "____ignore.___ignore";
}) (lib.splitString "\n" (builtins.readFile ./vim-lua.txt));
process' = val: (
if val.type == "function" then (
#if val.arity == 0 then
args: if args == "GET_INFO" then val else call (raw val.value) args
#else if val.arity == 1 then (a: if a == "GET_INFO" then val else call (raw val.value) [a])
#else (a: if a == "GET_INFO" then val else call (raw val.value) a)
) else raw val.value
);
process = val: lib.setAttrByPath (lib.splitString "." val.value) (process' val);
processOpt = o: val: lib.setAttrByPath ["vim" o val] (raw "vim.${o}.${val}");
processVar = val:
if lib.hasPrefix "b:" val then lib.setAttrByPath ["vim" "b" (lib.removePrefix "b:" val)] (raw "vim.b.${val}")
else if lib.hasPrefix "v:" val then lib.setAttrByPath ["vim" "v" (lib.removePrefix "v:" val)] (raw "vim.v.${val}")
else if lib.hasPrefix "w:" val then lib.setAttrByPath ["vim" "w" (lib.removePrefix "w:" val)] (raw "vim.w.${val}")
else if lib.hasPrefix "t:" val then lib.setAttrByPath ["vim" "t" (lib.removePrefix "t:" val)] (raw "vim.t.${val}")
else if lib.hasPrefix "v:" val then lib.setAttrByPath ["vim" "v" (lib.removePrefix "v:" val)] (raw "vim.v.${val}")
else lib.setAttrByPath ["vim" "g" val] (raw "vim.g.${val}");
setPath = path: key: val: if builtins.isAttrs val
then (builtins.mapAttrs (setPath "${path}${key}.") val) // { __kind = "var"; _name = "${path}${key}"; }
else val;
opts = (lib.splitString "\n" (builtins.readFile ./vim-opts.txt));
vars = (lib.splitString "\n" (builtins.readFile ./vim-vars.txt));
zip = x: if x == [] then {} else lib.recursiveUpdate (zip (builtins.tail x)) (builtins.head x);
patch = builtins.mapAttrs (k: v: if k == "vim" then v // {
inspect = process' {
type = "function";
arity = 2;
value = "vim.inspect";
{ stdenvNoCC
, lib
, neovim-unwrapped
, neovimUtils
, lua51Packages
, wrapNeovimUnstable
, call
, substituteAll
, plugins
# , extraLuaPackages ? []
, ... }:
let update = self: prefix: lib.mapAttrs (k: v: let
v' = update self prefix v;
in (if builtins.isAttrs v && v?__kind then (
if v.__kind == "rec" then
lib.attrByPath (lib.splitString "." v.path) self
else if v.__kind == "var" && v._type == "function" then
(args: if args == "GET_INFO" then v' else call v' args)
else v'
) else if builtins.isAttrs v then v'
else if prefix != "" && k == "_name" then
(if v == "" then prefix else "${prefix}.${v}")
else v));
data = builtins.fromJSON (builtins.readFile ./vim-defs.json);
result = update result "" data;
config = neovimUtils.makeNeovimConfig {
extraLuaPackages = p: [ p.cjson ];
# inherit extraLuaPackages;
plugins = map (plugin: if plugin?plugin then {plugin=plugin.plugin;} else {inherit plugin;}) plugins;
};
cmd = process' {
type = "function";
arity = 1;
value = "vim.cmd";
neovim = wrapNeovimUnstable neovim-unwrapped config;
getReqAttrs = name: builtins.fromJSON (builtins.readFile (stdenvNoCC.mkDerivation {
phases = [ "installPhase" ];
name = "neovim-require-${name}.json";
dumpPlugin = substituteAll {
src = ./dump_plugin.lua;
package = name;
};
fn = (if v?fn then v.fn else {}) // {
visualmode = {
type = "function";
arity = 0;
value = "vim.fn.visualmode";
};
};
} else v);
in
patch (builtins.mapAttrs (setPath "")
(zip (
(map process defs)
++ (map process (map (x: x // {value = "vim" + (lib.removePrefix "vim.shared" x.value); }) (builtins.filter ({value,...}: lib.hasPrefix "vim.shared" value) defs)))
++ (map (processOpt "o") opts)
++ (map (processOpt "opt") opts)
++ (map processVar vars)
)))
nativeBuildInputs = [ neovim ];
installPhase = ''
export HOME="$TMPDIR"
nvim --headless -S $dumpPlugin -i NONE -u NONE -n -c 'echo""|qall!' 2>$out
'';
}));
req = name: let result = update result "require(\"${name}\")" (getReqAttrs name); in result;
_reqbind = name: varname: let result = update result "${varname}" (getReqAttrs name); in result;
in result // {
inherit req _reqbind;
}

View file

@ -1,354 +0,0 @@
all
aleph
arabic
arabicshape
allowrevins
ambiwidth
autochdir
autoindent
autoread
autowrite
autowriteall
background
backspace
backup
backupcopy
backupdir
backupext
backupskip
belloff
binary
bomb
breakat
breakindent
breakindentopt
bufhidden
buflisted
buftype
casemap
cdhome
cdpath
cedit
channel
charconvert
cindent
cinkeys
cinoptions
cinwords
cinscopedecls
clipboard
cmdheight
cmdwinheight
colorcolumn
columns
comments
commentstring
compatible
complete
concealcursor
conceallevel
completefunc
completeopt
confirm
copyindent
cpoptions
cscopepathcomp
cscopeprg
cscopequickfix
cscoperelative
cscopetag
cscopetagorder
cscopeverbose
cursorbind
cursorcolumn
cursorline
cursorlineopt
debug
define
delcombine
dictionary
diff
diffexpr
diffopt
digraph
directory
display
eadirection
edcompatible
emoji
encoding
endofline
equalalways
equalprg
errorbells
errorfile
errorformat
eventignore
expandtab
exrc
fileencoding
fileencodings
fileformat
fileformats
fileignorecase
filetype
fillchars
fixendofline
foldclose
foldcolumn
foldenable
foldexpr
foldignore
foldlevel
foldlevelstart
foldmarker
foldmethod
foldminlines
foldnestmax
foldopen
foldtext
formatexpr
formatoptions
formatlistpat
formatprg
fsync
gdefault
grepformat
grepprg
guicursor
guifont
guifontwide
helpfile
helpheight
helplang
hidden
highlight
history
hkmap
hkmapp
hlsearch
icon
iconstring
ignorecase
iminsert
imsearch
inccommand
include
includeexpr
incsearch
indentexpr
indentkeys
infercase
insertmode
isfname
isident
iskeyword
isprint
joinspaces
jumpoptions
keymap
keymodel
keywordprg
langmap
langmenu
langnoremap
langremap
laststatus
lazyredraw
linebreak
lines
linespace
lisp
lispwords
list
listchars
loadplugins
magic
makeef
makeencoding
makeprg
matchpairs
matchtime
maxcombine
maxfuncdepth
maxmapdepth
maxmempattern
menuitems
mkspellmem
modeline
modelineexpr
modelines
modifiable
modified
more
mouse
mousefocus
mousemodel
mousemoveevent
mousescroll
mousetime
nrformats
number
numberwidth
omnifunc
operatorfunc
packpath
paragraphs
paste
pastetoggle
patchexpr
patchmode
path
preserveindent
previewheight
previewwindow
printdevice
printencoding
printexpr
printfont
printheader
printmbcharset
printmbfont
printoptions
prompt
pumblend
pumheight
pumwidth
pyxversion
quickfixtextfunc
quoteescape
readonly
redrawdebug
redrawtime
regexpengine
relativenumber
remap
report
revins
rightleft
rightleftcmd
ruler
rulerformat
runtimepath
scroll
scrollback
scrollbind
scrolljump
scrolloff
scrollopt
sections
secure
selection
selectmode
sessionoptions
shada
shadafile
shell
shellcmdflag
shellpipe
shellquote
shellredir
shelltemp
shellxquote
shellxescape
shiftround
shiftwidth
shortmess
showbreak
showcmd
showfulltag
showmatch
showmode
showtabline
sidescroll
sidescrolloff
signcolumn
smartcase
smartindent
smarttab
softtabstop
spell
spellcapcheck
spellfile
spelllang
spellsuggest
spelloptions
splitbelow
splitright
startofline
statusline
suffixes
suffixesadd
swapfile
switchbuf
synmaxcol
syntax
tagfunc
tabline
tabpagemax
tabstop
tagbsearch
tagcase
taglength
tagrelative
tags
tagstack
termbidi
termguicolors
termpastefilter
terse
textwidth
thesaurus
thesaurusfunc
tildeop
timeout
timeoutlen
title
titlelen
titleold
titlestring
ttimeout
ttimeoutlen
ttyfast
undodir
undofile
undolevels
undoreload
updatecount
updatetime
varsofttabstop
vartabstop
verbose
verbosefile
viewdir
viewoptions
virtualedit
visualbell
warn
whichwrap
wildchar
wildcharm
wildignore
wildignorecase
wildmenu
wildmode
wildoptions
winaltkeys
winbar
winblend
winhighlight
window
winheight
winfixheight
winfixwidth
winminheight
winminwidth
winwidth
wrap
wrapmargin
wrapscan
write
writeany
writebackup
writedelay

View file

@ -1,140 +0,0 @@
NvimTreeRequired
NvimTreeSetup
b:autopairs_keymaps
b:changedtick
b:nvim-autopairs
colors_name
did_indent_on
did_load_filetypes
did_load_ftplugin
ft_ignore_pat
loaded_2html_plugin
loaded_clipboard_provider
loaded_cmp
loaded_devicons
loaded_gzip
loaded_man
loaded_matchit
loaded_matchparen
loaded_netrw
loaded_netrwPlugin
loaded_node_provider
loaded_python_provider
loaded_remote_plugins
loaded_shada_plugin
loaded_sleuth
loaded_spellfile_plugin
loaded_tarPlugin
loaded_tutor_mode_plugin
loaded_zipPlugin
lspconfig
lua_subversion
lua_version
markdown_fenced_languages
markdown_minlines
matchparen_insert_timeout
matchparen_timeout
nvim_web_devicons
python3_host_prog
ruby_host_prog
syntax_on
system_remote_plugins
v:_null_blob
v:_null_dict
v:_null_list
v:_null_string
v:argv
v:beval_bufnr
v:beval_col
v:beval_lnum
v:beval_text
v:beval_winid
v:beval_winnr
v:char
v:charconvert_from
v:charconvert_to
v:cmdarg
v:cmdbang
v:collate
v:completed_item
v:count
v:count1
v:ctype
v:dying
v:echospace
v:errmsg
v:errors
v:event
v:exception
v:exiting
v:false
v:fcs_choice
v:fcs_reason
v:fname
v:fname_diff
v:fname_in
v:fname_new
v:fname_out
v:folddashes
v:foldend
v:foldlevel
v:foldstart
v:hlsearch
v:insertmode
v:key
v:lang
v:lc_time
v:lnum
v:lua
v:mouse_col
v:mouse_lnum
v:mouse_win
v:mouse_winid
v:msgpack_types
v:null
v:numbermax
v:numbermin
v:numbersize
v:oldfiles
v:operator
v:option_command
v:option_new
v:option_old
v:option_oldglobal
v:option_oldlocal
v:option_type
v:prevcount
v:profiling
v:progname
v:progpath
v:register
v:scrollstart
v:searchforward
v:servername
v:shell_error
v:statusmsg
v:stderr
v:swapchoice
v:swapcommand
v:swapname
v:t_blob
v:t_bool
v:t_dict
v:t_float
v:t_func
v:t_list
v:t_number
v:t_string
v:termresponse
v:testing
v:this_session
v:throwpoint
v:true
v:val
v:version
v:vim_did_enter
v:warningmsg
v:windowid
vimsyn_embed
zipPlugin_ext

View file

@ -1,5 +1,15 @@
{ lib, config, ... }:
with lib; {
options.rustAnalyzerAndroidSettings = mkOption {
type = with types; attrs;
description = "Additional cargo arguments for rust-analyzer's RustAndroid command";
# TODO: create a neovim plugin or edit an existing one for workspace-specific config
default = {
rust-analyzer = {
cargo.target = "x86_64-linux-android";
};
};
};
options.terminals = mkOption {
type = with types; listOf str;
description = "terminal kinds (possible values are alacritty, urxvt, kitty, foot)";

View file

@ -26,7 +26,13 @@
pkgs = nixpkgs.legacyPackages."x86_64-linux";
modules = [
nur.nixosModules.nur
{ nixpkgs.overlays = [ nix-gaming.overlays.default ]; }
{ nixpkgs.overlays = [
nix-gaming.overlays.default
(self: super: {
clang_latest = super.clang_15;
clang-tools_latest = super.clang-tools_15;
})
]; }
./hosts/nixmsi.nix
(getPriv "nixmsi")
];

View file

@ -49,8 +49,14 @@
'';
}; in {
STEAM_EXTRA_COMPAT_TOOLS_PATHS = "${proton-ge}";
CARGO_PROFILE_DEV_INCREMENTAL = "true";
RUSTC_LINKER = "${pkgs.clang_latest}/bin/clang";
RUSTFLAGS = "-C link-arg=--ld-path=${pkgs.mold}/bin/mold";
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.clang_latest}/bin/clang";
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS = "-C link-arg=--ld-path=${pkgs.mold}/bin/mold";
};
home.packages = with pkgs; [
mold
(ghidra.overrideAttrs (old: {
patches = old.patches ++ [ ../common/ghidra-stdcall.patch ];
})) cutter
@ -65,7 +71,7 @@
virtmanager
gimp krita blender
tdesktop
clang rustc rustfmt cargo clippy
clang_latest rustc rustfmt cargo clippy
# waiting until the PR gets merged
(looking-glass-client.overrideAttrs (old: {
version = "B6";