Skip to content

Commit

Permalink
feat(neovim): independence from home-manager
Browse files Browse the repository at this point in the history
switch from lazy.nvim to lz.n
  • Loading branch information
natsukium committed Jan 4, 2025
1 parent aa0faa7 commit ec28da3
Show file tree
Hide file tree
Showing 15 changed files with 287 additions and 378 deletions.
111 changes: 0 additions & 111 deletions applications/nvim/default.nix

This file was deleted.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
cachix-deploy-lib = inputs.cachix-deploy-flake.lib pkgs;
in
{
neovim = pkgs.callPackage ./pkgs/neovim-with-config { };
cachix-deploy = cachix-deploy-lib.spec {
agents = {
mikumi = self.darwinConfigurations.mikumi.config.system.build.toplevel;
Expand Down
10 changes: 9 additions & 1 deletion homes/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ in
colorScheme = nix-colors.colorSchemes.nord;
base16.enable = true;

# editor
home.packages = [
(pkgs.callPackage ../pkgs/neovim-with-config { })
pkgs.neovim-remote
];
home.sessionVariables = {
EDITOR = "nvim";
};

imports = [
nix-colors.homeManagerModule
../modules/home-manager
Expand All @@ -29,7 +38,6 @@ in
../applications/misc
../applications/nix
../applications/nushell
../applications/nvim
../applications/rbw
../applications/starship
../applications/tmux
Expand Down
133 changes: 133 additions & 0 deletions pkgs/neovim-with-config/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
lib,
neovim-unwrapped,
neovimUtils,
vimPlugins,
wrapNeovimUnstable,
replaceVars,

# runtime dependencies
astro-language-server,
basedpyright,
bash-language-server,
biome,
docker-compose-language-service,
dockerfile-language-server-nodejs,
hadolint,
lua-language-server,
nixd,
nixfmt-rfc-style,
rubocop,
ruff,
shellcheck,
shfmt,
solargraph,
stylua,
taplo,
terraform-ls,
tinymist,
typescript-language-server,
typos-lsp,
typstyle,
wakatime-cli,
yaml-language-server,
}:
let
mapBuiltinPluginToPath = map (p: "$out/share/nvim/runtime/plugin/${p}");
disabledBuiltinPluginPaths = mapBuiltinPluginToPath [
"gzip.vim"
"matchit.vim"
"matchparen.vim"
"netrwPlugin.vim"
"tarPlugin.vim"
"tohtml.lua"
"tutor.vim"
"zipPlugin.vim"
];

language-servers = [
# astro
astro-language-server
# bash
bash-language-server
shellcheck
shfmt
# docker
dockerfile-language-server-nodejs
hadolint
docker-compose-language-service
# javascript
biome
# lua
lua-language-server
stylua
# nix
nixd
nixfmt-rfc-style
# python
basedpyright
ruff
# ruby
solargraph
rubocop
# terraform
terraform-ls
# toml
taplo
# typescript
typescript-language-server
# typst
tinymist
typstyle
# yaml
yaml-language-server
# spell check
typos-lsp
];

tools = [
(wakatime-cli.overrideAttrs { __darwinAllowLocalNetworking = true; })
];

extraWrapperArgs = [
"--suffix"
"PATH"
":"
(lib.makeBinPath (language-servers ++ tools))
];

config = neovimUtils.makeNeovimConfig {
withNodeJs = true; # for copilot
withRuby = false;
withPython3 = false;
vimAlias = true;
luaRcContent = builtins.readFile (
replaceVars ./init.lua {
myconfig = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.difference ./. (
lib.fileset.unions [
./init.lua
./plugins.nix
./default.nix
]
);
};
}
);

plugins = import ./plugins.nix { inherit vimPlugins; };

};
in
(wrapNeovimUnstable neovim-unwrapped (
# if wrapperArgs is defined directly in config, it will somehow be overwritten
config // { wrapperArgs = config.wrapperArgs ++ extraWrapperArgs; }
)).overrideAttrs
(oldAttrs: {
postInstall =
(oldAttrs.postInstall or "")
+ ''
echo ${lib.concatStringsSep " " disabledBuiltinPluginPaths} | xargs rm
'';
})
File renamed without changes.
33 changes: 3 additions & 30 deletions applications/nvim/init.lua → pkgs/neovim-with-config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ vim.keymap.set("n", "<Esc><Esc>", ":nohlsearch<CR><Esc>")
-- terminal
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { noremap = true })

local function float_term(cmd)
local opts = { size = { width = 0.9, height = 0.9 } }
require("lazy.util").float_term(cmd, opts)
end
vim.keymap.set("n", "<Leader>gg", function()
float_term({ "lazygit" })
end)

-- buffers
vim.keymap.set("n", "[b", "<cmd>bprevious<CR>", { desc = "Prev buffer" })
vim.keymap.set("n", "]b", "<cmd>bnext<CR>", { desc = "Next buffer" })
Expand All @@ -61,27 +53,8 @@ vim.keymap.set("n", "<leader><tab>]", "<cmd>tabnext<cr>", { desc = "Next Tab" })
vim.keymap.set("n", "<leader><tab>d", "<cmd>tabclose<cr>", { desc = "Close Tab" })
vim.keymap.set("n", "<leader><tab>[", "<cmd>tabprevious<cr>", { desc = "Previous Tab" })

local lazypath = "@lazy_nvim@"
vim.opt.rtp:prepend(lazypath)
vim.opt.rtp:prepend("@myconfig@")

require("lazy").setup({
defaults = { lazy = true },
rocks = { enabled = false },
performance = {
rtp = {
disabled_plugins = {
"gzip",
"matchit",
"matchparen",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
spec = "plugins",
})
require("lz.n").load("plugins")

require("misc")
vim.cmd([[colorscheme nord]])
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
return {
{
name = "nvim-cmp",
dir = "@nvim_cmp@",
"nvim-cmp",
event = { "InsertEnter", "CmdlineEnter" },
dependencies = {
{ name = "cmp-buffer", dir = "@cmp_buffer@" },
{ name = "cmp-nvim-lsp", dir = "@cmp_nvim_lsp@" },
{ name = "cmp-path", dir = "@cmp_path@" },
{
name = "cmp_luasnip",
dir = "@cmp_luasnip@",
dependencies = { name = "LuaSnip", dir = "@luasnip@" },
},
{ name = "cmp-cmdline", dir = "@cmp_cmdline@" },
{ name = "lspkind.nvim", dir = "@lspkind_nvim@" },
{ name = "copilot-cmp", dir = "@copilot_cmp@", config = true },
},
opts = function()
after = function()
vim.g.completeopt = "menu,menuone,noselect"
local cmp = require("cmp")
local luasnip = require("luasnip")
Expand Down Expand Up @@ -66,10 +52,9 @@ return {
end,
},
{
name = "copilot.lua",
dir = "@copilot_lua@",
"copilot.lua",
event = "InsertEnter",
config = function()
after = function()
require("copilot").setup({
suggestion = { enabled = false },
panel = { enabled = false },
Expand Down
Loading

0 comments on commit ec28da3

Please sign in to comment.