initial home-manager setup with neovim and starship

This commit is contained in:
Zhongheng Liu 2026-03-24 12:13:36 +01:00
commit 71c45e8397
Signed by untrusted user who does not match committer: steven
GPG key ID: 805A28B071DAD84B
6 changed files with 235 additions and 0 deletions

48
flake.lock generated Normal file
View file

@ -0,0 +1,48 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1768598210,
"narHash": "sha256-kkgA32s/f4jaa4UG+2f8C225Qvclxnqs76mf8zvTVPg=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "c47b2cc64a629f8e075de52e4742de688f930dc6",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1768564909,
"narHash": "sha256-Kell/SpJYVkHWMvnhqJz/8DqQg2b6PguxVWOuadbHCc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e4bae1bd10c9c57b2cf517953ab70060a828ee6f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

31
flake.nix Normal file
View file

@ -0,0 +1,31 @@
{
description = "Home Manager configuration of steven";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in
{
homeConfigurations."steven" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [ ./home.nix ];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
};
}

44
home.nix Normal file
View file

@ -0,0 +1,44 @@
{ config, pkgs, ... }:
{
imports = [
./neovim
];
home.username = "steven";
home.homeDirectory = "/home/steven";
home.stateVersion = "25.11"; # Please read the comment before changing.
home.sessionVariables = {
QT_QPA_PLATFORMTHEME = "gtk3";
PATH = "$PATH:/home/steven/.local/share/JetBrains/Toolbox/scripts/";
};
programs = {
home-manager.enable = true;
fish.enable = true;
zoxide.enable = true;
starship = {
enable = true;
enableFishIntegration = config.programs.fish.enable;
settings = {
format = "$username@$hostname: $character";
right_format = "$directory$git_status$git_branch";
hostname = {
ssh_only = false;
style = "bold blue dimmed";
format = "[$hostname]($style)";
};
username = {
show_always = true;
format = "[$user]($style)";
};
directory = {
fish_style_pwd_dir_length = 4;
};
sudo = {
style = "bold green";
symbol = "SUDO";
disabled = false;
};
};
};
};
}

36
neovim/coc.part.lua Normal file
View file

@ -0,0 +1,36 @@
-- https://raw.githubusercontent.com/neoclide/coc.nvim/master/doc/coc-example-config.lua
-- Some servers have issues with backup files, see #649
vim.opt.backup = false
vim.opt.writebackup = false
-- Having longer updatetime (default is 4000 ms = 4s) leads to noticeable
-- delays and poor user experience
vim.opt.updatetime = 300
-- Always show the signcolumn, otherwise it would shift the text each time
-- diagnostics appeared/became resolved
vim.opt.signcolumn = "yes"
local keyset = vim.keymap.set
-- Autocomplete
function _G.check_back_space()
local col = vim.fn.col('.') - 1
return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil
end
-- Use Tab for trigger completion with characters ahead and navigate
-- NOTE: There's always a completion item selected by default, you may want to enable
-- no select by setting `"suggest.noselect": true` in your configuration file
-- NOTE: Use command ':verbose imap <tab>' to make sure Tab is not mapped by
-- other plugins before putting this into your config
local opts = {silent = false, noremap = true, expr = true, replace_keycodes = false}
keyset("i", "<TAB>", 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "<TAB>" : coc#refresh()', opts)
keyset("i", "<S-TAB>", [[coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"]], opts)
-- Make <CR> to accept selected completion item or notify coc.nvim to format
-- <C-g>u breaks current undo, please make your own choice
keyset("i", "<cr>", [[coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"]], opts)
-- Use <c-space> to trigger completion
keyset("i", "<c-space>", "coc#refresh()", {silent = true, expr = true})

41
neovim/default.nix Normal file
View file

@ -0,0 +1,41 @@
{config, pkgs, ...}:
{
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
coc = {
enable = true;
settings = {
"zig.enabled" = true;
"zig.startUpMessage" = true;
"zig.path" = "${pkgs.zls}/bin/zls";
"zig.debugLog" = false;
};
};
plugins = with pkgs.vimPlugins; [
oil-nvim
nvim-colorizer-lua
nvim-treesitter
mini-nvim
plenary-nvim
telescope-nvim
gitsigns-nvim
vim-airline
nvim-web-devicons
vim-startify
nvim-lspconfig
everforest
tokyonight-nvim
];
extraLuaConfig = with builtins; (
concatStringsSep "\n" (
map readFile [
./init.lua
./coc.part.lua
])
);
};
}

35
neovim/init.lua Normal file
View file

@ -0,0 +1,35 @@
vim.opt.number = true
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.undofile = true
vim.opt.clipboard = "unnamedplus"
vim.cmd [[
highlight Normal guibg=none
highlight NonText guibg=none
highlight Normal ctermbg=none
highlight NonText ctermbg=none
]]
vim.cmd.colorscheme "tokyonight-night";
-- Disable netrw first:
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.diagnostic.config({
virtual_text = true,
})
require("oil").setup({
default_file_explorer = true,
})
vim.lsp.config['rust-analyzer'] = {
cmd = { 'rust-analyzer' },
filetypes = { 'rust' },
root_markers = { {'Cargo.toml', 'Cargo.lock'} },
}
vim.lsp.enable('rust-analyzer')
-- Keymaps
vim.keymap.set("n", "-", require("oil").open, { desc = "Open Oil" })
vim.keymap.set("n", "<leader>-", require("oil").open_float, { desc = "Open Oil float" })
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })