diff --git a/.ackrc b/.ackrc deleted file mode 100644 index a72aa9d..0000000 --- a/.ackrc +++ /dev/null @@ -1,2 +0,0 @@ ---pager=less -R ---ignore-case diff --git a/.config/ghostty/config b/.config/ghostty/config index 4437ccf..ddfc72c 100644 --- a/.config/ghostty/config +++ b/.config/ghostty/config @@ -5,4 +5,6 @@ # on Ghostty's website, at https://ghostty.org/docs/config. theme = tokyonight - +working-directory = home +quit-after-last-window-closed = true +window-inherit-working-directory = false diff --git a/.config/home-manager/common.nix b/.config/home-manager/common.nix new file mode 100644 index 0000000..b0968eb --- /dev/null +++ b/.config/home-manager/common.nix @@ -0,0 +1,155 @@ +{ config, pkgs, ... }: + +{ + home.packages = [ + pkgs.ack + pkgs.act + pkgs.awscli2 + pkgs.dive + pkgs.fd + pkgs.fzf + pkgs.gh + pkgs.git + pkgs.gnupg + pkgs.jq + pkgs.kind + pkgs.k9s + pkgs.kubectl + pkgs.kubernetes-helm + pkgs.lazydocker + pkgs.lazygit + pkgs.neovim + pkgs.ripgrep + pkgs.tmux + pkgs.yq + pkgs.yt-dlp + ]; + + home.file = { + ".ackrc".text = '' + --pager=less -R + --ignore-case + ''; + + ".tmux.conf".source = ../../tmux.conf; + + ".config/atuin".source = ../atuin; + ".config/ghostty".source = ../ghostty; + ".config/k9s".source = ../k9s; + ".config/nvim".source = ../nvim; + }; + + # Common session variables + home.sessionVariables = { + AWS_CLI_AUTO_PROMPT = "on-partial"; + EDITOR = "nvim"; + KUBE_EDITOR = "nvim"; + }; + + # Enable and configure Fish shell + programs.fish = { + enable = true; + + plugins = [ + { + name = "pure"; + src = pkgs.fishPlugins.pure.src; + } + ]; + + functions = { + aws-ps = '' + set profile $(aws configure list-profiles | fzf --height=30% --layout=reverse) + if set --query profile + set -gx AWS_PROFILE $profile + echo "AWS profile $AWS_PROFILE now active." + end + ''; + }; + + # Fish shell configuration + shellInit = '' + # Commands to run when fish starts (non-interactive) + set PATH $PATH /opt/homebrew/bin + set PATH $HOME/.orbstack/bin $PATH + ''; + + interactiveShellInit = '' + # Commands to run in interactive sessions + # Initialize atuin if available + if command -q atuin + atuin init fish | source + end + ''; + + # Fish shell aliases + shellAliases = { + lg = "lazygit"; + + # Quick reload aliases + rl = "exec fish"; + src = "source ~/.config/fish/config.fish"; + + # Home Manager aliases + hm = "home-manager"; + hms = "home-manager switch"; + hmb = "home-manager build --no-out-link"; + }; + }; + + # Configure direnv with nix-direnv for automatic Nix environment loading + programs.direnv = { + enable = true; + nix-direnv.enable = true; + }; + + programs.git = { + enable = true; + userName = "Mike Priscella"; + userEmail = "mpriscella@gmail.com"; + + extraConfig = { + core.editor = "nvim"; + color.ui = "auto"; + init.defaultBranch = "main"; + pull.rebase = false; + push.default = "simple"; + }; + + aliases = { + chb = "checkout -b"; + empty = "commit --allow-empty -n -m 'Empty-Commit'"; + }; + + ignores = [ + # OS generated files + ".DS_Store" + ".DS_Store?" + "._*" + ".Spotlight-V100" + ".Trashes" + "ehthumbs.db" + "Thumbs.db" + + # IDE files + ".vscode/" + ".idea/" + "*.swp" + "*.swo" + "*~" + + # Build artifacts + "node_modules/" + "target/" + "dist/" + "build/" + + # Environment files + ".env" + ".env.local" + ]; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/.config/home-manager/hosts/default.nix b/.config/home-manager/hosts/default.nix new file mode 100644 index 0000000..f533feb --- /dev/null +++ b/.config/home-manager/hosts/default.nix @@ -0,0 +1,45 @@ +{ config, pkgs, lib, ... }: + +let + # Automatically detect username from environment + username = builtins.getEnv "USER"; + + # Construct home directory based on detected username and OS + homeDirectory = + if pkgs.stdenv.isDarwin + then "/Users/${username}" + else "/home/${username}"; + + # Detect hostname for configuration path + hostname = + let + envHostname = builtins.getEnv "HOSTNAME"; + in + if envHostname != "" then envHostname + else if builtins.pathExists /etc/hostname then builtins.readFile /etc/hostname + else "unknown"; +in + +{ + imports = [ + ../common.nix + ../modules/machine-config.nix + ]; + + # Automatically inferred values + home.username = username; + home.homeDirectory = homeDirectory; + home.stateVersion = "25.05"; + + # Custom configuration using our module + myConfig = { + configPath = "${homeDirectory}/.config/home-manager/hosts/default.nix"; + }; + + # Optional: Add some debug info to session variables + home.sessionVariables = { + HM_DETECTED_USER = username; + HM_DETECTED_HOME = homeDirectory; + HM_DETECTED_HOST = hostname; + }; +} diff --git a/.config/home-manager/hosts/macbook-air.nix b/.config/home-manager/hosts/macbook-air.nix new file mode 100644 index 0000000..bf9a987 --- /dev/null +++ b/.config/home-manager/hosts/macbook-air.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../common.nix + ../modules/machine-config.nix + ]; + + home.username = "mpriscella"; + home.homeDirectory = "/Users/mpriscella"; + home.stateVersion = "25.05"; + + # Custom configuration using our module + myConfig = { + configPath = "${config.home.homeDirectory}/.config/home-manager/hosts/macbook-air.nix"; + }; +} diff --git a/.config/home-manager/hosts/work-macbook-pro.nix b/.config/home-manager/hosts/work-macbook-pro.nix new file mode 100644 index 0000000..5be5cc6 --- /dev/null +++ b/.config/home-manager/hosts/work-macbook-pro.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../common.nix + ../modules/machine-config.nix + ]; + + home.username = "michaelpriscella"; + home.homeDirectory = "/Users/michaelpriscella"; + home.stateVersion = "25.05"; + + # Custom configuration using our module + myConfig = { + configPath = "${config.home.homeDirectory}/.config/home-manager/hosts/work-macbook-pro.nix"; + }; +} diff --git a/.config/home-manager/modules/machine-config.nix b/.config/home-manager/modules/machine-config.nix new file mode 100644 index 0000000..a3ba73a --- /dev/null +++ b/.config/home-manager/modules/machine-config.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options.myConfig = { + configPath = mkOption { + type = types.str; + default = "${config.home.homeDirectory}/.config/home-manager/home.nix"; + description = "Path to the home-manager configuration file for this machine"; + }; + }; + + config = { + # Use your custom options here + home.packages = with pkgs; [ + # Custom build script + (writeShellScriptBin "home-manager-build" '' + echo "Building Home Manager configuration..." + echo "Using config: ${config.myConfig.configPath}" + exec home-manager build --file "${config.myConfig.configPath}" "$@" + '') + + # Custom switch script + (writeShellScriptBin "home-manager-switch" '' + echo "Switching Home Manager configuration..." + echo "Using config: ${config.myConfig.configPath}" + exec home-manager switch --file "${config.myConfig.configPath}" "$@" + '') + ]; + }; +} diff --git a/.config/k9s/plugins.yaml b/.config/k9s/plugins.yaml index 8f2e597..d401e84 100644 --- a/.config/k9s/plugins.yaml +++ b/.config/k9s/plugins.yaml @@ -2,7 +2,7 @@ plugins: # Create debug container for selected pod in current namespace. # See https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container debug-container: - shortCut: Shift-D + shortCut: d description: Add debug container dangerous: true scopes: diff --git a/.config/nvim/after/ftplugin/terraform.lua b/.config/nvim/after/ftplugin/terraform.lua index 616b23d..ae5925e 100644 --- a/.config/nvim/after/ftplugin/terraform.lua +++ b/.config/nvim/after/ftplugin/terraform.lua @@ -1,18 +1,23 @@ vim.bo.commentstring = '# %s' local function add_comment_header() - local line_number = vim.api.nvim_win_get_cursor(0)[1] + local line_length = 80 + local current_line = vim.api.nvim_win_get_cursor(0)[1] local line = vim.api.nvim_get_current_line() local bookend = '################################################################################' - vim.api.nvim_buf_set_lines(0, line_number - 1, line_number, true, { + -- for i = 1, line_length, 1 do + -- bookend = bookend .. '#' + -- end + + vim.api.nvim_buf_set_lines(0, current_line - 1, current_line, true, { bookend, '# ' .. line, }) - vim.api.nvim_buf_set_lines(0, line_number + 1, line_number + 1, true, { bookend }) + vim.api.nvim_buf_set_lines(0, current_line + 1, current_line + 1, true, { bookend }) if line == '' then - vim.api.nvim_win_set_cursor(0, { line_number + 1, 2 }) + vim.api.nvim_win_set_cursor(0, { current_line + 1, 2 }) vim.cmd 'startinsert' end end diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index f826047..af334be 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,6 +1,4 @@ -- Set ',' as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) vim.g.mapleader = ',' vim.g.maplocalleader = ',' @@ -12,14 +10,18 @@ vim.g.have_nerd_font = true -- NOTE: You can change these options as you wish! -- For more options, you can see `:help option-list` --- Make line numbers default +-- Make line numbers default. vim.opt.number = true --- You can also add relative line numbers, to help with jumping. --- Experiment for yourself to see if you like it! + +-- Ensure statusline is full width. +vim.o.laststatus = 3 + +-- Enable relative line numbers. vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' + -- Disable horizontal scroll. vim.opt.mousescroll = 'ver:3,hor:0' @@ -137,7 +139,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { }) -- [[ Install `lazy.nvim` plugin manager ]] --- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info +-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info. local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' @@ -149,18 +151,7 @@ end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) -- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run --- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins you can run --- :Lazy update --- --- NOTE: Here is where you install your plugins. require('lazy').setup { - -- LSP Plugins { -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins -- used for completion, annotations and signatures of Neovim apis diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 969959f..a3d2b60 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,49 +1,49 @@ { - "LuaSnip": { "branch": "master", "commit": "33b06d72d220aa56a7ce80a0dd6f06c70cd82b9d" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "codesnap.nvim": { "branch": "main", "commit": "6400480aa6cc366cbd931146c429aaa64680dab9" }, - "conform.nvim": { "branch": "master", "commit": "9180320205d250429f0f80e073326c674e2a7149" }, - "fidget.nvim": { "branch": "main", "commit": "9238947645ce17d96f30842e61ba81147185b657" }, - "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, - "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, - "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, - "lazydev.nvim": { "branch": "main", "commit": "8620f82ee3f59ff2187647167b6b47387a13a018" }, - "lazygit.nvim": { "branch": "main", "commit": "77a0d42943d8265271e6e6beaed72da54eeb17e7" }, - "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, - "luvit-meta": { "branch": "main", "commit": "57d464c4acb5c2e66bd4145060f5dc9e96a7bbb7" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, - "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "2faada1cffce5609d78ac5e81eaf3754e0476758" }, - "neo-tree.nvim": { "branch": "main", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, - "noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" }, - "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, - "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, - "nvim-cmp": { "branch": "main", "commit": "b555203ce4bd7ff6192e759af3362f9d217e8c89" }, - "nvim-dap": { "branch": "master", "commit": "665d3569a86395fe0dab85efbdb26d7d2ee57e49" }, - "nvim-dap-go": { "branch": "main", "commit": "6aa88167ea1224bcef578e8c7160fe8afbb44848" }, - "nvim-dap-ui": { "branch": "master", "commit": "e94d98649dccb6a3884b66aabc2e07beb279e535" }, - "nvim-lint": { "branch": "master", "commit": "1fea92f1d9908eaa5eb8bafe08b4293d7aadaa55" }, - "nvim-lspconfig": { "branch": "master", "commit": "ff2b85abaa810f6611233dbe6d31c07510ebf43d" }, - "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-notify": { "branch": "master", "commit": "29b33efc802a304b1cf13ab200915d4e9e67373d" }, - "nvim-treesitter": { "branch": "master", "commit": "eb3e850acff4d9f2f2dd8dacd75353043c899753" }, - "nvim-web-devicons": { "branch": "master", "commit": "63f552a7f59badc6e6b6d22e603150f0d5abebb7" }, - "overseer.nvim": { "branch": "master", "commit": "10ee48ff96c8d1049efb278ea4c8cf9f3b0e4326" }, - "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, - "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "avante.nvim": { "branch": "main", "commit": "fdf4716ec04cf5d9f8f39a44b7d42ab37cc2bd40" }, + "blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" }, + "codesnap.nvim": { "branch": "main", "commit": "be6d6b9a3b5e6999edbda76b16dace03d9bfcd3d" }, + "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, + "copilot.lua": { "branch": "master", "commit": "c1bb86abbed1a52a11ab3944ef00c8410520543d" }, + "copilot.vim": { "branch": "release", "commit": "3955014c503b0cd7b30bc56c86c56c0736ca0951" }, + "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, + "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "fzf-lua": { "branch": "main", "commit": "d155cc9648ba391f64876888ea0ae09a7aff469d" }, + "gitsigns.nvim": { "branch": "main", "commit": "731b581428ec6c1ccb451b95190ebbc6d7006db7" }, + "hardtime.nvim": { "branch": "main", "commit": "145b930954a3146cfb5b8a73cdcad42eb7d2740c" }, + "img-clip.nvim": { "branch": "main", "commit": "d8b6b030672f9f551a0e3526347699985a779d93" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, + "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, + "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "bef29b653ba71d442816bf56286c2a686210be04" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" }, + "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, + "mini.pick": { "branch": "main", "commit": "fdb920aa92ed624a0447bc13ddac79d9d2653c24" }, + "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-dap": { "branch": "master", "commit": "40a8189b8a57664a1850b0823fdcb3ac95b9f635" }, + "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, + "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, + "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, + "nvim-lspconfig": { "branch": "master", "commit": "7ad4a11cc5742774877c529fcfb2702f7caf75e4" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, + "nvim-surround": { "branch": "main", "commit": "8dd9150ca7eae5683660ea20cec86edcd5ca4046" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-treesitter-context": { "branch": "master", "commit": "1a1a7c5d6d75cb49bf64049dafab15ebe294a79f" }, + "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "render-markdown.nvim": { "branch": "main", "commit": "76f7ce56ccb913632745714f160faa53164c5574" }, + "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "toggleterm.nvim": { "branch": "main", "commit": "022ff5594acccc8d90d2e46dc43994f7722ebdf7" }, - "tokyonight.nvim": { "branch": "main", "commit": "45d22cf0e1b93476d3b6d362d720412b3d34465c" }, - "trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" }, - "vim-helm": { "branch": "master", "commit": "ae1ebc160d2b9b90108477ab10df7a4fc501e358" }, - "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, - "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" }, - "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } + "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, + "vim-helm": { "branch": "master", "commit": "cc5ac22444332381f38084a6c7f023c25eef6201" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/.config/nvim/lua/custom/plugins/autocompletion.lua b/.config/nvim/lua/custom/plugins/autocompletion.lua index e90ea08..025986d 100644 --- a/.config/nvim/lua/custom/plugins/autocompletion.lua +++ b/.config/nvim/lua/custom/plugins/autocompletion.lua @@ -1,115 +1,47 @@ --- Autocompletion return { - { - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - 'L3MON4D3/LuaSnip', - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - dependencies = { - { - 'rafamadriz/friendly-snippets', - config = function() - require('luasnip.loaders.from_vscode').lazy_load() - end, - }, - }, - }, - 'saadparwaiz1/cmp_luasnip', - - -- Adds other completion capabilities. - -- nvim-cmp does not ship with all sources by default. They are split - -- into multiple repos for maintenance purposes. - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-path', + 'saghen/blink.cmp', + dependencies = { 'rafamadriz/friendly-snippets' }, + + version = '1.*', + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { preset = 'default' }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono', }, - config = function() - -- See `:help cmp` - local cmp = require 'cmp' - local luasnip = require 'luasnip' - luasnip.config.setup {} - - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = 'menu,menuone,noinsert' }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert { - -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), - - -- Scroll the documentation window [b]ack / [f]orward - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - -- Accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + -- (Default) Only show the documentation popup when manually triggered + completion = { documentation = { auto_show = false } }, - -- If you prefer more traditional completion keymaps, - -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), - - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [''] = cmp.mapping.complete {}, - - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [''] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { 'i', 's' }), + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { 'lsp', 'path', 'snippets', 'buffer' }, + }, - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }, - sources = { - { - name = 'lazydev', - -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it - group_index = 0, - }, - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - }, - } - end, + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = 'prefer_rust_with_warning' }, }, + opts_extend = { 'sources.default' }, } diff --git a/.config/nvim/lua/custom/plugins/autoformat.lua b/.config/nvim/lua/custom/plugins/autoformat.lua index 10f209e..72439de 100644 --- a/.config/nvim/lua/custom/plugins/autoformat.lua +++ b/.config/nvim/lua/custom/plugins/autoformat.lua @@ -1,46 +1,39 @@ --- Autoformat return { - { - 'stevearc/conform.nvim', - event = { 'BufWritePre' }, - cmd = { 'ConformInfo' }, - keys = { - { - 'f', - function() - require('conform').format { async = true, lsp_format = 'fallback' } - end, - mode = '', - desc = '[F]ormat buffer', - }, - }, - opts = { - notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { cpp = true } - local lsp_format_opt - if disable_filetypes[vim.bo[bufnr].filetype] then - lsp_format_opt = 'never' - else - lsp_format_opt = 'fallback' - end - return { - timeout_ms = 500, - lsp_format = lsp_format_opt, - } + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { + 'f', + function() + require('conform').format { async = true, lsp_format = 'fallback' } end, - formatters_by_ft = { - lua = { 'stylua' }, - php = { 'phpcbf' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, - }, + mode = '', + desc = '[F]ormat buffer', + }, + }, + opts = { + notify_on_error = false, + format_on_save = function(bufnr) + -- Disable "format_on_save lsp_fallback" for languages that don't + -- have a well standardized coding style. You can add additional + -- languages here or re-enable it for the disabled ones. + local disable_filetypes = { cpp = true } + local lsp_format_opt + if disable_filetypes[vim.bo[bufnr].filetype] then + lsp_format_opt = 'never' + else + lsp_format_opt = 'fallback' + end + return { + timeout_ms = 500, + lsp_format = lsp_format_opt, + } + end, + formatters_by_ft = { + lua = { 'stylua' }, + php = { 'phpcbf' }, + c = { 'clang-format' }, }, }, } diff --git a/.config/nvim/lua/custom/plugins/autopairs.lua b/.config/nvim/lua/custom/plugins/autopairs.lua index 87a7e5f..ac0220d 100644 --- a/.config/nvim/lua/custom/plugins/autopairs.lua +++ b/.config/nvim/lua/custom/plugins/autopairs.lua @@ -1,16 +1,7 @@ --- autopairs --- https://github.com/windwp/nvim-autopairs - return { 'windwp/nvim-autopairs', event = 'InsertEnter', - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, config = function() require('nvim-autopairs').setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - local cmp = require 'cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) end, } diff --git a/.config/nvim/lua/custom/plugins/avante.lua b/.config/nvim/lua/custom/plugins/avante.lua new file mode 100644 index 0000000..1eb59b0 --- /dev/null +++ b/.config/nvim/lua/custom/plugins/avante.lua @@ -0,0 +1,59 @@ +return { + 'yetone/avante.nvim', + event = 'VeryLazy', + version = false, -- Never set this value to "*"! Never! + opts = { + -- add any opts here + -- for example + provider = 'openai', + openai = { + endpoint = 'https://api.openai.com/v1', + model = 'gpt-4o', -- your desired model (or use gpt-4o, etc.) + timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models + temperature = 0, + max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models) + --reasoning_effort = "medium", -- low|medium|high, only used for reasoning models + }, + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = 'make', + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + --- The below dependencies are optional, + 'echasnovski/mini.pick', -- for file_selector provider mini.pick + 'nvim-telescope/telescope.nvim', -- for file_selector provider telescope + 'hrsh7th/nvim-cmp', -- autocompletion for avante commands and mentions + 'ibhagwan/fzf-lua', -- for file_selector provider fzf + 'nvim-tree/nvim-web-devicons', -- or echasnovski/mini.icons + 'zbirenbaum/copilot.lua', -- for providers='copilot' + { + -- support for image pasting + 'HakonHarnes/img-clip.nvim', + event = 'VeryLazy', + opts = { + -- recommended settings + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { 'markdown', 'Avante' }, + }, + ft = { 'markdown', 'Avante' }, + }, + }, +} diff --git a/.config/nvim/lua/custom/plugins/codesnap.lua b/.config/nvim/lua/custom/plugins/codesnap.lua index 7e9b4d7..eb51415 100644 --- a/.config/nvim/lua/custom/plugins/codesnap.lua +++ b/.config/nvim/lua/custom/plugins/codesnap.lua @@ -1,15 +1,14 @@ return { - { - 'mistricky/codesnap.nvim', - build = 'make', - keys = { - { 'cc', 'CodeSnap', mode = 'x', desc = 'Save selected code snapshot into clipboard' }, - { 'cs', 'CodeSnapSave', mode = 'x', desc = 'Save selected code snapshot in ~/Pictures' }, - }, - opts = { - save_path = '~/Screenshots/CodeSnap', - has_breadcrumbs = true, - watermark = '@mpriscella', - }, + 'mistricky/codesnap.nvim', + build = 'make', + keys = { + { 'cc', 'CodeSnap', mode = 'x', desc = 'Save selected code snapshot into clipboard' }, + { 'cs', 'CodeSnapSave', mode = 'x', desc = 'Save selected code snapshot in ~/Pictures' }, + }, + opts = { + save_path = '~/Screenshots/CodeSnap', + bg_padding = 25, + has_breadcrumbs = true, + watermark = '@mpriscella', }, } diff --git a/.config/nvim/lua/custom/plugins/copilot.lua b/.config/nvim/lua/custom/plugins/copilot.lua new file mode 100644 index 0000000..c4a31de --- /dev/null +++ b/.config/nvim/lua/custom/plugins/copilot.lua @@ -0,0 +1,12 @@ +return { + 'github/copilot.vim', + config = function() + vim.g.copilot_filetypes = { + ['codecompanion'] = false, + ['helm'] = false, + ['markdown'] = false, + ['terraform'] = false, + } + vim.g.copilot_settings = { selectedCompletionModel = 'gpt-4o-copilot' } + end, +} diff --git a/.config/nvim/lua/custom/plugins/debug.lua b/.config/nvim/lua/custom/plugins/debug.lua index caefdd9..69fe4c9 100644 --- a/.config/nvim/lua/custom/plugins/debug.lua +++ b/.config/nvim/lua/custom/plugins/debug.lua @@ -1,11 +1,3 @@ --- debug.lua --- --- Shows how to use the DAP plugin to debug your code. --- --- Primarily focused on configuring the debugger for Go, but can --- be extended to other languages as well. That's why it's called --- kickstart.nvim and not kitchen-sink.nvim ;) - return { -- NOTE: Yes, you can install new plugins here! 'mfussenegger/nvim-dap', diff --git a/.config/nvim/lua/custom/plugins/gitsigns.lua b/.config/nvim/lua/custom/plugins/gitsigns.lua index 0effa40..a1f2b8d 100644 --- a/.config/nvim/lua/custom/plugins/gitsigns.lua +++ b/.config/nvim/lua/custom/plugins/gitsigns.lua @@ -1,65 +1,63 @@ -- Adds git related signs to the gutter, as well as utilities for managing changes return { - { - 'lewis6991/gitsigns.nvim', - opts = { - on_attach = function(bufnr) - local gitsigns = require 'gitsigns' + 'lewis6991/gitsigns.nvim', + opts = { + on_attach = function(bufnr) + local gitsigns = require 'gitsigns' - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end - -- Navigation - map('n', ']c', function() - if vim.wo.diff then - vim.cmd.normal { ']c', bang = true } - else - gitsigns.nav_hunk 'next' - end - end, { desc = 'Jump to next git [c]hange' }) + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal { ']c', bang = true } + else + gitsigns.nav_hunk 'next' + end + end, { desc = 'Jump to next git [c]hange' }) - map('n', '[c', function() - if vim.wo.diff then - vim.cmd.normal { '[c', bang = true } - else - gitsigns.nav_hunk 'prev' - end - end, { desc = 'Jump to previous git [c]hange' }) + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal { '[c', bang = true } + else + gitsigns.nav_hunk 'prev' + end + end, { desc = 'Jump to previous git [c]hange' }) - -- Actions - -- visual mode - map('v', 'hs', function() - gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'stage git hunk' }) - map('v', 'hr', function() - gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'reset git hunk' }) - -- normal mode - map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) - map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) - map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) - map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) - map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) - map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) - map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) - map('n', 'hD', function() - gitsigns.diffthis '@' - end, { desc = 'git [D]iff against last commit' }) - -- Toggles - map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) - end, - }, - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, + -- Actions + -- visual mode + map('v', 'hs', function() + gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'stage git hunk' }) + map('v', 'hr', function() + gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'reset git hunk' }) + -- normal mode + map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) + map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) + map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) + map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) + map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) + map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) + map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) + map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' }) + map('n', 'hD', function() + gitsigns.diffthis '@' + end, { desc = 'git [D]iff against last commit' }) + -- Toggles + map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) + map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) + end, + }, + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, }, } diff --git a/.config/nvim/lua/custom/plugins/hardline.lua b/.config/nvim/lua/custom/plugins/hardline.lua new file mode 100644 index 0000000..1119b6d --- /dev/null +++ b/.config/nvim/lua/custom/plugins/hardline.lua @@ -0,0 +1,6 @@ +return { + 'm4xshen/hardtime.nvim', + lazy = false, + dependencies = { 'MunifTanjim/nui.nvim' }, + opts = {}, +} diff --git a/.config/nvim/lua/custom/plugins/helm.lua b/.config/nvim/lua/custom/plugins/helm.lua index 5b006ea..dbf16e6 100644 --- a/.config/nvim/lua/custom/plugins/helm.lua +++ b/.config/nvim/lua/custom/plugins/helm.lua @@ -1,6 +1,4 @@ return { - { - 'towolf/vim-helm', - ft = 'helm', - }, + 'towolf/vim-helm', + ft = 'helm', } diff --git a/.config/nvim/lua/custom/plugins/icons.lua b/.config/nvim/lua/custom/plugins/icons.lua index 4a95ebb..71ea12c 100644 --- a/.config/nvim/lua/custom/plugins/icons.lua +++ b/.config/nvim/lua/custom/plugins/icons.lua @@ -1,17 +1,15 @@ return { - { - 'nvim-tree/nvim-web-devicons', - config = function() - require('nvim-web-devicons').setup { - override = { - php = { - icon = '', - color = '#a074c4', - cterm_color = '140', - name = 'Php', - }, + 'nvim-tree/nvim-web-devicons', + config = function() + require('nvim-web-devicons').setup { + override = { + php = { + icon = '', + color = '#a074c4', + cterm_color = '140', + name = 'Php', }, - } - end, - }, + }, + } + end, } diff --git a/.config/nvim/lua/custom/plugins/indent_line.lua b/.config/nvim/lua/custom/plugins/indent_line.lua deleted file mode 100644 index ed7f269..0000000 --- a/.config/nvim/lua/custom/plugins/indent_line.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - { -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help ibl` - main = 'ibl', - opts = {}, - }, -} diff --git a/.config/nvim/lua/custom/plugins/lazygit.lua b/.config/nvim/lua/custom/plugins/lazygit.lua deleted file mode 100644 index 275e08b..0000000 --- a/.config/nvim/lua/custom/plugins/lazygit.lua +++ /dev/null @@ -1,22 +0,0 @@ -return { - { - 'kdheepak/lazygit.nvim', - lazy = true, - cmd = { - 'LazyGit', - 'LazyGitConfig', - 'LazyGitCurrentFile', - 'LazyGitFilter', - 'LazyGitFilterCurrentFile', - }, - -- optional for floating window border decoration - dependencies = { - 'nvim-lua/plenary.nvim', - }, - -- setting the keybinding for LazyGit with 'keys' is recommended in - -- order to load the plugin when the command is run for the first time - keys = { - { 'lg', 'LazyGit', desc = 'LazyGit' }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/lint.lua b/.config/nvim/lua/custom/plugins/lint.lua index a34c0f9..11c445d 100644 --- a/.config/nvim/lua/custom/plugins/lint.lua +++ b/.config/nvim/lua/custom/plugins/lint.lua @@ -1,54 +1,52 @@ return { - { -- Linting - 'mfussenegger/nvim-lint', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local lint = require 'lint' - lint.linters_by_ft = { - markdown = { 'markdownlint' }, - } + 'mfussenegger/nvim-lint', + event = { 'BufReadPre', 'BufNewFile' }, + config = function() + local lint = require 'lint' + lint.linters_by_ft = { + -- markdown = { 'markdownlint' }, + } - -- To allow other plugins to add linters to require('lint').linters_by_ft, - -- instead set linters_by_ft like this: - -- lint.linters_by_ft = lint.linters_by_ft or {} - -- lint.linters_by_ft['markdown'] = { 'markdownlint' } - -- - -- However, note that this will enable a set of default linters, - -- which will cause errors unless these tools are available: - -- { - -- clojure = { "clj-kondo" }, - -- dockerfile = { "hadolint" }, - -- inko = { "inko" }, - -- janet = { "janet" }, - -- json = { "jsonlint" }, - -- markdown = { "vale" }, - -- rst = { "vale" }, - -- ruby = { "ruby" }, - -- terraform = { "tflint" }, - -- text = { "vale" } - -- } - -- - -- You can disable the default linters by setting their filetypes to nil: - -- lint.linters_by_ft['clojure'] = nil - -- lint.linters_by_ft['dockerfile'] = nil - -- lint.linters_by_ft['inko'] = nil - -- lint.linters_by_ft['janet'] = nil - -- lint.linters_by_ft['json'] = nil - -- lint.linters_by_ft['markdown'] = nil - -- lint.linters_by_ft['rst'] = nil - -- lint.linters_by_ft['ruby'] = nil - -- lint.linters_by_ft['terraform'] = nil - -- lint.linters_by_ft['text'] = nil + -- To allow other plugins to add linters to require('lint').linters_by_ft, + -- instead set linters_by_ft like this: + -- lint.linters_by_ft = lint.linters_by_ft or {} + -- lint.linters_by_ft['markdown'] = { 'markdownlint' } + -- + -- However, note that this will enable a set of default linters, + -- which will cause errors unless these tools are available: + -- { + -- clojure = { "clj-kondo" }, + -- dockerfile = { "hadolint" }, + -- inko = { "inko" }, + -- janet = { "janet" }, + -- json = { "jsonlint" }, + -- markdown = { "vale" }, + -- rst = { "vale" }, + -- ruby = { "ruby" }, + -- terraform = { "tflint" }, + -- text = { "vale" } + -- } + -- + -- You can disable the default linters by setting their filetypes to nil: + -- lint.linters_by_ft['clojure'] = nil + -- lint.linters_by_ft['dockerfile'] = nil + -- lint.linters_by_ft['inko'] = nil + -- lint.linters_by_ft['janet'] = nil + -- lint.linters_by_ft['json'] = nil + -- lint.linters_by_ft['markdown'] = nil + -- lint.linters_by_ft['rst'] = nil + -- lint.linters_by_ft['ruby'] = nil + -- lint.linters_by_ft['terraform'] = nil + -- lint.linters_by_ft['text'] = nil - -- Create autocommand which carries out the actual linting - -- on the specified events. - local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) - vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { - group = lint_augroup, - callback = function() - lint.try_lint() - end, - }) - end, - }, + -- Create autocommand which carries out the actual linting + -- on the specified events. + local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + end, } diff --git a/.config/nvim/lua/custom/plugins/lsp.lua b/.config/nvim/lua/custom/plugins/lsp.lua index 0f2a20e..c4e2dab 100644 --- a/.config/nvim/lua/custom/plugins/lsp.lua +++ b/.config/nvim/lua/custom/plugins/lsp.lua @@ -1,234 +1,225 @@ return { - { - -- Main LSP Configuration - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim - { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - - -- Useful status updates for LSP. - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, - - -- Allows extra capabilities provided by nvim-cmp - 'hrsh7th/cmp-nvim-lsp', - }, - config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - -- NOTE: Remember that Lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - - -- Find references for the word under your cursor. - map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map('rn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header. - map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } - end, - }) - end - - -- The following code creates a keymap to toggle inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) - end, '[T]oggle Inlay [H]ints') - end - end, - }) - - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - local servers = { - bashls = {}, - helm_ls = { - settings = { - ['helm-ls'] = { - yamlls = { - path = 'yaml-language-server', - }, + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs and related tools to stdpath for Neovim + -- Mason must be loaded before its dependents so we need to set it up here. + { 'williamboman/mason.nvim', opts = {} }, -- NOTE: Must be loaded before dependants + 'williamboman/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + + -- Useful status updates for LSP. + { 'j-hui/fidget.nvim', opts = {} }, + + -- Allows extra capabilities provided by nvim-cmp + -- 'hrsh7th/cmp-nvim-lsp', + }, + config = function() + -- Brief aside: **What is LSP?** + -- + -- LSP is an initialism you've probably heard, but might not understand what it is. + -- + -- LSP stands for Language Server Protocol. It's a protocol that helps editors + -- and language tooling communicate in a standardized fashion. + -- + -- In general, you have a "server" which is some tool built to understand a particular + -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers + -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone + -- processes that communicate with some "client" - in this case, Neovim! + -- + -- LSP provides Neovim with features like: + -- - Go to definition + -- - Find references + -- - Autocompletion + -- - Symbol Search + -- - and more! + -- + -- Thus, Language Servers are external tools that must be installed separately from + -- Neovim. This is where `mason` and related plugins come into play. + -- + -- If you're wondering about lsp vs treesitter, you can check out the wonderfully + -- and elegantly composed help section, `:help lsp-vs-treesitter` + + vim.filetype.add { + pattern = { + ['.*/%.github[%w/]+workflows[%w/]+.*%.ya?ml'] = 'yaml.github', + ['*.mdx'] = 'markdown', + }, + } + + -- This function gets run when an LSP attaches to a particular buffer. + -- That is to say, every time a new file is opened that is associated with + -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this + -- function will be executed to configure the current buffer + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + -- NOTE: Remember that Lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + -- map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + + -- Find references for the word under your cursor. + -- map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + -- map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + -- map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + -- map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + -- map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map('rn', vim.lsp.buf.rename, '[R]e[n]ame') + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) + + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } + end, + }) + end + + -- The following code creates a keymap to toggle inlay hints in your + -- code, if the language server you are using supports them + -- + -- This may be unwanted, since they displace some of your code + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + map('th', function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) + end, '[T]oggle Inlay [H]ints') + end + end, + }) + + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP specification. + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. + local capabilities = vim.lsp.protocol.make_client_capabilities() + -- capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + bashls = {}, + -- gh_actions_ls = {}, + -- helm_ls = { + -- settings = { + -- ['helm-ls'] = { + -- yamlls = { + -- path = 'yaml-language-server', + -- }, + -- }, + -- }, + -- }, + -- @see https://luals.github.io/wiki/settings/ + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = 'Replace', }, - }, - }, - lua_ls = { - settings = { - Lua = { - completion = { - callSnippet = 'Replace', - }, - diagnostics = { - globals = { 'vim' }, - }, + diagnostics = { + globals = { 'require', 'snacks', 'vim' }, + }, + workspace = { + library = { '/Users/michaelpriscella/.local/share/nvim' }, }, }, }, - markdownlint = {}, - phpactor = {}, - phpcs = { - cmd = { '/Users/michaelpriscella/workspace/wpcomvip/wgb-zenith/vendor/bin/phpcs', '-d', '-1' }, - }, - shellcheck = {}, - terraformls = {}, - tflint = {}, - ts_ls = {}, - zls = {}, - -- yamlls = { - -- settings = { - -- validate = true, - -- -- disable the schema store - -- schemaStore = { - -- enable = false, - -- url = '', - -- }, - -- schemas = { - -- ['https://json.schemastore.org/github-workflow.json'] = '.github/workflows/*.{yml,yaml}', - -- }, - -- }, - -- }, - } - - -- Ensure the servers and tools above are installed - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu. - require('mason').setup() - - -- You can add other tools here that you want Mason to install - -- for you, so that they are available from within Neovim. - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'prettierd', - 'stylua', -- Used to format Lua code - }) - require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - handlers = { - function(server_name) - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for ts_ls) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } - end, - }, + }, + shellcheck = {}, + terraformls = {}, + -- tflint = {}, + -- ts_ls = {}, + zls = {}, + } + + -- Ensure the servers and tools above are installed + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + -- require('mason').setup() + + -- You can add other tools here that you want Mason to install + -- for you, so that they are available from within Neovim. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'prettierd', + 'stylua', -- Used to format Lua code + }) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + require('mason-lspconfig').setup { + handlers = { + function(server_name) + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for ts_ls) + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) + require('lspconfig')[server_name].setup(server) + end, + }, + } + end, } diff --git a/.config/nvim/lua/custom/plugins/lualine.lua b/.config/nvim/lua/custom/plugins/lualine.lua index 48063a1..d37ca64 100644 --- a/.config/nvim/lua/custom/plugins/lualine.lua +++ b/.config/nvim/lua/custom/plugins/lualine.lua @@ -1,12 +1,11 @@ return { - { - 'nvim-lualine/lualine.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - -- Eviline config for lualine - -- Author: shadmansaleh - -- Credit: glepnir - local lualine = require 'lualine' + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + -- Eviline config for lualine + -- Author: shadmansaleh + -- Credit: glepnir + local lualine = require 'lualine' -- Color table for highlights -- stylua: ignore @@ -24,206 +23,212 @@ return { red = '#ec5f67', } - local conditions = { - buffer_not_empty = function() - return vim.fn.empty(vim.fn.expand '%:t') ~= 1 - end, - hide_in_width = function() - return vim.fn.winwidth(0) > 80 - end, - check_git_workspace = function() - local filepath = vim.fn.expand '%:p:h' - local gitdir = vim.fn.finddir('.git', filepath .. ';') - return gitdir and #gitdir > 0 and #gitdir < #filepath - end, - } - - -- Config - local config = { - options = { - -- Disable sections and component separators - component_separators = '', - section_separators = '', - theme = { - -- We are going to use lualine_c an lualine_x as left and - -- right section. Both are highlighted by c theme . So we - -- are just setting default looks o statusline - normal = { c = { fg = colors.fg, bg = colors.bg } }, - inactive = { c = { fg = colors.fg, bg = colors.bg } }, - }, - }, - sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - -- These will be filled later - lualine_c = {}, - lualine_x = {}, + local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand '%:t') ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand '%:p:h' + local gitdir = vim.fn.finddir('.git', filepath .. ';') + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, + } + + -- Config + local config = { + options = { + -- Disable sections and component separators + component_separators = '', + section_separators = '', + theme = { + -- We are going to use lualine_c an lualine_x as left and + -- right section. Both are highlighted by c theme . So we + -- are just setting default looks o statusline + normal = { c = { fg = colors.fg, bg = colors.bg } }, + inactive = { c = { fg = colors.fg, bg = colors.bg } }, }, - inactive_sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - lualine_c = {}, - lualine_x = {}, - }, - } - - -- Inserts a component in lualine_c at left section - local function ins_left(component) - table.insert(config.sections.lualine_c, component) - end - - -- Inserts a component in lualine_x at right section - local function ins_right(component) - table.insert(config.sections.lualine_x, component) - end - - ins_left { - function() - return '▊' - end, - color = { fg = colors.blue }, -- Sets highlighting of component - padding = { left = 0, right = 1 }, -- We don't need space before this - } - - ins_left { - -- mode component - function() - return '' - end, - color = function() - -- auto change color according to neovims mode - local mode_color = { - n = colors.red, - i = colors.green, - v = colors.blue, - [''] = colors.blue, - V = colors.blue, - c = colors.magenta, - no = colors.red, - s = colors.orange, - S = colors.orange, - [''] = colors.orange, - ic = colors.yellow, - R = colors.violet, - Rv = colors.violet, - cv = colors.red, - ce = colors.red, - r = colors.cyan, - rm = colors.cyan, - ['r?'] = colors.cyan, - ['!'] = colors.red, - t = colors.red, - } - return { fg = mode_color[vim.fn.mode()] } - end, - padding = { right = 1 }, - } - - ins_left { - -- filesize component - 'filesize', - cond = conditions.buffer_not_empty, - } - - ins_left { - 'filename', - cond = conditions.buffer_not_empty, - color = { fg = colors.magenta, gui = 'bold' }, - } - - ins_left { 'location' } - - ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } } - - ins_left { - 'diagnostics', - sources = { 'nvim_diagnostic' }, - symbols = { error = ' ', warn = ' ', info = ' ' }, - diagnostics_color = { - error = { fg = colors.red }, - warn = { fg = colors.yellow }, - info = { fg = colors.cyan }, - }, - } - - -- Insert mid section. You can make any number of sections in neovim :) - -- for lualine it's any number greater then 2 - ins_left { - function() - return '%=' - end, - } - - ins_left { - -- Lsp server name . - function() - local msg = 'No Active Lsp' - local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = 0 }) - local clients = vim.lsp.get_clients() - if next(clients) == nil then - return msg - end - for _, client in ipairs(clients) do - local filetypes = client.config.filetypes - if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - return client.name - end - end + }, + sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + -- These will be filled later + lualine_c = {}, + lualine_x = {}, + }, + inactive_sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, + } + + -- Inserts a component in lualine_c at left section + local function ins_left(component) + table.insert(config.sections.lualine_c, component) + end + + -- Inserts a component in lualine_x at right section + local function ins_right(component) + table.insert(config.sections.lualine_x, component) + end + + ins_left { + function() + return '▊' + end, + color = { fg = colors.blue }, -- Sets highlighting of component + padding = { left = 0, right = 1 }, -- We don't need space before this + } + + ins_left { + -- mode component + function() + return '' + end, + color = function() + -- auto change color according to neovims mode + local mode_color = { + n = colors.red, + i = colors.green, + v = colors.blue, + [''] = colors.blue, + V = colors.blue, + c = colors.magenta, + no = colors.red, + s = colors.orange, + S = colors.orange, + [''] = colors.orange, + ic = colors.yellow, + R = colors.violet, + Rv = colors.violet, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ['r?'] = colors.cyan, + ['!'] = colors.red, + t = colors.red, + } + return { fg = mode_color[vim.fn.mode()] } + end, + padding = { right = 1 }, + } + + ins_left { + -- filesize component + 'filesize', + cond = conditions.buffer_not_empty, + } + + ins_left { + 'filename', + cond = conditions.buffer_not_empty, + color = { fg = colors.magenta, gui = 'bold' }, + path = 4, + } + + ins_left { 'location' } + + ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } } + + ins_left { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + symbols = { error = ' ', warn = ' ', info = ' ' }, + diagnostics_color = { + error = { fg = colors.red }, + warn = { fg = colors.yellow }, + info = { fg = colors.cyan }, + }, + } + + -- Insert mid section. You can make any number of sections in neovim :) + -- for lualine it's any number greater then 2 + ins_left { + function() + return '%=' + end, + } + + ins_left { + 'filetype', + colored = true, -- Displays filetype icon in color if set to true + icons_enabled = false, -- { align = 'right' }, + } + + ins_left { + -- Lsp server name . + function() + local msg = 'No Active Lsp' + local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = 0 }) + local clients = vim.lsp.get_clients() + if next(clients) == nil then return msg - end, - icon = ' LSP:', - color = { fg = '#ffffff', gui = 'bold' }, - } - - -- Add components to right sections - ins_right { - 'o:encoding', -- option component same as &encoding in viml - fmt = string.upper, -- I'm not sure why it's upper case either ;) - cond = conditions.hide_in_width, - color = { fg = colors.green, gui = 'bold' }, - } - - ins_right { - 'fileformat', - fmt = string.upper, - icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh - color = { fg = colors.green, gui = 'bold' }, - } - - ins_right { - 'branch', - icon = '', - color = { fg = colors.violet, gui = 'bold' }, - } - - ins_right { - 'diff', - -- Is it me or the symbol for modified us really weird - symbols = { added = ' ', modified = '󰝤 ', removed = ' ' }, - diff_color = { - added = { fg = colors.green }, - modified = { fg = colors.orange }, - removed = { fg = colors.red }, - }, - cond = conditions.hide_in_width, - } - - ins_right { - function() - return '▊' - end, - color = { fg = colors.blue }, - padding = { left = 1 }, - } - - -- Now don't forget to initialize lualine - lualine.setup(config) - end, - }, + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + return client.name + end + end + return msg + end, + icon = ' ', + color = { fg = '#ffffff', gui = 'bold' }, + } + + -- Add components to right sections + -- ins_right { + -- 'o:encoding', -- option component same as &encoding in viml + -- fmt = string.upper, -- I'm not sure why it's upper case either ;) + -- cond = conditions.hide_in_width, + -- color = { fg = colors.green, gui = 'bold' }, + -- } + + -- ins_right { + -- 'fileformat', + -- fmt = string.upper, + -- icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh + -- color = { fg = colors.green, gui = 'bold' }, + -- } + + ins_right { + 'branch', + icon = '', + color = { fg = colors.violet, gui = 'bold' }, + } + + ins_right { + 'diff', + -- Is it me or the symbol for modified us really weird + symbols = { added = ' ', modified = '󰝤 ', removed = ' ' }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.orange }, + removed = { fg = colors.red }, + }, + cond = conditions.hide_in_width, + } + + ins_right { + function() + return '▊' + end, + color = { fg = colors.blue }, + padding = { left = 1 }, + } + + -- Now don't forget to initialize lualine + lualine.setup(config) + end, } diff --git a/.config/nvim/lua/custom/plugins/mini.lua b/.config/nvim/lua/custom/plugins/mini.lua deleted file mode 100644 index d9f991a..0000000 --- a/.config/nvim/lua/custom/plugins/mini.lua +++ /dev/null @@ -1,40 +0,0 @@ --- Collection of various small independent plugins/modules -return { - { - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } - - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we set the section for - -- cursor location to LINE:COLUMN - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim - end, - }, -} diff --git a/.config/nvim/lua/custom/plugins/neo-tree.lua b/.config/nvim/lua/custom/plugins/neo-tree.lua deleted file mode 100644 index e217f17..0000000 --- a/.config/nvim/lua/custom/plugins/neo-tree.lua +++ /dev/null @@ -1,28 +0,0 @@ --- Neo-tree is a Neovim plugin to browse the file system --- https://github.com/nvim-neo-tree/neo-tree.nvim - -return { - 'nvim-neo-tree/neo-tree.nvim', - version = '*', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', - 'MunifTanjim/nui.nvim', - }, - cmd = 'Neotree', - keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, - }, - opts = { - window = { - position = 'right', - }, - filesystem = { - window = { - mappings = { - ['\\'] = 'close_window', - }, - }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/noice.lua b/.config/nvim/lua/custom/plugins/noice.lua index d40989f..81c9fd0 100644 --- a/.config/nvim/lua/custom/plugins/noice.lua +++ b/.config/nvim/lua/custom/plugins/noice.lua @@ -1,55 +1,52 @@ return { - { - 'folke/noice.nvim', - dependencies = { - 'MunifTanjim/nui.nvim', - 'rcarriga/nvim-notify', + 'folke/noice.nvim', + dependencies = { + 'MunifTanjim/nui.nvim', + 'rcarriga/nvim-notify', + }, + event = 'VeryLazy', + opts = { + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp + }, + }, + ---@class NoicePresets|{} + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help }, - event = 'VeryLazy', - opts = { - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ['vim.lsp.util.convert_input_to_markdown_lines'] = true, - ['vim.lsp.util.stylize_markdown'] = true, - ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp + routes = { + { + filter = { + event = 'msg_show', + kind = '', + find = 'written', }, + opts = { skip = true }, }, - -- you can enable a preset for easier configuration - presets = { - bottom_search = true, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help - }, - - routes = { - { - filter = { - event = 'msg_show', - kind = '', - find = 'written', - }, - opts = { skip = true }, - }, - { - filter = { - event = 'notify', - kind = 'info', - find = '[Neo-tree INFO]', - }, - opts = { skip = true }, + { + filter = { + event = 'notify', + kind = 'info', + find = '[Neo-tree INFO]', }, - -- Is there a way to filter by message title / source? - { - filter = { - event = 'notify', - kind = 'warn', - find = 'Config Change Detected.', - }, - opts = { skip = true }, + opts = { skip = true }, + }, + -- Is there a way to filter by message title / source? + { + filter = { + event = 'notify', + kind = 'warn', + find = 'Config Change Detected.', }, + opts = { skip = true }, }, }, }, diff --git a/.config/nvim/lua/custom/plugins/snacks.lua b/.config/nvim/lua/custom/plugins/snacks.lua new file mode 100644 index 0000000..fed168c --- /dev/null +++ b/.config/nvim/lua/custom/plugins/snacks.lua @@ -0,0 +1,102 @@ +return { + -- @see https://github.com/folke/snacks.nvim + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + ---@type snacks.dashboard.Config|{} + dashboard = { enabled = true }, + ---@type snacks.explorer.Config|{} + explorer = { + enabled = true, + replace_netrw = true, + }, + ---@type snacks.indent.Config|{} + indent = { enabled = true }, + ---@type snacks.input.Config|{} + input = { enabled = true }, + ---@type snacks.lazygit.Config|{} + lazygit = { enabled = true }, + ---@type snacks.picker.Config|{} + picker = { + enabled = true, + sources = { + ---@type snacks.picker.explorer.Config|{} + explorer = { + git_status_open = true, + hidden = true, + ignored = true, + layout = { layout = { position = 'right' } }, + }, + ---@type snacks.picker.grep.Config|{} + grep = { + hidden = true, + }, + }, + }, + ---@type snacks.notifier.Config|{} + notifier = { + enabled = true, + }, + ---@type snacks.quickfile.Config|{} + quickfile = { enabled = true }, + ---@type snacks.statuscolumn.Config|{} + statuscolumn = { enabled = true }, + ---@type snacks.words.Config|{} + words = { enabled = true }, + }, + keys = { + { + 'gd', + function() + Snacks.picker.lsp_definitions() + end, + desc = '[G]oto [D]efinition', + }, + { + 'sb', + function() + Snacks.picker.buffers() + end, + desc = '[S]earch [B]uffers', + }, + { + 'sf', + function() + Snacks.picker.files { + hidden = true, + } + end, + desc = '[S]earch [F]iles', + }, + { + 'sg', + function() + Snacks.picker.grep() + end, + desc = '[S]earch [G]rep', + }, + { + 'sh', + function() + Snacks.picker.help() + end, + desc = '[S]earch [H]elp', + }, + { + 'lg', + function() + Snacks.lazygit() + end, + desc = 'Toggle [l]azy[g]it', + }, + { + '\\', + function() + Snacks.explorer() + end, + desc = 'Toggle Explorer', + }, + }, +} diff --git a/.config/nvim/lua/custom/plugins/surround.lua b/.config/nvim/lua/custom/plugins/surround.lua new file mode 100644 index 0000000..e32286c --- /dev/null +++ b/.config/nvim/lua/custom/plugins/surround.lua @@ -0,0 +1,10 @@ +return { + 'kylechui/nvim-surround', + version = '*', -- Use for stability; omit to use `main` branch for the latest features + event = 'VeryLazy', + config = function() + require('nvim-surround').setup { + -- Configuration here, or leave empty to use defaults + } + end, +} diff --git a/.config/nvim/lua/custom/plugins/tabline.lua b/.config/nvim/lua/custom/plugins/tabline.lua deleted file mode 100644 index 0bbac0d..0000000 --- a/.config/nvim/lua/custom/plugins/tabline.lua +++ /dev/null @@ -1,59 +0,0 @@ -return { - -- { - -- 'nanozuki/tabby.nvim', - -- -- event = 'VimEnter', -- if you want lazy load, see below - -- dependencies = 'nvim-tree/nvim-web-devicons', - -- config = function() - -- local theme = { - -- fill = 'TabLineFill', - -- -- Also you can do this: fill = { fg='#f2e9de', bg='#907aa9', style='italic' } - -- head = 'TabLine', - -- current_tab = 'TabLineSel', - -- tab = 'TabLine', - -- win = 'TabLine', - -- tail = 'TabLine', - -- } - -- require('tabby').setup { - -- line = function(line) - -- return { - -- { - -- { '  ', hl = theme.head }, - -- line.sep('', theme.head, theme.fill), - -- }, - -- line.tabs().foreach(function(tab) - -- local hl = tab.is_current() and theme.current_tab or theme.tab - -- return { - -- line.sep('', hl, theme.fill), - -- tab.is_current() and '' or '󰆣', - -- tab.number(), - -- tab.name(), - -- tab.close_btn '', - -- line.sep('', hl, theme.fill), - -- hl = hl, - -- margin = ' ', - -- } - -- end), - -- line.spacer(), - -- line.wins_in_tab(line.api.get_current_tab()).foreach(function(win) - -- return { - -- line.sep('', theme.win, theme.fill), - -- win.is_current() and '' or '', - -- win.buf_name(), - -- line.sep('', theme.win, theme.fill), - -- hl = theme.win, - -- margin = ' ', - -- } - -- end), - -- { - -- line.sep('', theme.tail, theme.fill), - -- { '  ', hl = theme.tail }, - -- }, - -- hl = theme.fill, - -- } - -- end, - -- -- option = {}, -- setup modules' option, - -- } - -- -- configs... - -- end, - -- }, -} diff --git a/.config/nvim/lua/custom/plugins/telescope.lua b/.config/nvim/lua/custom/plugins/telescope.lua deleted file mode 100644 index 67e37c3..0000000 --- a/.config/nvim/lua/custom/plugins/telescope.lua +++ /dev/null @@ -1,123 +0,0 @@ --- Fuzzy Finder (files, lsp, etc) -return { - { - 'nvim-telescope/telescope.nvim', - event = 'VimEnter', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - defaults = { - vimgrep_arguments = { - 'rg', - '--color=never', - '--no-heading', - '--with-filename', - '--line-number', - '--column', - '--smart-case', - '--hidden', - '--glob', - '!{**/.git/*}', - }, - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - }, - pickers = { - find_files = { - find_command = { 'rg', '--files', '--hidden', '--glob', '!**/.git/*' }, - }, - }, - extensions = { - ['ui-select'] = { - require('telescope.themes').get_dropdown(), - }, - }, - } - - -- Enable Telescope extensions if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, { desc = '[S]earch [/] in Open Files' }) - - -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) - end, - }, -} diff --git a/.config/nvim/lua/custom/plugins/terminal.lua b/.config/nvim/lua/custom/plugins/terminal.lua index 3a2b987..79275a0 100644 --- a/.config/nvim/lua/custom/plugins/terminal.lua +++ b/.config/nvim/lua/custom/plugins/terminal.lua @@ -3,61 +3,60 @@ local size = 18 return { - { - 'akinsho/toggleterm.nvim', - version = 'v2.13.0', - opts = { - autochdir = true, - open_mapping = [[st]], - size = size, - }, - init = function() - vim.keymap.set('t', 'x', function() - -- This functionality may be good to extract into a separate plugin. - local current_size = vim.fn.winheight(0) - if current_size > size then - vim.cmd(string.format('resize %s', size)) - else - vim.cmd 'resize 100' - end - end, { desc = 'Toggle Maximized Terminal' }) - - vim.keymap.set('t', '', '', { desc = 'Move focus up' }) - - -- K9s -- Should definitely be its own plugin. - local Terminal = require('toggleterm.terminal').Terminal - local mode = require('toggleterm.terminal').mode - - local k9s = Terminal:new { - cmd = 'k9s', - hidden = true, - direction = 'float', - } - - function _k9s_toggle() - k9s:toggle() - if k9s:is_open() then - k9s:set_mode(mode.INSERT) - end + 'akinsho/toggleterm.nvim', + version = 'v2.13.0', + opts = { + autochdir = true, + open_mapping = [[st]], + size = size, + }, + init = function() + vim.keymap.set('t', 'x', function() + -- This functionality may be good to extract into a separate plugin. + local current_size = vim.fn.winheight(0) + if current_size > size then + vim.cmd(string.format('resize %s', size)) + else + vim.cmd 'resize 100' end + end, { desc = 'Toggle Maximized Terminal' }) + + vim.keymap.set('t', '', '', { desc = 'Move focus up' }) - vim.keymap.set({ 'n', 't' }, '9', 'lua _k9s_toggle()', { desc = 'Toggle K9s' }) + -- K9s -- Should definitely be its own plugin. + local Terminal = require('toggleterm.terminal').Terminal + local mode = require('toggleterm.terminal').mode - -- htop - local htop = Terminal:new { - cmd = 'htop', - hidden = true, - direction = 'float', - } + local k9s = Terminal:new { + cmd = 'k9s', + hidden = true, + direction = 'float', + } - function _htop_toggle() - htop:toggle() - if htop:is_open() then - htop:set_mode(mode.INSERT) - end + -- How to make this a local variable? Or do I create a module? M = {} and whatever. + function k9s_toggle() + k9s:toggle() + if k9s:is_open() then + k9s:set_mode(mode.INSERT) end + end - vim.keymap.set({ 'n', 't' }, 'ht', 'lua _htop_toggle()', { desc = 'Toggle Htop' }) - end, - }, + vim.keymap.set({ 'n', 't' }, '9', 'lua k9s_toggle()', { desc = 'Toggle K9s' }) + + -- htop + local htop = Terminal:new { + cmd = 'htop', + hidden = true, + direction = 'float', + } + + function htop_toggle() + htop:toggle() + if htop:is_open() then + htop:set_mode(mode.INSERT) + end + end + + vim.keymap.set({ 'n', 't' }, 'ht', 'lua htop_toggle()', { desc = 'Toggle Htop' }) + end, } diff --git a/.config/nvim/lua/custom/plugins/todo-comments.lua b/.config/nvim/lua/custom/plugins/todo-comments.lua index 8dc2cc7..ae041b0 100644 --- a/.config/nvim/lua/custom/plugins/todo-comments.lua +++ b/.config/nvim/lua/custom/plugins/todo-comments.lua @@ -1,9 +1,5 @@ --- Highlight todo, notes, etc in comments return { - { - 'folke/todo-comments.nvim', - event = 'VimEnter', - dependencies = { 'nvim-lua/plenary.nvim' }, - opts = { signs = false }, - }, + 'folke/todo-comments.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = {}, } diff --git a/.config/nvim/lua/custom/plugins/tokyonight.lua b/.config/nvim/lua/custom/plugins/tokyonight.lua index e57793c..e483e2d 100644 --- a/.config/nvim/lua/custom/plugins/tokyonight.lua +++ b/.config/nvim/lua/custom/plugins/tokyonight.lua @@ -1,16 +1,14 @@ return { - { - 'folke/tokyonight.nvim', - priority = 1000, - lazy = false, - opts = { - style = 'night', - on_colors = function(colors) - colors.border = 'orange' - end, - }, - init = function() - vim.cmd.colorscheme 'tokyonight-night' + 'folke/tokyonight.nvim', + priority = 1000, + lazy = false, + opts = { + style = 'night', + on_colors = function(colors) + colors.border = 'orange' end, }, + init = function() + vim.cmd.colorscheme 'tokyonight-night' + end, } diff --git a/.config/nvim/lua/custom/plugins/treesitter.lua b/.config/nvim/lua/custom/plugins/treesitter.lua index 7c0c9af..197b908 100644 --- a/.config/nvim/lua/custom/plugins/treesitter.lua +++ b/.config/nvim/lua/custom/plugins/treesitter.lua @@ -1,9 +1,8 @@ --- Highlight, edit, and navigate code return { { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts + main = 'nvim-treesitter.configs', -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { ensure_installed = { @@ -11,6 +10,8 @@ return { 'c', 'diff', 'html', + 'http', + 'jsonc', 'lua', 'luadoc', 'markdown', @@ -25,12 +26,7 @@ return { auto_install = true, highlight = { enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - -- additional_vim_regex_highlighting = { 'ruby' }, }, - -- indent = { enable = true, disable = { 'ruby' } }, indent = { enable = true }, }, config = function() @@ -38,11 +34,8 @@ return { vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' vim.opt.foldlevelstart = 99 end, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + }, + { + 'nvim-treesitter/nvim-treesitter-context', }, } diff --git a/.config/nvim/lua/custom/plugins/trouble.lua b/.config/nvim/lua/custom/plugins/trouble.lua index 5f42998..40087b3 100644 --- a/.config/nvim/lua/custom/plugins/trouble.lua +++ b/.config/nvim/lua/custom/plugins/trouble.lua @@ -1,39 +1,37 @@ return { - { - 'folke/trouble.nvim', - opts = {}, - cmd = 'Trouble', - keys = { - { - 'xx', - 'Trouble diagnostics toggle', - desc = 'Diagnostics (Trouble)', - }, - { - 'xX', - 'Trouble diagnostics toggle filter.buf=0', - desc = 'Buffer Diagnostics (Trouble)', - }, - { - 'cs', - 'Trouble symbols toggle focus=false', - desc = 'Symbols (Trouble)', - }, - { - 'cl', - 'Trouble lsp toggle focus=false win.position=right', - desc = 'LSP Definitions / references / ... (Trouble)', - }, - { - 'xL', - 'Trouble loclist toggle', - desc = 'Location List (Trouble)', - }, - { - 'xQ', - 'Trouble qflist toggle', - desc = 'Quickfix List (Trouble)', - }, + 'folke/trouble.nvim', + opts = {}, + cmd = 'Trouble', + keys = { + { + 'xx', + 'Trouble diagnostics toggle', + desc = 'Diagnostics (Trouble)', + }, + { + 'xX', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'Buffer Diagnostics (Trouble)', + }, + { + 'cs', + 'Trouble symbols toggle focus=false', + desc = 'Symbols (Trouble)', + }, + { + 'cl', + 'Trouble lsp toggle focus=false win.position=right', + desc = 'LSP Definitions / references / ... (Trouble)', + }, + { + 'xL', + 'Trouble loclist toggle', + desc = 'Location List (Trouble)', + }, + { + 'xQ', + 'Trouble qflist toggle', + desc = 'Quickfix List (Trouble)', }, }, } diff --git a/.config/nvim/lua/custom/plugins/vim-sleuth.lua b/.config/nvim/lua/custom/plugins/vim-sleuth.lua deleted file mode 100644 index aa8eda1..0000000 --- a/.config/nvim/lua/custom/plugins/vim-sleuth.lua +++ /dev/null @@ -1,6 +0,0 @@ --- Detect tabstop and shiftwidth automatically -return { - { - 'tpope/vim-sleuth', - }, -} diff --git a/.config/nvim/lua/custom/plugins/vs-tasks.lua b/.config/nvim/lua/custom/plugins/vs-tasks.lua deleted file mode 100644 index 4635d63..0000000 --- a/.config/nvim/lua/custom/plugins/vs-tasks.lua +++ /dev/null @@ -1,23 +0,0 @@ -return { - -- { - -- 'EthanJWright/vs-tasks.nvim', - -- dependencies = { - -- 'nvim-lua/popup.nvim', - -- 'nvim-lua/plenary.nvim', - -- 'nvim-telescope/telescope.nvim', - -- }, - -- config = function() - -- require('vstask').setup {} - -- end, - -- keys = { - -- { - -- 'ta', - -- function() - -- require('telescope').extensions.vstask.tasks() - -- end, - -- mode = 'n', - -- desc = 'VSCode [TA]sks', - -- }, - -- }, - -- }, -} diff --git a/.config/nvim/lua/custom/plugins/which-key.lua b/.config/nvim/lua/custom/plugins/which-key.lua index f765edf..7d66fd2 100644 --- a/.config/nvim/lua/custom/plugins/which-key.lua +++ b/.config/nvim/lua/custom/plugins/which-key.lua @@ -1,56 +1,56 @@ --- Useful plugin to show you pending keybinds. return { - { - 'folke/which-key.nvim', - event = 'VimEnter', -- Sets the loading event to 'VimEnter' - opts = { - icons = { - -- set icon mappings to true if you have a Nerd Font - mappings = vim.g.have_nerd_font, - -- If you are using a Nerd Font: set icons.keys to an empty table which will use the - -- default whick-key.nvim defined Nerd Font icons, otherwise define a string table - keys = vim.g.have_nerd_font and {} or { - Up = ' ', - Down = ' ', - Left = ' ', - Right = ' ', - C = ' ', - M = ' ', - D = ' ', - S = ' ', - CR = ' ', - Esc = ' ', - ScrollWheelDown = ' ', - ScrollWheelUp = ' ', - NL = ' ', - BS = ' ', - Space = ' ', - Tab = ' ', - F1 = '', - F2 = '', - F3 = '', - F4 = '', - F5 = '', - F6 = '', - F7 = '', - F8 = '', - F9 = '', - F10 = '', - F11 = '', - F12 = '', - }, - }, + 'folke/which-key.nvim', + event = 'VimEnter', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = { + ---@class wk.Opts + icons = { + mappings = vim.g.have_nerd_font, + -- If you are using a Nerd Font: set icons.keys to an empty table which will use the + -- default whick-key.nvim defined Nerd Font icons, otherwise define a string table + keys = vim.g.have_nerd_font and {}, + -- keys = vim.g.have_nerd_font and {} or { + -- Up = ' ', + -- Down = ' ', + -- Left = ' ', + -- Right = ' ', + -- C = ' ', + -- M = ' ', + -- D = ' ', + -- S = ' ', + -- CR = ' ', + -- Esc = ' ', + -- ScrollWheelDown = ' ', + -- ScrollWheelUp = ' ', + -- NL = ' ', + -- BS = ' ', + -- Space = ' ', + -- Tab = ' ', + -- F1 = '', + -- F2 = '', + -- F3 = '', + -- F4 = '', + -- F5 = '', + -- F6 = '', + -- F7 = '', + -- F8 = '', + -- F9 = '', + -- F10 = '', + -- F11 = '', + -- F12 = '', + -- }, + }, - -- Document existing key chains - spec = { - { 'c', group = '[C]ode', mode = { 'n', 'x' } }, - { 'd', group = '[D]ocument' }, - { 'r', group = '[R]ename' }, - { 's', group = '[S]earch' }, - { 'w', group = '[W]orkspace' }, - { 't', group = '[T]oggle' }, - { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, - }, + -- Document existing key chains + ---@type wk.Spec + spec = { + { 'c', group = '[C]ode', mode = { 'n', 'x' } }, + { 'd', group = '[D]ocument' }, + { 'r', group = '[R]ename' }, + { 's', group = '[S]earch' }, + { 'w', group = '[W]orkspace' }, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, }, } diff --git a/.config/nvim/lua/custom/plugins/zenmode.lua b/.config/nvim/lua/custom/plugins/zenmode.lua deleted file mode 100644 index ff4b267..0000000 --- a/.config/nvim/lua/custom/plugins/zenmode.lua +++ /dev/null @@ -1,17 +0,0 @@ --- Enable ZenMode. --- --- Commands: --- ZenMode - Toggles Zen Mode. -return { - { - 'folke/zen-mode.nvim', - opts = { - plugins = { - tmux = { enabled = true }, - }, - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }, - }, -} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6c3600e..5052775 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,9 +17,7 @@ "sumneko.lua" ], "settings": { - "Lua.diagnostics.globals": ["vim"], - "vscode-neovim.neovimInitVimPaths.linux": "/workspaces/dotfiles/.config/nvim/init.lua", - "vscode-neovim.neovimExecutablePaths.linux": "/usr/local/bin/nvim" + "Lua.diagnostics.globals": ["vim"] } } }, @@ -29,5 +27,3 @@ }, "remoteUser": "vscode" } - -/* vim: set filetype=jsonc : */ diff --git a/.dotfiles.gitconfig b/.dotfiles.gitconfig deleted file mode 100644 index 82351d5..0000000 --- a/.dotfiles.gitconfig +++ /dev/null @@ -1,52 +0,0 @@ -[user] -name = Mike Priscella -email = mpriscella@gmail.com - -[alias] -branches = branch -a -chb = checkout -b -# Show the diff between the latest commit and the current state -d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat" -# Remove branches that have already been merged with master -# a.k.a. ‘delete merged’ -dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d; git remote -v update -p" -empty = commit --allow-empty -n -m "Empty-Commit" -g = grep --break --heading --line-number -# View abbreviated SHA, description, and history graph of the latest 20 commits -l = log --pretty=oneline -n 20 --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit -remotes = remote -v -# View the current working tree status using the short format -s = status -s -su = "!git branch --set-upstream-to=origin/$1 $1" -tags = tag -l -ytd-commits = !"git rev-list --count HEAD --since=\"Jan 1 $(date +%Y)\" --before=\"Dec 31 $(date +%Y)\"" - -[color] -ui = auto - -[fetch] -prune = true - -[rebase] -autosquash = true - -[push] -default = current - -[grep] -extendRegexp = true -lineNumber = true - -[filter "lfs"] -clean = git-lfs clean %f -smudge = git-lfs smudge %f -required = true - -[pull] -rebase = false - -[core] -editor = nvim -attributesFile = ~/.gitattributes - -# vim: set filetype=gitconfig : diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/.github/workflows/test-home-manager.yml b/.github/workflows/test-home-manager.yml new file mode 100644 index 0000000..b863e3e --- /dev/null +++ b/.github/workflows/test-home-manager.yml @@ -0,0 +1,179 @@ +name: Test Home Manager Configurations + +on: + push: + branches: + - main + paths: + - '.config/home-manager/**' + pull_request: + branches: + - main + paths: + - '.config/home-manager/**' + workflow_dispatch: + +jobs: + test-configs: + name: Test ${{ matrix.host }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + include: + # Test default.nix on both platforms (auto-detects) + - host: default + os: ubuntu-latest + platform: linux + - host: default + os: macos-latest + platform: darwin + + # Test specific host configs on their target platforms + - host: work-macbook-pro + os: macos-latest + platform: darwin + - host: macbook-air + os: macos-latest + platform: darwin + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v24 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + nix_path: nixpkgs=channel:nixos-unstable + + # - name: Setup Cachix (optional - speeds up builds) + # uses: cachix/cachix-action@v12 + # if: ${{ vars.CACHIX_NAME != '' }} + # with: + # name: ${{ vars.CACHIX_NAME }} + # authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + + - name: Install Home Manager + run: | + # Use the standard installation method with proper environment setup + nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager + nix-channel --update + + # Ensure the channel is in NIX_PATH for this session + export NIX_PATH="nixpkgs=channel:nixos-unstable:home-manager=$HOME/.nix-defexpr/channels/home-manager" + + # Install home-manager using the updated NIX_PATH + nix-shell '' -A install + + - name: Set test environment variables + run: | + # Set test username but keep the real HOME directory + echo "USER=testuser" >> $GITHUB_ENV + # Keep the existing HOME directory (GitHub runner's home) + echo "REAL_HOME=$HOME" >> $GITHUB_ENV + # Set hostname for testing + echo "HOSTNAME=github-runner" >> $GITHUB_ENV + + # Set proper NIX_PATH for all subsequent steps + echo "NIX_PATH=nixpkgs=channel:nixos-unstable:home-manager=$HOME/.nix-defexpr/channels/home-manager" >> $GITHUB_ENV + + - name: Test configuration build + run: | + cd ${{ github.workspace }} + echo "Testing configuration: ${{ matrix.host }}.nix" + + # Build the configuration using home-manager + home-manager build \ + --file .config/home-manager/hosts/${{ matrix.host }}.nix \ + --no-out-link \ + --show-trace + + - name: Test configuration evaluation + run: | + cd ${{ github.workspace }} + echo "Evaluating configuration for detailed analysis..." + + # Test that the configuration evaluates without errors + nix-instantiate \ + --eval \ + --strict \ + --show-trace \ + --expr " + let + pkgs = import {}; + home-manager = import {}; + config = import ./.config/home-manager/hosts/${{ matrix.host }}.nix { + inherit pkgs; + config = {}; + lib = pkgs.lib; + }; + in + config.home.stateVersion or \"unknown\" + " + + - name: Check for common issues + run: | + cd ${{ github.workspace }} + echo "Checking for common configuration issues..." + + # Check if all imported files exist + echo "Checking imports..." + if ! find .config/home-manager -name "*.nix" -exec nix-instantiate --parse {} \; > /dev/null; then + echo "❌ Syntax errors found in nix files" + exit 1 + fi + + # Check for missing files referenced in configs + echo "Checking file references..." + if grep -r "source.*\.\." .config/home-manager/hosts/${{ matrix.host }}.nix; then + echo "Found relative path references - ensuring they exist..." + # This is just informational, actual test is in the build step + fi + + echo "✅ Basic checks passed" + + - name: Generate build artifacts info + if: always() + run: | + cd ${{ github.workspace }} + echo "## Configuration Test Results" >> $GITHUB_STEP_SUMMARY + echo "- **Host**: ${{ matrix.host }}" >> $GITHUB_STEP_SUMMARY + echo "- **Platform**: ${{ matrix.platform }}" >> $GITHUB_STEP_SUMMARY + echo "- **OS**: ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY + echo "- **Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY + + if [[ "${{ job.status }}" == "success" ]]; then + echo "✅ Configuration builds successfully" >> $GITHUB_STEP_SUMMARY + else + echo "❌ Configuration failed to build" >> $GITHUB_STEP_SUMMARY + fi + + test-matrix-summary: + name: Test Results Summary + runs-on: ubuntu-latest + needs: test-configs + if: always() + + steps: + - name: Generate summary + run: | + echo "## Home Manager Configuration Test Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + if [[ "${{ needs.test-configs.result }}" == "success" ]]; then + echo "🎉 **All configurations passed!**" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "All host configurations build successfully and are ready for deployment." >> $GITHUB_STEP_SUMMARY + else + echo "⚠️ **Some configurations failed**" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Check the individual job results above for details." >> $GITHUB_STEP_SUMMARY + fi + + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Tested Configurations:" >> $GITHUB_STEP_SUMMARY + echo "- default.nix (Linux & macOS)" >> $GITHUB_STEP_SUMMARY + echo "- work-macbook-pro.nix (macOS)" >> $GITHUB_STEP_SUMMARY + echo "- macbook-air.nix (macOS)" >> $GITHUB_STEP_SUMMARY diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/.wezterm.lua b/.wezterm.lua deleted file mode 100644 index 6801c7b..0000000 --- a/.wezterm.lua +++ /dev/null @@ -1,43 +0,0 @@ --- https://wezfurlong.org/wezterm/config/files.html - --- Pull in the wezterm API -local wezterm = require("wezterm") - --- This will hold the configuration. -local config = wezterm.config_builder() - -config.font = wezterm.font_with_fallback({ "JetBrains Mono", "SpaceMono Nerd Font" }) -config.font_size = 11 -config.line_height = 1.2 --- config.color_scheme = "GitHub Dark" -config.color_scheme = "tokyonight" - -config.max_fps = 120 -config.hide_tab_bar_if_only_one_tab = true - --- neovim zen mode. -wezterm.on("user-var-changed", function(window, pane, name, value) - local overrides = window:get_config_overrides() or {} - if name == "ZEN_MODE" then - local incremental = value:find("+") - local number_value = tonumber(value) - if incremental ~= nil then - while number_value > 0 do - window:perform_action(wezterm.action.IncreaseFontSize, pane) - number_value = number_value - 1 - end - overrides.enable_tab_bar = false - elseif number_value < 0 then - window:perform_action(wezterm.action.ResetFontSize, pane) - overrides.font_size = nil - overrides.enable_tab_bar = true - else - overrides.font_size = number_value - overrides.enable_tab_bar = false - end - end - window:set_config_overrides(overrides) -end) - --- and finally, return the configuration to wezterm -return config diff --git a/.zshrc b/.zshrc index e64a281..7db9fac 100644 --- a/.zshrc +++ b/.zshrc @@ -202,3 +202,14 @@ if [[ "$TERM_PROGRAM" != "tmux" ]]; then fi export RPROMPT=$gen_prompt + +if [ -d "$HOME/.atuin" ]; then + . "$HOME/.atuin/bin/env" + eval "$(atuin init zsh)" +fi + +if [ -f "$HOME/.nvm/nvm.sh" ]; then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +fi diff --git a/dotfiles.sh b/dotfiles.sh deleted file mode 100755 index 8ba8696..0000000 --- a/dotfiles.sh +++ /dev/null @@ -1,261 +0,0 @@ -#!/bin/bash - -usage() { - echo "Manages mpriscella/dotfiles." - echo "" - echo "Usage:" - echo " ./dotfiles.sh [command]" - echo "" - echo "Available Commands:" - echo " clean Removes any backup files generated from the install command." - echo " install Installs dotfiles and predefined packages." - echo "" -} - -# Bring in ID and ID_LIKE, if the file exists. -if [ -f /etc/os-release ]; then - # shellcheck source=/dev/null - source /etc/os-release -fi - -# Normalize the OS ID. -if [ "${ID}" = "debian" ] || [ "${ID_LIKE}" = "debian" ]; then - ADJUSTED_ID="debian" -elif [ "$(uname -s)" = "Darwin" ]; then - ADJUSTED_ID="darwin" -fi - -# Install Homebrew on MacOS. -if [ "${ADJUSTED_ID}" = "darwin" ]; then - if ! type brew >/dev/null 2>&1; then - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - fi -fi - -# Determine what the package manager install command for the OS is. -if type apt-get >/dev/null 2>&1; then - INSTALL_CMD=apt-get -elif type brew >/dev/null 2>&1; then - INSTALL_CMD=brew -else - echo "(Error) Unable to find a supported package manager." - exit 1 -fi - -####################################### -# Update package manager. -# Globals: -# INSTALL_CMD -# Arguments: -# None -####################################### -pkg_mgr_update() { - if [ "${INSTALL_CMD}" = "apt-get" ]; then - if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then - echo "Running apt-get update..." - sudo "${INSTALL_CMD}" update -y - fi - elif [ "${INSTALL_CMD}" = "brew" ]; then - echo "Running brew update ..." - "${INSTALL_CMD}" update - fi -} - -####################################### -# Ensure packages are installed. -# Globals: -# INSTALL_CMD -# Arguments: -# List of packages to install. -####################################### -check_packages() { - if [ "${INSTALL_CMD}" = "apt-get" ]; then - if ! dpkg -s "$@" >/dev/null 2>&1; then - pkg_mgr_update - sudo "${INSTALL_CMD}" -y install --no-install-recommends "$@" - fi - elif [ "${INSTALL_CMD}" = "brew" ]; then - pkg_mgr_update - "${INSTALL_CMD}" install "$@" - else - echo "Linux distro ${ID} not supported." - exit 1 - fi -} - -####################################### -# Clean up package manager cache files. -# Globals: -# ADJUSTED_ID -# Arguments: -# None -####################################### -clean_up() { - case "${ADJUSTED_ID}" in - debian) - rm -rf /var/lib/apt/lists/* - ;; - darwin) - brew cleanup - ;; - esac -} - -####################################### -# Install package dependencies. -# Globals: -# ADJUSTED_ID -# Arguments: -# None -####################################### -install_dependencies() { - if [ "${ADJUSTED_ID}" = "debian" ]; then - check_packages ack curl exuberant-ctags fd-find fzf gawk git jq locales python3 \ - ripgrep tar tmux vim virt-what zsh - npm install -g tree-sitter-cli @devcontainers/cli - curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh - curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - - check_packages nodejs - install_neovim >/dev/null 2>&1 - LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') - curl -Lo /tmp/lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" - tar xf /tmp/lazygit.tar.gz lazygit - sudo install lazygit /usr/local/bin - rm lazygit - elif [ "${ADJUSTED_ID}" = "darwin" ]; then - brew tap homebrew/cask-fonts - brew install --casks dbeaver-community devtoys font-space-mono-nerd-font wezterm - check_packages ack act atuin derailed/k9s/k9s dive fzf gh gnupg hadolint helm \ - jordanbaird-ice jq k6 kind jesseduffield/lazygit/lazygit neovim node \ - ripgrep shellcheck sslscan step terraform-ls tmux tree-sitter yq \ - yt-dlp - npm install -g @devcontainers/cli - fi - clean_up -} - -####################################### -# Installs neovim from source. -# Necessary until this issue gets resolved: https://github.com/neovim/neovim/issues/15143 -# Globals: -# HOME -# PWD -# Arguments: -# None -####################################### -install_neovim() { - old_dir="$PWD" - cd "$HOME" || exit - git clone --depth 1 --branch stable https://github.com/neovim/neovim.git - cd neovim || exit - check_packages ninja-build gettext cmake unzip - make CMAKE_BUILD_TYPE=RelWithDebInfo - sudo make install - cd "$old_dir" || exit -} - -spinner_pid= - -####################################### -# Starts a progress spinner. -# Globals: -# spinner_pid -# Arguments: -# A string to precede the spinner. -####################################### -function start_spinner { - set +m - echo -n "$1 " - { while :; do for X in ". " ".. " "..." " .." " ." " "; do - echo -en "\b\b\b$X" - sleep 0.1 - done; done & } 2>/dev/null - spinner_pid=$! -} - -####################################### -# Stops a running progress spinner, identified by spinner_pid. -# Globals: -# spinner_pid -# Arguments: -# None -####################################### -function stop_spinner { - { kill -9 "$spinner_pid" && wait; } 2>/dev/null - set -m - echo -en "\033[2K\r" -} - -trap stop_spinner EXIT - -####################################### -# Installs tmux plugin manager. -# Globals: -# HOME -# Arguments: -# None -####################################### -config_tmux() { - if [ ! -d "$HOME"/.tmux/plugins/tpm ]; then - TPM_VERSION=v3.1.0 - git clone --depth 1 --branch "${TPM_VERSION}" https://github.com/tmux-plugins/tpm "$HOME"/.tmux/plugins/tpm - fi - "$HOME"/.tmux/plugins/tpm/bin/install_plugins -} - -files=".ackrc .config/ghostty .config/nvim .dotfiles.gitconfig .gitattributes .kshell.sh .tmux.conf .vimrc .zshrc" - -####################################### -# Symlinks the dotfiles to their correct destination in the home directory. -# Globals: -# files -# HOME -# Arguments: -# None -####################################### -install_dotfiles() { - for i in $files; do - mkdir -p "$(dirname "$HOME"/"$i")" - if [ "$(readlink "$HOME"/"$i")" != "$PWD"/"$i" ]; then - rm "$HOME"/"$i" - elif [ ! -L "$HOME"/"$i" ] && [ -f "$HOME"/"$i" ]; then - mv "$HOME"/"$i" "$HOME"/"$i".bkup - fi - - ln -s "$PWD"/"$i" "$HOME"/"$i" - done - - if type nvim >/dev/null 2>&1; then - nvim --headless "+Lazy! install" +qa - fi - - if type tmux >/dev/null 2>&1; then - config_tmux - fi - - git config --global include.path "$HOME"/.dotfiles.gitconfig -} - -case "$1" in -"install") - start_spinner "Installing dependencies" - install_dependencies >/dev/null 2>&1 - stop_spinner - echo "✅ Dependencies installed." - - start_spinner "Installing dotfiles" - install_dotfiles >/dev/null 2>&1 - stop_spinner - echo "✅ Dotfiles installed." - ;; -"clean") - for i in $files; do - if test -f "$HOME"/"$i".bkup; then - rm "$HOME"/"$i".bkup - fi - done - ;; -*) - usage - ;; -esac diff --git a/install.sh b/install.sh index 31a7e37..1181cd5 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,429 @@ #!/bin/bash -if [ -z "$DEBUG_DOTFILES" ]; then - ./dotfiles.sh install -fi +set -e # Exit on any error + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Helper functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Detect operating system +detect_os() { + case "$(uname -s)" in + Darwin*) + OS="macos" + log_info "Running on macOS" + ;; + Linux*) + OS="linux" + log_info "Running on Linux" + # Detect Linux distribution + if [[ -f /etc/os-release ]]; then + # shellcheck source=/dev/null + source /etc/os-release + DISTRO="$ID" + log_info "Detected Linux distribution: $PRETTY_NAME" + else + DISTRO="unknown" + log_warning "Could not detect Linux distribution" + fi + ;; + *) + log_error "Unsupported operating system: $(uname -s)" + log_error "This script supports macOS and Linux only" + exit 1 + ;; + esac +} + +# Check prerequisites based on OS +check_prerequisites() { + case "$OS" in + linux) + # Check if curl is available + if ! command -v curl >/dev/null 2>&1; then + log_error "curl is required but not installed" + log_info "Please install curl first:" + case "$DISTRO" in + ubuntu | debian) + log_info " sudo apt update && sudo apt install curl" + ;; + fedora | rhel | centos) + log_info " sudo dnf install curl" + ;; + arch | manjaro) + log_info " sudo pacman -S curl" + ;; + *) + log_info " Please install curl using your distribution's package manager" + ;; + esac + exit 1 + fi + + # Check if systemd is available for multi-user install + if command -v systemctl >/dev/null 2>&1; then + log_info "systemd detected - will use multi-user installation" + else + log_warning "systemd not detected - will use single-user installation" + fi + ;; + macos) + # macOS specific checks + if ! command -v curl >/dev/null 2>&1; then + log_error "curl is required but not installed" + exit 1 + fi + ;; + esac +} + +# Install Nix if not already installed +install_nix() { + if command -v nix >/dev/null 2>&1; then + log_success "Nix is already installed: $(nix --version)" + + # Even if Nix is installed, ensure it's sourced in current session + if [[ -z "${NIX_PATH:-}" ]]; then + log_info "Sourcing Nix environment for current session..." + # Try to source Nix profile for current session + if [[ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]]; then + # shellcheck source=/dev/null + source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' + log_info "Sourced Nix daemon profile" + elif [[ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]]; then + # shellcheck source=/dev/null + source "$HOME/.nix-profile/etc/profile.d/nix.sh" + log_info "Sourced Nix single-user profile" + fi + else + log_info "Nix environment already sourced (NIX_PATH is set)" + fi + + log_success "Nix is ready to use" + return 0 + fi + + log_info "Installing Nix..." + + case "$OS" in + macos) + # Use the official Nix installer for macOS with daemon support + install_args="--daemon" + ;; + linux) + # Check if we should use multi-user or single-user install + if command -v systemctl >/dev/null 2>&1 && [[ "$EUID" -ne 0 ]]; then + log_info "Using multi-user installation (recommended)" + install_args="--daemon" + else + log_info "Using single-user installation" + install_args="" + fi + ;; + esac + + # Download and run the installer + if curl -L https://nixos.org/nix/install | sh -s -- "$install_args"; then + log_success "Nix installation completed" + + # Source nix profile to make nix available in current session + case "$OS" in + macos | linux) + # Try daemon profile first (multi-user install) + if [[ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]]; then + # shellcheck source=/dev/null + source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' + log_info "Sourced Nix daemon profile" + # Fallback to single-user profile + elif [[ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]]; then + # shellcheck source=/dev/null + source "$HOME/.nix-profile/etc/profile.d/nix.sh" + log_info "Sourced Nix single-user profile" + else + log_warning "Could not find Nix profile to source" + fi + ;; + esac + + # Verify installation + if command -v nix >/dev/null 2>&1; then + log_success "Nix is now available: $(nix --version)" + else + log_warning "Nix installed but not available in current session." + log_info "You may need to restart your terminal or manually source the Nix profile." + # Don't exit here - continue with the script + fi + else + log_error "Failed to install Nix" + log_info "You can try installing Nix manually from: https://nixos.org/download.html" + exit 1 + fi +} + +# Install home-manager +install_home_manager() { + # Check if home-manager is already installed + if command -v home-manager >/dev/null 2>&1; then + log_success "home-manager is already installed: $(home-manager --version)" + return 0 + fi + + # Ensure nix commands are available + if ! command -v nix-channel >/dev/null 2>&1; then + log_error "nix-channel command not found. Nix may not be properly installed or sourced." + log_info "Try restarting your terminal or manually sourcing Nix profile." + return 1 + fi + + log_info "Installing home-manager..." + + # Check if home-manager channel already exists + if nix-channel --list | grep -q "home-manager"; then + log_info "home-manager channel already exists" + else + # Add home-manager channel + if nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager; then + log_success "Added home-manager channel" + else + log_error "Failed to add home-manager channel" + log_info "You can try adding it manually: nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager" + return 1 + fi + fi + + # Update channels + log_info "Updating Nix channels..." + if nix-channel --update; then + log_success "Updated Nix channels" + else + log_warning "Failed to update Nix channels, but continuing..." + log_info "You may need to run 'nix-channel --update' manually later" + fi + + # Install home-manager + log_info "Installing home-manager package..." + if nix-shell '' -A install; then + log_success "home-manager installation completed" + + # Verify installation + if command -v home-manager >/dev/null 2>&1; then + log_success "home-manager is now available: $(home-manager --version)" + else + log_warning "home-manager installed but not available in current session." + log_info "You may need to restart your terminal or source your shell profile." + # Don't exit here - continue with the script + fi + else + log_error "Failed to install home-manager" + log_info "You can try installing it manually:" + echo " 1. nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager" + echo " 2. nix-channel --update" + echo " 3. nix-shell '' -A install" + return 1 + fi +} + +# Setup initial home-manager configuration +setup_home_manager() { + local config_dir="$HOME/.config/home-manager" + local dotfiles_config_dir + dotfiles_config_dir="$(pwd)/.config/home-manager" + + if [[ -d "$config_dir" ]]; then + log_info "home-manager config directory already exists" + else + log_info "Creating home-manager config directory..." + mkdir -p "$config_dir" + fi + + # Check if we have a dotfiles home-manager config + if [[ -d "$dotfiles_config_dir" ]]; then + log_info "Dotfiles home-manager configuration found" + + # Suggest appropriate configuration file based on OS + case "$OS" in + macos) + log_info "You can now run: home-manager switch --file .config/home-manager/hosts/work-macbook-pro.nix" + ;; + linux) + log_info "You can now run: home-manager switch --file .config/home-manager/hosts/linux-machine.nix" + log_warning "Note: You may need to create a Linux-specific configuration file" + ;; + esac + else + log_warning "No home-manager configuration found in dotfiles" + log_info "You may need to create a home-manager configuration" + fi +} + +# Test and apply home-manager configuration +test_and_apply_config() { + local config_file=".config/home-manager/hosts/default.nix" + local dotfiles_config_dir + dotfiles_config_dir="$(pwd)/.config/home-manager" + + # Check if we're in the dotfiles directory + if [[ ! -d "$dotfiles_config_dir" ]]; then + log_error "Not in dotfiles directory or home-manager config not found" + log_info "Please run this script from your dotfiles directory" + return 1 + fi + + # Check if default.nix exists + if [[ ! -f "$config_file" ]]; then + log_warning "Default configuration file not found: $config_file" + log_info "Skipping automatic configuration application" + return 1 + fi + + log_info "Testing home-manager configuration: $config_file" + + # Test the configuration by building it + if home-manager build --file "$config_file" --no-out-link; then + log_success "Configuration test passed!" + + # Ask user if they want to apply it + echo + read -p "Do you want to apply this configuration now? (y/N): " -n 1 -r + echo + + if [[ $REPLY =~ ^[Yy]$ ]]; then + log_info "Applying home-manager configuration..." + + if home-manager switch --file "$config_file"; then + log_success "Home-manager configuration applied successfully!" + + # Show what was applied + log_info "Configuration details:" + echo " - User: $(whoami)" + echo " - Config: $config_file" + echo " - Home: $HOME" + echo " - Generation: $(home-manager generations | head -1 | awk '{print $5}' || echo 'Unknown')" + + return 0 + else + log_error "Failed to apply home-manager configuration" + log_info "You can try manually with: home-manager switch --file $config_file" + return 1 + fi + else + log_info "Configuration not applied. You can apply it later with:" + echo " home-manager switch --file $config_file" + return 0 + fi + else + log_error "Configuration test failed!" + log_info "Please check your configuration file: $config_file" + log_info "Common issues:" + echo " - Check syntax errors in nix files" + echo " - Verify all imports exist" + echo " - Ensure username/home directory are correct" + echo " - Try: home-manager build --file $config_file --show-trace" + return 1 + fi +} + +# Main installation process +main() { + log_info "Starting dotfiles installation..." + + # Detect operating system + detect_os + + # Check prerequisites + check_prerequisites + + # Install Nix + log_info "Checking Nix installation..." + install_nix + nix_install_result=$? + + if [[ $nix_install_result -ne 0 ]]; then + log_error "Nix installation failed. Cannot continue." + exit 1 + fi + + # Install home-manager + log_info "Checking home-manager installation..." + install_home_manager + hm_install_result=$? + + if [[ $hm_install_result -ne 0 ]]; then + log_warning "home-manager installation had issues, but continuing..." + log_info "You may need to install home-manager manually later." + fi + + # Setup home-manager + setup_home_manager + + # Test and apply configuration (only if home-manager is available) + if command -v home-manager >/dev/null 2>&1; then + log_info "Testing and applying home-manager configuration..." + if test_and_apply_config; then + log_success "Installation and configuration completed!" + echo + log_info "Your dotfiles are now active!" + echo + log_info "Useful commands:" + echo " - Update packages: nix-channel --update && home-manager switch" + echo " - Rebuild config: home-manager switch --file .config/home-manager/hosts/default.nix" + echo " - List generations: home-manager generations" + echo " - Rollback: home-manager switch --switch-generation " + echo " - Check system: nix-info -m" + else + log_warning "Configuration test/apply step had issues" + log_success "Base installation completed!" + echo + log_info "Manual next steps:" + + case "$OS" in + macos | linux) + echo " 1. Navigate to your dotfiles directory" + echo " 2. Test config: home-manager build --file .config/home-manager/hosts/default.nix --no-out-link" + echo " 3. Apply config: home-manager switch --file .config/home-manager/hosts/default.nix" + ;; + esac + + echo + log_info "Useful commands:" + echo " - Update packages: nix-channel --update && home-manager switch" + echo " - List generations: home-manager generations" + echo " - Rollback: home-manager switch --switch-generation " + echo " - Check system: nix-info -m" + fi + else + log_warning "home-manager not available. Skipping configuration application." + log_success "Nix installation completed!" + echo + log_info "Next steps:" + echo " 1. Install home-manager manually:" + echo " nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager" + echo " nix-channel --update" + echo " nix-shell '' -A install" + echo " 2. Apply your configuration:" + echo " home-manager switch --file .config/home-manager/hosts/default.nix" + fi +} + +# Run main function +main "$@" diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..9d3fd10 --- /dev/null +++ b/shell.nix @@ -0,0 +1,14 @@ +let + pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/c16a6c8efedb65e10d565633e3f45f73bbbdf8ab.tar.gz") { + config = { + allowUnfree = true; + }; + overlays = []; + }; +in + pkgs.mkShellNoCC { + buildInputs = [ + pkgs.gh + pkgs.shellcheck + ]; + } diff --git a/.tmux.conf b/tmux.conf similarity index 100% rename from .tmux.conf rename to tmux.conf