diff --git a/static/static/home.nix b/static/static/home.nix new file mode 100644 index 0000000..4a4a1f0 --- /dev/null +++ b/static/static/home.nix @@ -0,0 +1,91 @@ +{ config, pkgs, ... }: + +let + nixvim = import (builtins.fetchGit { + url = "https://github.com/nix-community/nixvim"; + # When using a different channel you can use `ref = "nixos-"` to set it here + }); +in +{ + nix = { + package = pkgs.nix; + settings.experimental-features = [ "nix-command" "flakes" ]; + }; + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "nixolas"; + home.homeDirectory = "/home/nixolas"; + + imports = [ + nixvim.homeManagerModules.nixvim + ./neovim.nix + ]; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "24.05"; # Please read the comment before changing. + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = [ + # # Adds the 'hello' command to your environment. It prints a friendly + # # "Hello, world!" when run. + # pkgs.hello + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. These will be explicitly sourced when using a + # shell provided by Home Manager. If you don't want to manage your shell + # through Home Manager then you have to manually source 'hm-session-vars.sh' + # located at either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/nixolas/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + # EDITOR = "emacs"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/static/static/neovim.nix b/static/static/neovim.nix new file mode 100644 index 0000000..38f2837 --- /dev/null +++ b/static/static/neovim.nix @@ -0,0 +1,281 @@ +{ pkgs, lib, ... }: +let +in +{ + + home.packages = with pkgs; [ + # Required clipboard provider + xclip + # Required for find in file + ripgrep + ]; + + programs.nixvim = { + enable = true; + viAlias = true; + vimAlias = true; + + globals = { + mapleader = " "; + }; + + filetype.extension = { + templ = "templ"; + }; + + opts = { + autoindent = true; + expandtab = true; + foldlevel=20; + guifont = "MesloLGS\ NF\ 10"; + number = true; + shiftwidth = 4; + tabstop = 4; + }; + + keymaps = [ + # Modes: https://superuser.com/questions/1702308/how-can-i-configure-shortcut-keys-in-all-modes-of-vim + # n - normal + # i - insert + # c - cmd + # v - visual select + # x - visual only + # s - selection + # o - oper + # t - terminal + # l - lang + { + # Open new vertical split and starts a new terminal window + mode = "n"; + key = "ot"; + action = "vs | te"; + } + { + # toggle the left tree panel + mode = "n"; + key = "op"; + action = "NvimTreeToggle"; + } + { + # Open cwd filename fuzzy search + mode = "n"; + key = "o."; + action = "Telescope file_browser"; + } + { + # Open fuzzy filename recursive search + mode = "n"; + key = "."; + action = "Telescope find_files"; + } + { + # Search file contents of cwd + mode = "n"; + key = "of"; + action = "Telescope live_grep"; + } + { + # Keep cursor centered while navigating + mode = "n"; + key = ""; + action = "zz"; + } + { + # Keep cursor centered while navigating + mode = "n"; + key = ""; + action = "zz"; + } + { + # Keep cursor centered while skipping to search results + mode = "n"; + key = "n"; + action = "nzzzv"; + } + { + # Keep cursor centered while skipping to search results + mode = "n"; + key = "N"; + action = "Nzzzv"; + } + { + # Yank to system clipboard + mode = "n"; + key = "y"; + action = "\"+y"; + } + { + # Yank to system clipboard + mode = "n"; + key = "Y"; + action = "\"+Y"; + } + { + # Delete into the void + mode = "n"; + key = "d"; + action = "\"_d"; + } + + { + # Move visual selection up one row + mode = "v"; + key = "J"; + action = ":m '>+1gv=gv"; + } + { + # Move visual selection down one row + mode = "v"; + key = "K"; + action = ":m '<-2gv=gv"; + } + { + mode = "v"; + key = ">"; + action = ">gv"; + } + { + mode = "v"; + key = "<"; + action = "' -A install + + echo "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" >> ~/.bashrc + mkdir -p ~/.config/home-manager/rsrcs + curl -L "https://staticpages.nickiel.net/static/home.nix" >> ~/.config/home-manager/home.nix + curl -L "https://staticpages.nickiel.net/static/neovim.nix" >> ~/.config/home-manager/neovim.nix + curl -L "https://staticpages.nickiel.net/static/rscrs/nvim.lua" >> ~/.config/home-manager/rsrcs/nvim.lua + + sudo chmod +x ~/.nix-profile/etc/profile.d/hm-session-vars.sh; + home-manager switch; + + echo "[all]\ndtparam=pciex1_gen=3" | sudo tee -a /boot/firmware/config.txt; + sudo sed -i '3a\ + kernel=kernel8.img + ' /boot/firmware/config.txt + + echo "Restart the device, and you should be good to go"; +else + echo "Invalid arguments. This script takes no arguments, or `stage_two`" +fi + + diff --git a/static/static/rsrcs/nvim.lua b/static/static/rsrcs/nvim.lua new file mode 100644 index 0000000..7342d2b --- /dev/null +++ b/static/static/rsrcs/nvim.lua @@ -0,0 +1,186 @@ + +-- Attached rust-analyzer server +local rt = require("rust-tools") + +rt.setup({ + server = { + on_attach = function(_, bufnr) + -- Hover actions + vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) + -- Code action groups + vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) + end, + }, +}) + +-- LSP Diagnostics Options Setup +local sign = function(opts) + vim.fn.sign_define(opts.name, { + texthl = opts.name, + text = opts.text, + numhl = '' + }) +end + +sign({name = 'DiagnosticSignError', text = ''}) +sign({name = 'DiagnosticSignWarn', text = ''}) +sign({name = 'DiagnosticSignHint', text = '󰋼'}) +sign({name = 'DiagnosticSignInfo', text = '󰋽'}) + +vim.diagnostic.config({ + virtual_text = false, + signs = true, + update_in_insert = true, + underline = true, + severity_sort = false, + float = { + border = 'rounded', + source = 'always', + header = '', + prefix = '', + }, +}) + +vim.cmd([[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + + +--Set completeopt to have a better completion experience +-- :help completeopt +-- menuone: popup even when there's only one match +-- noinsert: Do not insert text until a selection is made +-- noselect: Do not select, force to select one from the menu +-- shortness: avoid showing extra messages when using completion +-- updatetime: set updatetime for CursorHold +vim.opt.shortmess = vim.opt.shortmess + { c = true} +vim.api.nvim_set_option('updatetime', 300) + +-- Fixed column for diagnostics to appear +-- Show autodiagnostic popup on cursor hover_range +-- Goto previous / next diagnostic warning / error +-- Show inlay_hints more frequently +vim.cmd([[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]]) + +-- Completion Plugin Setup +local cmp = require'cmp' +cmp.setup({ + -- Enable LSP snippets + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + -- Add tab support + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }, + -- Installed sources: + sources = { + { name = 'path' }, -- file paths + { name = 'nvim_lsp', keyword_length = 3 }, -- from language server + { name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized + { name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.* + { name = 'buffer', keyword_length = 2 }, -- source current buffer + { name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip + { name = 'calc'}, -- source for math calculation + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon ={ + nvim_lsp = 'λ', + vsnip = '⋗', + buffer = 'Ω', + path = '', + } + item.menu = menu_icon[entry.source.name] + return item + end, + }, +}) + +-- https://github.com/phaazon/hop.nvim/wiki/Advanced-Hop +local hop = require('hop') +hop.setup { + keys = 'etovxqpdygfblzhckisuran', +} +local directions = require('hop.hint').HintDirection +vim.keymap.set('', 'ff', function() + hop.hint_patterns({ multi_windows = true, current_line_only = false }) +end, {remap=true}) + +vim.opt.scrolloff = 8; + + +require("telescope").load_extension "file_browser" + +-- Themeing +require("monokai-pro").setup({ + transparent_background = true, + terminal_colors = true, + devicons = true, -- highlight the icons of `nvim-web-devicons` + styles = { + comment = { italic = true }, + keyword = { italic = true }, -- any other keyword + type = { italic = true }, -- (preferred) int, long, char, etc + storageclass = { italic = true }, -- static, register, volatile, etc + structure = { italic = true }, -- struct, union, enum, etc + parameter = { italic = true }, -- parameter pass in function + annotation = { italic = true }, + tag_attribute = { italic = true }, -- attribute of tag in reactjs + }, + filter = "pro", -- classic | octagon | pro | machine | ristretto | spectrum + -- Enable this will disable filter option + day_night = { + enable = false, -- turn off by default + day_filter = "pro", -- classic | octagon | pro | machine | ristretto | spectrum + night_filter = "spectrum", -- classic | octagon | pro | machine | ristretto | spectrum + }, + inc_search = "background", -- underline | background + background_clear = { + -- "float_win", + "toggleterm", + "telescope", + -- "which-key", + "renamer", + "notify", + -- "nvim-tree", + -- "neo-tree", + -- "bufferline", -- better used if background of `neo-tree` or `nvim-tree` is cleared + },-- "float_win", "toggleterm", "telescope", "which-key", "renamer", "neo-tree", "nvim-tree", "bufferline" + plugins = { + bufferline = { + underline_selected = false, + underline_visible = false, + }, + indent_blankline = { + context_highlight = "default", -- default | pro + context_start_underline = false, + }, + }, + ---@param c Colorscheme + override = function(c) end, +}) + +vim.cmd.colorscheme "monokai-pro-spectrum" +