feat: initial commit

New neovim configuration, a continuation from
a1a9da1ddc,
but based on Nix as the plugin/package manager. With a wrapped neovim
instance, for better portability.
This commit is contained in:
Guz
2024-12-03 18:17:33 -03:00
commit 4dd2211721
8 changed files with 456 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
result

228
flake.lock generated Normal file
View File

@@ -0,0 +1,228 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1732722421,
"narHash": "sha256-HRJ/18p+WoXpWJkcdsk9St5ZiukCqSDgbOGFa8Okehg=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9ed2ac151eada2306ca8c418ebd97807bb08f6ac",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1730504689,
"narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "506278e768c2a08bec68eb62932193e341f55c90",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": [
"neovim-nightly-overlay",
"hercules-ci-effects",
"nixpkgs"
]
},
"locked": {
"lastModified": 1712014858,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"type": "github"
},
"original": {
"id": "flake-parts",
"type": "indirect"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"gitignore": "gitignore",
"nixpkgs": [
"neovim-nightly-overlay",
"nixpkgs"
],
"nixpkgs-stable": [
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1732021966,
"narHash": "sha256-mnTbjpdqF0luOkou8ZFi2asa1N3AA2CchR/RqCNmsGE=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "3308484d1a443fc5bc92012435d79e80458fe43c",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"neovim-nightly-overlay",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"hercules-ci-effects": {
"inputs": {
"flake-parts": "flake-parts_2",
"nixpkgs": [
"neovim-nightly-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1730903510,
"narHash": "sha256-mnynlrPeiW0nUQ8KGZHb3WyxAxA3Ye/BH8gMjdoKP6E=",
"owner": "hercules-ci",
"repo": "hercules-ci-effects",
"rev": "b89ac4d66d618b915b1f0a408e2775fe3821d141",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "hercules-ci-effects",
"type": "github"
}
},
"neovim-nightly-overlay": {
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"hercules-ci-effects": "hercules-ci-effects",
"neovim-src": "neovim-src",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1733211153,
"narHash": "sha256-Ml7GGmUsaDldssIVE189Sf+PMPRgkkGpj66EvZvy8MI=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "90426479f3220aadcc01832db56ee8cfa3886671",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"type": "github"
}
},
"neovim-src": {
"flake": false,
"locked": {
"lastModified": 1733163189,
"narHash": "sha256-0NlEbJgUYghWNgp2Iiak8N989Cvjoq87xkeRCagfCeU=",
"owner": "neovim",
"repo": "neovim",
"rev": "49d6cd1da86cab49c7a5a8c79e59d48d016975fa",
"type": "github"
},
"original": {
"owner": "neovim",
"repo": "neovim",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1733064805,
"narHash": "sha256-7NbtSLfZO0q7MXPl5hzA0sbVJt6pWxxtGWbaVUDDmjs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "31d66ae40417bb13765b0ad75dd200400e98de84",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1733015953,
"narHash": "sha256-t4BBVpwG9B4hLgc6GUBuj3cjU7lP/PJfpTHuSqE+crk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ac35b104800bff9028425fec3b6e8a41de2bbfff",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"neovim-nightly-overlay": "neovim-nightly-overlay",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}

38
flake.nix Normal file
View File

@@ -0,0 +1,38 @@
{
description = "My development environment";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
};
outputs = {
self,
nixpkgs,
...
}@inputs: let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
overlays = [
inputs.neovim-nightly-overlay.overlays.default
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
pkgs = import nixpkgs {inherit system overlays;};
in
f system pkgs);
in {
packages = forAllSystems (system: pkgs: {
neovim = self.packages.${system}.default;
default = (pkgs.callPackage ./neovim.nix {});
});
devShells = forAllSystems (system: pkgs: {
default = pkgs.mkShell {
buildInputs = with pkgs; [
stylua
];
};
});
};
}

10
lua/dot013/init.lua Normal file
View File

@@ -0,0 +1,10 @@
require("dot013.options")
vim.g.lze = {
--@type fun(name: string)
load = vim.cmd.packadd,
--@type boolean
verbose = true,
}
require("lze").load("dot013.plugins")

58
lua/dot013/options.lua Normal file
View File

@@ -0,0 +1,58 @@
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- vim.g.loaded_netrw = 1;
-- vim.g.loaded_netrwPlugin = 1;
vim.wo.number = true
vim.o.mouse = "a"
-- True colors
vim.o.termguicolors = true
-- Enable filetype plugins
vim.o.filetype = "on"
-- Enable spell checking by default
vim.o.spell = true
-- Set relative line numbers
vim.o.number = true
vim.o.relativenumber = true
vim.o.signcolumn = "number"
-- Set indentation
vim.o.expandtab = false
vim.o.tabstop = 4
vim.o.softtabstop = 4
vim.o.shiftwidth = 4
-- vim.o.expandtab = 4;
vim.o.breakindent = true
-- Scroll off
vim.o.scrolloff = 10
-- Line length column
vim.o.colorcolumn = "80"
-- Sync NeoVim and OS clipboards
vim.o.clipboard = "unnamedplus"
-- Highlight search
vim.o.hlsearch = false
vim.o.incsearch = true
-- Save undo history
vim.o.undofile = true
-- Case-insensitive search, unless \C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
vim.wo.signcolumn = "yes"
vim.o.updatetime = 250
vim.o.timeoutlen = 300
vim.o.completeopt = "menuone,noselect"

View File

@@ -0,0 +1,41 @@
return {
{
"plenary.nvim",
dep_of = {
"telescope.nvim",
},
},
{
"telescope-fzf-native.nvim",
dep_of = {
"telescope.nvim"
},
},
{
"telescope.nvim",
cmd = {
"Telescope",
},
keys = {
{ "<leader><space>", function() return require("telescope.builtin").buffers end, "Find existing buffers" },
{
"/",
function() return require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
windblend = 10,
previewer = false,
})) end,
"Find in current buffer"
},
{ "fr", ":lua require('telescope.builtin').oldfiles()<cr>", "Find recent files" },
{ "ff", "<cmd>Telescope find_files<cr>", "Find files" },
{ "fw", ":lua require('telescope.builtin').grep_string()<cr>", "Find word" },
{ "<leader>fw", "<cmd>Telescope live_grep<cr>","Find word in all files" },
{ "gf", ":lua require('telescope.builtin').git_files()<cr>", "Git files" },
{ "fs", ":lua require('telescope.builtin').resume()<cr>", "Resume search" },
},
after = function ()
require("telescope").setup()
require("telescope").load_extension("fzf")
end,
}
}

79
neovim.nix Normal file
View File

@@ -0,0 +1,79 @@
{
symlinkJoin,
makeWrapper,
runCommandLocal,
pkgs,
lib,
}: let
nvimPkg = pkgs.neovim-unwrapped;
startPlugins = with pkgs; with vimPlugins; [
lze
(vimUtils.buildVimPlugin {
name = "dot013.nvim";
src = ./.;
})
];
optPlugins = with pkgs; with pkgs.vimPlugins; [
telescope-nvim
telescope-fzf-native-nvim
nvim-treesitter.withAllGrammars
];
foldPlugins = builtins.foldl' (acc: next: acc ++ [ next ] ++ (foldPlugins (next.dependencies or []))) [];
startPluginsWithDeps = lib.unique (foldPlugins startPlugins);
optPluginsWithDeps = lib.unique (foldPlugins optPlugins);
packpath = let
packageName = "dot013";
in runCommandLocal "packpath" {} ''
mkdir -p $out/pack/${packageName}/{start,opt}
${lib.concatMapStringsSep "\n"
(plugin: "ln -vsfT ${plugin} $out/pack/${packageName}/start/${lib.getName plugin}")
startPluginsWithDeps}
${lib.concatMapStringsSep "\n"
(plugin: "ln -vsfT ${plugin} $out/pack/${packageName}/opt/${lib.getName plugin}")
optPluginsWithDeps}
'';
initLua = let
luaPackages = lp: [];
luaEnv = nvimPkg.lua.withPackages luaPackages;
inherit (nvimPkg.lua.pkgs.luaLib) genLuaPathAbsStr genLuaCPathAbsStr;
in pkgs.writeText "init.lua" ''
-- Don't use LUA_PATH and LUA_CPATH, since they leak into the LSP
package.path = "${genLuaPathAbsStr luaEnv};" .. package.path
package.cpath = "${genLuaCPathAbsStr luaEnv};" .. package.cpath
-- No remote plugins
vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_python_provider = 0
vim.g.loaded_python3_provider = 0
vim.g.loaded_ruby_provider = 0
require("dot013")
'';
in symlinkJoin {
name = "neovim-custom";
pname = "nvim";
paths = [nvimPkg];
nativeBuildInputs = [makeWrapper];
postBuild = ''
wrapProgram $out/bin/nvim \
--add-flags '-u' \
--add-flags '${initLua}' \
--add-flags '--cmd' \
--add-flags "'set packpath^=${packpath} | set runtimepath^=${packpath}'" \
--set-default NVIM_APPNAME nvim-custom
'';
passthru = {
inherit packpath;
};
}

1
plugin/init.lua Normal file
View File

@@ -0,0 +1 @@
require("dot013")