integrate with nix2lua

This commit is contained in:
Dmitriy Pleshevskiy 2022-11-19 00:56:53 +03:00
parent 42e6ef422f
commit ea2231f615
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
13 changed files with 178 additions and 76 deletions

View File

@ -6,19 +6,23 @@
, vimAlias ? false
, grammarFileTypes ? [ "nix" ]
, theme ? { }
, plugins ? { }
, wrapNeovim
, neovim-unwrapped
, tree-sitter
, neovimPlugins
, lib
, toLua
, substituteAll
, ...
}:
let
inherit (builtins) catAttrs isFunction readFile;
myLib = import ./lib.nix { inherit lib; };
myLib = import ./lib.nix { inherit lib; } // { inherit substituteAll toLua; };
pluginParams = neovimPlugins // {
inherit plugins;
inherit tree-sitter grammarFileTypes;
inherit enableDevIcons enableTabby enableOrgMode;
themeCfg = theme;
@ -29,7 +33,7 @@ let
if isFunction op then op pluginParams else import op pluginParams;
callPlugins = list: map callPlugin list;
plugins = callPlugins [
pluginsSettings = callPlugins [
./plugins/config
./plugins/syntax
./plugins/git
@ -41,11 +45,11 @@ let
];
basePlugins = [ neovimPlugins.plenary-nvim ];
customPlugins = catAttrs "plugins" plugins;
customPlugins = catAttrs "plugins" pluginsSettings;
allPlugins = basePlugins ++ customPlugins;
basicConfigs = map readFile [ ./config/basic.lua ];
pluginConfigs = catAttrs "luaConfig" plugins;
pluginConfigs = catAttrs "luaConfig" pluginsSettings;
allConfigs = basicConfigs ++ pluginConfigs;
in
wrapNeovim neovim-unwrapped {

View File

@ -51,6 +51,36 @@
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitsigns-nvim": {
"flake": false,
"locked": {
@ -170,7 +200,42 @@
"type": "github"
}
},
"nix2lua": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1668806730,
"narHash": "sha256-CfRF/O5ObRBGCQkrUBsNWzKH2OjLNtOOuVk8H2dMoxQ=",
"ref": "refs/heads/main",
"rev": "9666618527a63e79ccc1855beeab285cd8480727",
"revCount": 6,
"type": "git",
"url": "https://git.pleshevski.ru/mynix/nix2lua"
},
"original": {
"type": "git",
"url": "https://git.pleshevski.ru/mynix/nix2lua"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1668650906,
"narHash": "sha256-JuiYfDO23O8oxUUOmhQflmOoJovyC5G4RjcYQMQjrRE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3a86856a13c88c8c64ea32082a851fefc79aa700",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1667969101,
"narHash": "sha256-GL53T705HO7Q/KVfbb5STx8AxFs8YgaGY8pvAZC+O7U=",
@ -342,6 +407,7 @@
"cmp-luasnip": "cmp-luasnip",
"cmp-nvim-lsp": "cmp-nvim-lsp",
"editorconfig-nvim": "editorconfig-nvim",
"flake-utils": "flake-utils",
"gitsigns-nvim": "gitsigns-nvim",
"hop-nvim": "hop-nvim",
"lspsaga-nvim": "lspsaga-nvim",
@ -349,7 +415,8 @@
"lualine-nvim": "lualine-nvim",
"luasnip": "luasnip",
"neoformat": "neoformat",
"nixpkgs": "nixpkgs",
"nix2lua": "nix2lua",
"nixpkgs": "nixpkgs_2",
"nlsp-settings-nvim": "nlsp-settings-nvim",
"nvim-cmp": "nvim-cmp",
"nvim-lspconfig": "nvim-lspconfig",
@ -362,8 +429,7 @@
"tabby-nvim": "tabby-nvim",
"telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim",
"telescope-nvim": "telescope-nvim",
"theme": "theme",
"utils": "utils"
"theme": "theme"
}
},
"tabby-nvim": {
@ -433,21 +499,6 @@
"rev": "9ac18414f0446478024b19018d73b7ea14f6fc96",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",

View File

@ -1,7 +1,9 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
flake-utils.url = "github:numtide/flake-utils";
nix2lua.url = "git+https://git.pleshevski.ru/mynix/nix2lua";
# Plenary (required by crates-nvim)
plenary-nvim = {
@ -158,7 +160,7 @@
};
};
outputs = inputs @ { self, nixpkgs, utils, ... }:
outputs = inputs @ { self, nixpkgs, flake-utils, nix2lua, ... }:
let
inputPlugins = [
"plenary-nvim"
@ -219,21 +221,78 @@
{
overlays = {
default = final: prev: {
myneovim = prev.callPackage self (mkNvimPlugins prev);
myneovim = prev.callPackage self (mkNvimPlugins prev // nix2lua.lib);
};
};
} //
utils.lib.eachDefaultSystem (system:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
neovim = pkgs.callPackage self (mkNvimPlugins pkgs);
neovim = pkgs.callPackage self (mkNvimPlugins pkgs // nix2lua.lib);
testNeovim = (neovim.override {
enableDevIcons = true;
enableTabby = true;
enableOrgMode = true;
grammarFileTypes = [ "nix" "lua" "org" ];
plugins = with nix2lua.lib; {
nvimTree.settings = {
open_on_setup = true;
renderer = {
group_empty = true;
full_name = true;
};
};
lspSaga.settings = {
border_style = "rounded";
symbol_in_winbar.enable = false;
code_action_lightbulb.enable = false;
code_action_keys = { quit = "<Esc>"; };
definition_action_keys = { quit = "<Esc>"; };
rename_action_quit = "<C-c>";
};
lspConfig = {
servers = {
nix = { };
tsserver = { };
eslint = { };
denols = {
root_dir = mkLuaRaw "root_pattern(\"deno.json\", \"deno.jsonc\")";
};
rust_analyzer = {
settings.rust-analyzer = {
"server.path" = "rust-analyzer";
"updates.prompt" = false;
"updates.checkOnStartup" = false;
"checkOnSave.enable" = true;
"checkOnSave.command" = "clippy";
"cargo.autoreload" = true;
};
};
};
};
lualine.settings = {
options.ignore_focus = [ "NvimTree" ];
sections = {
lualine_a = [
[ "filename" (mkDictItem "path" 1) ]
];
lualine_b = [ "branch" "diff" "diagnostics" ];
lualine_c = [ "lsp_progress" ];
lualine_x = [ "filesize" "filetype" ];
lualine_y = [ "progress" ];
lualine_z = [ "location" "mode" ];
};
};
orgmode.settings = {
org_agenda_files = [ "~/orgs/**/*" ];
org_default_notes_file = "~/orgs/refile.org";
win_split_mode = "tabnew";
org_hide_leading_stars = true;
};
};
});
in
{

View File

@ -51,7 +51,7 @@ let
in
{
inherit (lib) importJSON;
inherit (lib) importJSON attrByPath;
inherit foldr concatMap;
inherit optional getAttrOpt;
inherit mkLuaHeredoc mkLuaRc;

View File

@ -1,4 +1,6 @@
{ nvim-tree-lua
{ lib
, plugins ? { }
, nvim-tree-lua
, telescope-nvim
, telescope-live-grep-args-nvim
, ...
@ -6,10 +8,14 @@
let
inherit (builtins) readFile;
nvimTreeLuaSettings = lib.toLua (lib.attrByPath [ "nvimTree" "settings" ] { } plugins);
telescopeSettings = lib.toLua (lib.attrByPath [ "telescope" "settings" ] { } plugins);
in
{
luaConfig = (readFile ./nvim-tree.lua)
+ (readFile ./telescope-nvim.lua);
luaConfig =
(readFile (lib.substituteAll { src = ./nvim-tree.lua; inherit nvimTreeLuaSettings; }))
+ (readFile (lib.substituteAll { src = ./telescope-nvim.lua; inherit telescopeSettings; }));
plugins = [ nvim-tree-lua ]
++ [ telescope-nvim telescope-live-grep-args-nvim ];

View File

@ -1,13 +1,5 @@
-- See: https://github.com/kyazdani42/nvim-tree.lua/blob/master/doc/nvim-tree-lua.txt
-- empty setup using defaults
require("nvim-tree").setup({
open_on_setup = true,
renderer = {
group_empty = true,
full_name = true,
},
})
require("nvim-tree").setup(@nvimTreeLuaSettings@)
vim.keymap.set("n", "<leader>nt", "<Cmd>NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>nf", "<Cmd>NvimTreeFindFile<CR>")

View File

@ -1,7 +1,7 @@
-- See: https://github.com/nvim-telescope/telescope.nvim
local telescope = require("telescope")
telescope.setup({})
telescope.setup(@telescopeSettings@)
vim.keymap.set("n", "<leader>ff", "<Cmd>Telescope find_files hidden=true<CR>")
vim.keymap.set("n", "<leader>fb", "<Cmd>Telescope buffers<CR>")

View File

@ -1,4 +1,6 @@
{ nvim-lspconfig
{ lib
, plugins
, nvim-lspconfig
, nlsp-settings-nvim
, lspsaga-nvim
, luasnip
@ -17,9 +19,12 @@ let
cmp-nvim-lsp # LSP source for nvim-cmp
cmp-luasnip # Snippets source for nvim-cmp
];
lspConfigServers = lib.toLua (lib.attrByPath [ "lspConfig" "servers" ] [ ] plugins);
lspSagaSettings = lib.toLua (lib.attrByPath [ "lspSaga" "settings" ] { } plugins);
in
{
luaConfig = (readFile ./lspconfig.lua)
luaConfig = (readFile (lib.substituteAll { src = ./lspconfig.lua; inherit lspConfigServers lspSagaSettings; }))
+ (readFile ./nvim-cmp.lua);
plugins = lsp

View File

@ -3,14 +3,7 @@ local saga = require("lspsaga")
local nlsp_settings = require("nlspsettings")
-- See: https://github.com/glepnir/lspsaga.nvim#configuration
saga.init_lsp_saga({
border_style = "rounded",
symbol_in_winbar = { enable = false },
code_action_lightbulb = { enable = false },
code_action_keys = { quit = "<Esc>" },
definition_action_keys = { quit = "<Esc>" },
rename_action_quit = "<C-c>",
})
saga.init_lsp_saga(@lspSagaSettings@)
-- always show signcolumns
vim.opt.signcolumn = "yes"
@ -64,15 +57,20 @@ nlsp_settings.setup({})
-- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
--
-- Override the default configuration to be applied to all servers
lsp_config.util.default_config = vim.tbl_extend("force", lsp_config.util.default_config, {
on_attach = on_attach,
capabilities = capabilities,
})
-- nix
lsp_config.nil_ls.setup({})
local root_pattern = lsp_config.util.root_pattern
for name, settings in pairs(@lspConfigServers@) do
lsp_config[name].setup(settings)
end
--[[
-- js,ts
lsp_config.tsserver.setup({})
lsp_config.eslint.setup({})
@ -98,3 +96,4 @@ lsp_config.rust_analyzer.setup({
},
},
})
]]--

View File

@ -1,4 +1,5 @@
{ lib
, plugins
, theme
, lualine-nvim
, lualine-lsp-progress
@ -20,11 +21,12 @@ let
vim.cmd([[colorscheme catppuccin]])
'';
lualineSettings = lib.toLua (lib.attrByPath [ "lualine" "settings" ] { } plugins);
lualinePlugins = [ lualine-nvim lualine-lsp-progress ];
in
{
luaConfig = themeConfig
+ (readFile ./lualine.lua)
+ (readFile (lib.substituteAll { src = ./lualine.lua; inherit lualineSettings; }))
+ (lib.optional enableTabby (readFile ./tabby-nvim.lua));
plugins = [ theme ]

View File

@ -1,16 +1,2 @@
-- See: https://github.com/nvim-lualine/lualine.nvim#default-configuration
require("lualine").setup({
options = {
ignore_focus = { "NvimTree" },
},
sections = {
lualine_a = {
{ "filename", path = 1 },
},
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "lsp_progress" },
lualine_x = { "filesize", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location", "mode" },
},
})
require("lualine").setup(@lualineSettings@)

View File

@ -1,4 +1,5 @@
{ lib
, plugins
, hop-nvim
, nvim-orgmode
, org-bullets-nvim
@ -8,10 +9,12 @@
let
inherit (builtins) readFile;
orgmodeSettings = lib.toLua (lib.attrByPath [ "orgmode" "settings" ] { } plugins);
in
{
luaConfig = readFile ./hop-nvim.lua
+ lib.optional enableOrgMode (readFile ./nvim-orgmode.lua);
+ lib.optional enableOrgMode (readFile (lib.substituteAll { src = ./nvim-orgmode.lua; inherit orgmodeSettings; }));
plugins = [ hop-nvim ]
++ lib.optional enableOrgMode [ nvim-orgmode org-bullets-nvim ];

View File

@ -1,8 +1,3 @@
require("orgmode").setup({
org_agenda_files = { "~/orgs/**/*" },
org_default_notes_file = "~/orgs/refile.org",
win_split_mode = "tabnew",
org_hide_leading_stars = true,
})
require("orgmode").setup(@orgmodeSettings@)
require("org-bullets").setup()