From 71c45e8397476cf9324618c953b169fb70ee9d97 Mon Sep 17 00:00:00 2001 From: Zhongheng Liu Date: Tue, 24 Mar 2026 12:13:36 +0100 Subject: [PATCH] initial home-manager setup with neovim and starship --- flake.lock | 48 +++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 +++++++++++++++++++++++++++++ home.nix | 44 +++++++++++++++++++++++++++++++++++++++++ neovim/coc.part.lua | 36 ++++++++++++++++++++++++++++++++++ neovim/default.nix | 41 ++++++++++++++++++++++++++++++++++++++ neovim/init.lua | 35 +++++++++++++++++++++++++++++++++ 6 files changed, 235 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home.nix create mode 100644 neovim/coc.part.lua create mode 100644 neovim/default.nix create mode 100644 neovim/init.lua diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b8bf553 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ba331c1 --- /dev/null +++ b/flake.nix @@ -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 + }; + }; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..12caab4 --- /dev/null +++ b/home.nix @@ -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; + }; + }; + }; + }; +} diff --git a/neovim/coc.part.lua b/neovim/coc.part.lua new file mode 100644 index 0000000..766ba3b --- /dev/null +++ b/neovim/coc.part.lua @@ -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 ' 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", "", 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "" : coc#refresh()', opts) +keyset("i", "", [[coc#pum#visible() ? coc#pum#prev(1) : "\"]], opts) + +-- Make to accept selected completion item or notify coc.nvim to format +-- u breaks current undo, please make your own choice +keyset("i", "", [[coc#pum#visible() ? coc#pum#confirm() : "\u\\=coc#on_enter()\"]], opts) + +-- Use to trigger completion +keyset("i", "", "coc#refresh()", {silent = true, expr = true}) diff --git a/neovim/default.nix b/neovim/default.nix new file mode 100644 index 0000000..0377b6a --- /dev/null +++ b/neovim/default.nix @@ -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 + ]) + ); + }; + +} diff --git a/neovim/init.lua b/neovim/init.lua new file mode 100644 index 0000000..be8a4ce --- /dev/null +++ b/neovim/init.lua @@ -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", "-", require("oil").open_float, { desc = "Open Oil float" }) +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) +vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) +vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) +vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' })