Skip to content

Commit

Permalink
feat(shell): add neovim config
Browse files Browse the repository at this point in the history
  • Loading branch information
zakuciael committed Dec 15, 2024
1 parent 79cd8f9 commit 7a004af
Show file tree
Hide file tree
Showing 20 changed files with 464 additions and 53 deletions.
13 changes: 13 additions & 0 deletions .neoconf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"lspconfig": {
"nixd": {
"nixd": {
"options": {
"nixos": {
"expr": "(builtins.getFlake (builtins.toString ./.)).nixosConfigurations.${builtins.replaceStrings [\"\n\"] [\"\"] (builtins.readFile \"/etc/hostname\")}.options"
}
}
}
}
}
}
110 changes: 74 additions & 36 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
...
}:
with lib;
with lib.my; {
with lib.my;
{
# NixOS configuration
nix = {
settings = {
Expand All @@ -28,7 +29,7 @@ with lib.my; {
!include ${config.sops.templates."nix/access_tokens.conf".path}
'';
package = pkgs.nixVersions.latest;
nixPath = ["nixpkgs=${inputs.nixpkgs}"];
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
};

nixpkgs.pkgs = pkgs;
Expand Down Expand Up @@ -91,67 +92,85 @@ with lib.my; {

# Global packages
environment = {
systemPackages = with pkgs; [neovim git bash];
variables = {
EDITOR = "nvim";
};
shells = with pkgs; [bash];
systemPackages = with pkgs; [
git
bash
];
shells = with pkgs; [ bash ];
};

# Linux Kernel settings
boot = {
supportedFilesystems = ["ntfs"];

initrd.availableKernelModules = ["ehci_pci" "ahci" "nvme" "xhci_pci" "usbhid" "usb_storage" "sd_mod"];
supportedFilesystems = [ "ntfs" ];

initrd.availableKernelModules = [
"ehci_pci"
"ahci"
"nvme"
"xhci_pci"
"usbhid"
"usb_storage"
"sd_mod"
];
loader.efi.canTouchEfiVariables = true;

tmp.cleanOnBoot = true;

plymouth = {
enable = true;
themePackages = with pkgs; [nixos-blur-plymouth];
themePackages = with pkgs; [ nixos-blur-plymouth ];
theme = "nixos-blur";
};
};

# SOPS
sops = let
base = "nix/access-tokens";
secretNames = utils.recursiveReadSecretNames {inherit config base;};
secrets = utils.readSecrets {inherit config base;};
in {
templates = {
"nix/access_tokens.conf" = {
mode = "0440";
group = config.users.groups.keys.name;
content = ''
access-tokens = ${
lib.concatStringsSep " "
(
builtins.map
(entry: "${entry}=${utils.mkSecretPlaceholder config [base entry]}")
(builtins.attrNames secrets)
)
}
'';
sops =
let
base = "nix/access-tokens";
secretNames = utils.recursiveReadSecretNames { inherit config base; };
secrets = utils.readSecrets { inherit config base; };
in
{
templates = {
"nix/access_tokens.conf" = {
mode = "0440";
group = config.users.groups.keys.name;
content = ''
access-tokens = ${
lib.concatStringsSep " " (
builtins.map (
entry:
"${entry}=${
utils.mkSecretPlaceholder config [
base
entry
]
}"
) (builtins.attrNames secrets)
)
}
'';
};
};
secrets = {
"users/${username}/password".neededForUsers = true;
} // lib.listToAttrs (builtins.map (v: lib.nameValuePair v { }) secretNames);
};
secrets =
{"users/${username}/password".neededForUsers = true;}
// lib.listToAttrs (builtins.map (v: lib.nameValuePair v {}) secretNames);
};

# User settings
users.users.${username} = {
isNormalUser = true;
hashedPasswordFile = config.sops.secrets."users/${username}/password".path;
description = "Krzysztof Saczuk";
extraGroups = ["wheel" config.users.groups.keys.name];
extraGroups = [
"wheel"
config.users.groups.keys.name
];
};

# Home-manager
home-manager = {
extraSpecialArgs = {inherit pkgs lib;};
extraSpecialArgs = { inherit pkgs lib; };
sharedModules = [
inputs.nix-colors.homeManagerModule
inputs.sops-nix.homeManagerModule
Expand All @@ -174,6 +193,25 @@ with lib.my; {
services.xdg.enable = true;
hardware.grub.enable = true;
shell = {
neovim = {
enable = true;
lspPackages = with pkgs; [
# Lua
lua-language-server
stylua

# Nix
deadnix
statix
nixd
inputs.nixfmt.default
];
treesitterGrammars = [
"lua"
"luap"
"nix"
];
};
fish = {
enable = true;
default = true;
Expand Down
34 changes: 34 additions & 0 deletions dotfiles/nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local lazy_path = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"

if not (vim.uv or vim.loop).fs_stat(lazy_path) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable",
lazy_path })
end

vim.opt.rtp:prepend(lazy_path)

if not pcall(require, "lazy") then
vim.api.nvim_echo(
{ { ("Unable to load lazy from: %s\n"):format(lazy_path), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } },
true, {})
vim.fn.getchar()
vim.cmd.quit()
end

require("lazy").setup({
{
"AstroNvim/AstroNvim",
version = "^4",
import = "astronvim.plugins",
opts = {
icons_enabled = true,
},
},
{
"nvim-treesitter/nvim-treesitter",
commit = vim.fn.readfile(vim.fn.stdpath("config") .. "/treesitter-rev", "", 1)[1],
},
{ import = "community" },
{ import = "plugins" },
{ import = "lsp" },
})
11 changes: 11 additions & 0 deletions dotfiles/nvim/lua/community.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---@type LazySpec
return {
{
"AstroNvim/astrocommunity",
branch = "main"
},
{ import = "astrocommunity.colorscheme.catppuccin" },
{ import = "astrocommunity.pack.lua" },
{ import = "astrocommunity.diagnostics.trouble-nvim" },
{ import = "astrocommunity.utility.hover-nvim" },
}
38 changes: 38 additions & 0 deletions dotfiles/nvim/lua/lsp/nix.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---@type LazySpec
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "nix" },
},
},
{
"nvimtools/none-ls.nvim",
opts = function(_, opts)
local builtins = require("null-ls").builtins

opts.sources = require("astrocore").list_insert_unique(opts.sources, {
builtins.code_actions.statix,
builtins.diagnostics.deadnix,
builtins.formatting.nixfmt,
})
end,
},
{
"AstroNvim/astrolsp",
---@type AstroLSPOpts
opts = {
servers = { "nixd" },
config = {
nixd = {
nixpkgs = {
expr = "import (builtins.getFlake (builtins.toString ./.)).inputs.nixpkgs { }"
},
formatting = {
command = { "nixfmt" },
},
},
},
},
},
}
11 changes: 11 additions & 0 deletions dotfiles/nvim/lua/plugins/astrolsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---@type LazySpec
return {
"AstroNvim/astrolsp",
---@type AstroLSPOpts
opts = {
features = {
inlay_hints = true,
signature_help = true,
}
}
}
8 changes: 8 additions & 0 deletions dotfiles/nvim/lua/plugins/discord_rp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---@type LazySpec
return {
"IogaMaster/neocord",
event = "VeryLazy",
opts = {
log_level = nil,
},
}
38 changes: 38 additions & 0 deletions dotfiles/nvim/lua/plugins/mappings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---@type LazySpec
return {
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
mappings = {
n = {
-- Neotree: remember last source and make git the default
["<Leader>e"] = { "<Cmd>Neotree toggle source=git_status<CR>", desc = "Toggle Explorer" },
["<Leader>o"] = {
function()
if vim.bo.filetype == "neo-tree" then
vim.cmd.wincmd("p")
else
vim.cmd.Neotree({ "focus", "source=last" })
end
end,
desc = "Toggle Explorer Focus",
},
-- Switch between tabs
["<S-Tab>"] = { ":bprev<CR>" },
["<Tab>"] = { ":bnext<CR>" },

-- Disable hover.nvim when moving mouse
["<MouseMove>"] = false,
},
t = {
-- Easier escape from the toggleterm.nvim plugin
["<ESC><ESC>"] = { "<C-\\><C-n>" },
["<S-ESC>"] = { "<C-\\><C-n>" },
},
c = {
-- Write file as sudo
["w!!"] = { "w !sudo tee > /dev/null %", desc = "Write as sudo" },
},
}
},
}
29 changes: 29 additions & 0 deletions dotfiles/nvim/lua/plugins/mason.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- customize mason plugins
local suggested_packages = {}

--- Clear "ensure_installed" option but add pkgs to a "suggested-pkgs.json" file
--- so that missing pkgs can be installed via Nix dotfiles
local disable_auto_install = function(_, opts)
require("astrocore").list_insert_unique(suggested_packages, opts.ensure_installed or {})

local file = io.open(vim.fn.stdpath("data") .. "/suggested-pkgs.json", "w")
file:write(vim.fn.json_encode(suggested_packages))
file:close()

opts.ensure_installed = {}
end

return {
{
"williamboman/mason-lspconfig.nvim",
opts = disable_auto_install,
},
{
"jay-babu/mason-null-ls.nvim",
opts = disable_auto_install,
},
{
"jay-babu/mason-nvim-dap.nvim",
opts = disable_auto_install,
},
}
7 changes: 7 additions & 0 deletions dotfiles/nvim/lua/plugins/neo-tree.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---@type LazySpec
return {
"nvim-neo-tree/neo-tree.nvim",
opts = {
follow_current_file = true,
},
}
11 changes: 11 additions & 0 deletions dotfiles/nvim/lua/plugins/neoconf.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---@types LazySpec
return {
"folke/neoconf.nvim",
opts = {
import = {
vscode = false,
coc = false,
nlsp = false,
}
}
}
9 changes: 9 additions & 0 deletions dotfiles/nvim/lua/plugins/spaceless.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---@type LazySpec
return {
{
"lewis6991/spaceless.nvim",
init = function()
require("spaceless").setup()
end,
},
}
Loading

0 comments on commit 7a004af

Please sign in to comment.