diff --git a/.envrc b/.envrc index a8d08c3..e3c2943 100644 --- a/.envrc +++ b/.envrc @@ -1,8 +1,7 @@ -use flake .nix +export DIRENV_WARN_TIMEOUT=20s -if on_git_branch; then - echo - git status --short --branch - echo - git fetch -fi +eval "$(devenv direnvrc)" + +# The use_devenv function supports passing flags to the devenv command +# For example: use devenv --impure --option services.postgres.enable:bool true +use devenv diff --git a/.gitignore b/.gitignore index 3357b94..47f7f20 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,13 @@ # Ignore build outputs from performing a nix-build or `nix build` command result result-* + +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/.nix/flake.lock b/.nix/flake.lock deleted file mode 100644 index 2ac74d2..0000000 --- a/.nix/flake.lock +++ /dev/null @@ -1,25 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1729665710, - "narHash": "sha256-AlcmCXJZPIlO5dmFzV3V2XF6x/OpNWUV8Y/FMPGd8Z4=", - "rev": "2768c7d042a37de65bb1b5b3268fc987e534c49d", - "revCount": 696158, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.696158%2Brev-2768c7d042a37de65bb1b5b3268fc987e534c49d/0192bd28-d6c0-735c-ab86-8ab9d12f7d62/source.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/.nix/flake.nix b/.nix/flake.nix deleted file mode 100644 index 0cbe327..0000000 --- a/.nix/flake.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ - description = "A flake editing flake"; - - inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; - - outputs = { nixpkgs, ... }: - let - supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; - forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { - pkgs = import nixpkgs { inherit system; }; - }); - in - { - devShells = forEachSupportedSystem ({ pkgs }: { - default = pkgs.mkShell.override - { - # Override stdenv in order to change compiler: - # stdenv = pkgs.clangStdenv; - } - { - packages = with pkgs; [ - pre-commit - commitizen - ]; - - shellHook = '' - pre-commit install --allow-missing-config --hook-type pre-commit --hook-type commit-msg - ''; - }; - }); - }; -} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 87f991d..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# See https://pre-commit.com for more information -# See https://pre-commit.com/hooks.html for more hooks -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - - id: detect-private-key - - id: mixed-line-ending - - - repo: https://github.com/commitizen-tools/commitizen - rev: v3.27.0 - hooks: - - id: commitizen - stages: [commit-msg] - - - repo: local - hooks: - - id: home-manager-check - name: Home Manager Config Check - entry: home-manager switch --dry-run - language: system - pass_filenames: false - exclude: ^docs/ diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..05d4282 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,103 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1747116279, + "owner": "cachix", + "repo": "devenv", + "rev": "79e442e0b24f0f45db0d853d88d3d27dff422b3b", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1746537231, + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "fa466640195d38ec97cf0493d6d6882bc4d14969", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1746807397, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "c5208b594838ea8e6cca5997fbf784b7cca1ca90", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": [ + "git-hooks" + ] + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..7883385 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,27 @@ +{pkgs, ...}: { + packages = with pkgs; [ + watchexec + ]; + + git-hooks = { + hooks = { + alejandra.enable = true; + check-case-conflicts.enable = true; + check-merge-conflicts.enable = true; + commitizen.enable = true; + deadnix.enable = true; + detect-private-keys.enable = true; + end-of-file-fixer.enable = true; + markdownlint.enable = true; + mdformat.enable = true; + }; + + hooks.home-manager-check = { + enable = true; + name = "Home Manager Config Check"; + entry = "home-manager switch --dry-run"; + pass_filenames = false; + excludes = ["^docs/"]; + }; + }; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..116a2ad --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + +# If you're using non-OSS software, you can set allowUnfree to true. +# allowUnfree: true + +# If you're willing to use a package that's vulnerable +# permittedInsecurePackages: +# - "openssl-1.1.1w" + +# If you have more than one devenv you can merge them +#imports: +# - ./backend diff --git a/flake.lock b/flake.lock index b3174e7..e42e83e 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1734093295, - "narHash": "sha256-hSwgGpcZtdDsk1dnzA0xj5cNaHgN9A99hRF/mxMtwS4=", + "lastModified": 1750730235, + "narHash": "sha256-rZErlxiV7ssvI8t7sPrKU+fRigNc2KvoKZG3gtUtK50=", "owner": "nix-community", "repo": "home-manager", - "rev": "66c5d8b62818ec4c1edb3e941f55ef78df8141a8", + "rev": "d07e9cceb4994ed64a22b9b36f8b76923e87ac38", "type": "github" }, "original": { @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1734119587, - "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", + "lastModified": 1750506804, + "narHash": "sha256-VLFNc4egNjovYVxDGyBYTrvVCgDYgENp5bVi9fPTDYc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", + "rev": "4206c4cb56751df534751b058295ea61357bbbaa", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0fe7fb7..8737aba 100644 --- a/flake.nix +++ b/flake.nix @@ -59,27 +59,6 @@ vimwikiPath = "~/vimwiki"; }; }; - "ubuntu" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - modules = [ - ./shell - ./git - ./gpg - ./neovim - ./horsch.nix - ]; - - extraSpecialArgs = { - user = "ubuntu"; - userName = "Michael Mandl"; - userEmail = "michael.mandl@horsch.com"; - gpgSigningKey = "088ED38F036C7AF2"; - gpgSSHKeys = [ "AEB2BF3FF9CF9529E9A3C6F1A202D21686FF9278" ]; - theme = "dark"; - vimwikiPath = "~/vimwiki"; - }; - }; }; }; } diff --git a/git/default.nix b/git/default.nix index 183cddd..2a63730 100644 --- a/git/default.nix +++ b/git/default.nix @@ -1,9 +1,17 @@ -{ pkgs, userName, userEmail, gpgSigningKey, ... }: - { + pkgs, + userName, + userEmail, + gpgSigningKey, + ... +}: { programs = { less.enable = true; git-credential-oauth.enable = true; + git-worktree-switcher = { + enable = true; + enableZshIntegration = true; + }; git = { enable = true; @@ -16,9 +24,24 @@ signByDefault = true; }; - difftastic = { + delta = { enable = true; + options = { + dark = true; + theme = "Solarized (dark)"; + side-by-side = true; + line-numbers = true; + true-color = "always"; + plus-style = "syntax \"#003800\""; + minus-style = "syntax \"#380000\""; + }; + }; + + difftastic = { + enable = false; background = "light"; + display = "side-by-side-show-both"; + enableAsDifftool = true; }; lfs = { @@ -26,14 +49,34 @@ }; extraConfig = { - core.editor = "nvim"; - core.pager = "less -FX"; + branch.sort = "-committerdate"; - diff.ignoreSubmodules = "none"; + core = { + editor = "nvim"; + fsmonitor = true; + untrackedCache = true; + }; - fetch.parallel = 8; - fetch.writeCommitGraph = true; - fetch.recurseSubmodules = true; + column.ui = "auto"; + + commit.verbose = true; + + diff = { + algorithm = "histogram"; + colorMoved = "plain"; + ignoreSubmodules = "none"; + mnemonicPrefix = true; + renames = true; + }; + + fetch = { + all = true; + parallel = 8; + prune = true; + pruneTags = true; + recurseSubmodules = true; + writeCommitGraph = true; + }; format.pretty = "format:%C(yellow)%h %Cblue%>(12)%ad %C(red)%G? %Cgreen%<(7,trunc)%aN%Cred%d %Creset%s"; @@ -41,28 +84,49 @@ log.date = "relative"; - merge.ff = false; - merge.tool = "nvim"; + merge = { + conflictstyle = "zdiff3"; + ff = false; + tool = "nvim"; + }; - mergetool.nvim.cmd = "nvim -f -c \"Gdiffsplit!\" \"$MERGED\""; + mergetool.nvim.cmd = "nvim -d $BASE $LOCAL $REMOTE $MERGED -c 'DiffviewOpen'"; + mergetool.nvim.trustExitCode = false; mergetool.prompt = false; pager.difftool = true; pull.rebase = true; - push.recurseSubmodules = "on-demand"; + push = { + autoSetupRemote = true; + default = "simple"; + followTags = true; + recurseSubmodules = "on-demand"; + }; - rebase.autostash = true; + rebase = { + qutoSquash = true; + autoStash = true; + updateRefs = true; + }; - rerere.enabled = true; + rerere = { + autoupdate = true; + enabled = true; + }; status.submoduleSummary = true; submodule.fetchJobs = 8; submodule.recurse = true; - worktree.guessRemote = true; + tag.sort = "version:refname"; + + worktree = { + guessRemote = true; + useRelativePaths = true; + }; }; aliases = { @@ -101,26 +165,5 @@ git -C ''${dir}/.base checkout --detach HEAD git -C ''${dir}/.base worktree add ../''${branch} '') - - (writeShellScriptBin "git-make-relative" '' - - gitfile=''${1} - - if [[ -z ''${gitfile} ]]; then - gitfile=".git" - fi - - if [[ ! -f ''${gitfile} ]]; then - echo "file ''${gitfile} does not exist" - exit 1 - fi - - gitdir=$(grep "gitdir:" ''${gitfile} | cut -d: -f2 | xargs) - rel_gitdir=$(realpath -s --relative-to=. ''${gitdir}) - - echo "relative path: ''${rel_gitdir}" - - sed -i -e "s,gitdir:.*,gitdir: ''${rel_gitdir}," ''${gitfile} - '') ]; } diff --git a/gpg/default.nix b/gpg/default.nix index 4a3069c..00d7857 100644 --- a/gpg/default.nix +++ b/gpg/default.nix @@ -4,7 +4,7 @@ services.gpg-agent = { enable = true; enableZshIntegration = true; - pinentryPackage = pkgs.pinentry-curses; + pinentry.package = pkgs.pinentry-curses; enableSshSupport = true; sshKeys = gpgSSHKeys; defaultCacheTtl = 3600 * 12; diff --git a/horsch/github.nix b/horsch/github.nix index 2015359..0a94235 100644 --- a/horsch/github.nix +++ b/horsch/github.nix @@ -1,11 +1,43 @@ -{ ... }: - { - programs.gh = { - enable = true; + pkgs, + lib, + ... +}: { + nixpkgs.config.allowUnfreePredicate = pkg: + builtins.elem (lib.getName pkg) [ + "gh-copilot" + ]; - settings = { - git_protocol = "ssh"; + home.packages = with pkgs; [ + delta + ]; + + programs = { + gh = { + enable = true; + + settings = { + git_protocol = "ssh"; + }; + + extensions = with pkgs; [ + gh-copilot + gh-dash + ]; + }; + + gh-dash = { + enable = true; + + settings = { + defaults = { + preview = { + open = true; + width = 64; + }; + }; + pager.diff = "delta"; + }; }; }; } diff --git a/horsch/ssh.nix b/horsch/ssh.nix index 7890487..b3be0ad 100644 --- a/horsch/ssh.nix +++ b/horsch/ssh.nix @@ -1,6 +1,4 @@ -{ ... }: - -{ +{...}: { programs = { ssh = { enable = true; @@ -17,7 +15,7 @@ }; }; Fusion-USB = { - host = "fusion-usb fusion 172.16.0.1"; + host = "fusion-usb 172.16.0.1"; user = "root"; hostname = "172.16.0.1"; checkHostIP = false; @@ -28,7 +26,7 @@ }; }; Fusion-Wifi = { - host = "fusion-wifi 172.16.1.1"; + host = "fusion-wifi fusion 172.16.1.1"; user = "root"; hostname = "172.16.1.1"; checkHostIP = false; diff --git a/horsch/zsh.nix b/horsch/zsh.nix index 407e92b..5d091c6 100644 --- a/horsch/zsh.nix +++ b/horsch/zsh.nix @@ -1,6 +1,5 @@ -{ ... }: -{ - programs.zsh.initExtra = '' +{...}: { + programs.zsh.initContent = '' if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ]; then source $HOME/.nix-profile/etc/profile.d/nix.sh @@ -54,8 +53,11 @@ local ssh_login="fusion" local update_file=''${1} + local fzf_preview='stat --printf "%n\nSize: %s bytes\nModified: %y" {}' + if [ -z ''${update_file} ]; then - update_file=$(find build/tmp/deploy/images -name "*.swu" -type f | fzf --select-1) + update_file=$(find build/tmp/deploy/images -name "*.swu" -type f \ + | fzf --select-1 --exit-0 --header "Select a update file" --preview=''${fzf_preview} --preview-window=top) fi if [ -z ''${update_file} ]; then @@ -97,7 +99,7 @@ local wic_file=''${2} if [ -z ''${bootloader_file} ]; then - bootloader_file=$(find build/tmp/deploy/images -name "imx-boot-horsch-fusion-sd*" -type f \ + bootloader_file=$(find build/tmp/deploy/images -name "imx-boot-horsch-*" -type f \ | fzf --select-1 --exit-0 --header "Select a bootloader file" --preview=''${fzf_preview} --preview-window=top) fi @@ -132,5 +134,16 @@ --get \ | jq | bat } + + function hb-roots { + curl --silent \ + --location "https://hawkbit-smartcan.horsch.com/rest/v1/softwaremodules" \ + --header "Content-Type: application/json" \ + --header "Authorization: Basic ''$hawkbitToken" \ + --data "q=type==rootfs-smartcan" \ + --data "sort=id:DESC" \ + --get \ + | jq | bat + } ''; } diff --git a/neovim/blink-cmp.lua b/neovim/blink-cmp.lua new file mode 100644 index 0000000..8d5bcfb --- /dev/null +++ b/neovim/blink-cmp.lua @@ -0,0 +1,38 @@ +require("copilot").setup({ + copilot_model = "claude-4-sonnet" +}) + +require("blink-copilot").setup({}) + +require("blink-cmp").setup({ + completion = { + documentation = { auto_show = true, auto_show_delay_ms = 500 }, + ghost_text = { enabled = true }, + list = { + selection = { preselect = false, auto_insert = true }, + }, + }, + keymap = { + preset = "default", + [""] = { "select_next", "fallback" }, + [""] = { "select_prev", "fallback" }, + [""] = { "accept", "fallback" }, + }, + signature = { enabled = true }, + sources = { + default = { "copilot", "lsp", "buffer", "path", "cmdline" }, + + per_filetype = { + codecompanion = { "codecompanion" } + }, + + providers = { + copilot = { + name = "copilot", + module = "blink-copilot", + score_offset = 100, + async = true, + } + } + }, +}) diff --git a/neovim/codecompanion.lua b/neovim/codecompanion.lua new file mode 100644 index 0000000..efd6d72 --- /dev/null +++ b/neovim/codecompanion.lua @@ -0,0 +1,35 @@ +local codecompanion = require("codecompanion") + +vim.g.codecompanion_auto_tool_mode = true + +codecompanion.setup({ + strategies = { + chat = { + adapter = "copilot", + tools = { + opts = { + auto_submit_errors = true, + auto_submit_success = true, + requires_approval = false, + } + } + }, + inline = { + adapter = "copilot", + }, + cmd = { + adapter = "copilot", + }, + }, + adapters = { + copilot = function() + return require("codecompanion.adapters").extend("copilot", { + schema = { + model = { + default = "claude-sonnet-4", + }, + }, + }) + end, + } +}) diff --git a/neovim/dap.lua b/neovim/dap.lua index a36d4ee..c7331e7 100644 --- a/neovim/dap.lua +++ b/neovim/dap.lua @@ -1,6 +1,26 @@ local dap = require("dap") local dapui = require("dapui") +dap.adapters.lldb = { + type = "executable", + command = "lldb-dap", + name = "lldb", +} + +dap.configurations.cpp = { + { + name = "Launch", + type = "lldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = {}, + }, +} + dapui.setup() vim.fn.sign_define("DapBreakpoint", { text = "🔴", texthl = "", linehl = "", numhl = "" }) diff --git a/neovim/default.nix b/neovim/default.nix index d138ddf..9630896 100644 --- a/neovim/default.nix +++ b/neovim/default.nix @@ -1,8 +1,9 @@ -{ pkgs, theme, vimwikiPath, ... }: { - # symlink for a stable path - home.file.".vscode-extensions/vscode-lldb".source = pkgs.vscode-extensions.vadimcn.vscode-lldb; - + pkgs, + theme, + vimwikiPath, + ... +}: { programs = { neovim = { enable = true; @@ -12,37 +13,33 @@ # theme nvim-solarized-lua + # keep window layout when deleting buffers + vim-bbye + # auto-close brackets, etc nvim-autopairs + # trailing whirespaces + vim-better-whitespace + # better wildmenu wilder-nvim - # undo-tree - undotree - - # quickfix + # better quickfix nvim-bqf - # ui - dressing-nvim - # session handling - project-nvim auto-session - # escape handling - better-escape-nvim - nvim-treesitter.withAllGrammars nvim-treesitter-textobjects nvim-ts-context-commentstring markdown-preview-nvim # use({ "iamcco/markdown-preview.nvim", run = ":call mkdp#util#install()" }) + render-markdown-nvim toggleterm-nvim nvim-notify comment-nvim lualine-nvim - tabline-nvim indent-blankline-nvim plenary-nvim vim-illuminate @@ -55,21 +52,11 @@ vim-flog git-blame-nvim nvim-web-devicons # used by diffview-nvim - - # snippets - friendly-snippets - luasnip + diffview-nvim # auto-completion - nvim-cmp - cmp-nvim-lsp - cmp-buffer - cmp-path - cmp-cmdline - cmp-nvim-lua - cmp_luasnip - cmp-calc - cmp-nvim-lsp-signature-help + blink-cmp + blink-copilot # telescope telescope-nvim @@ -80,10 +67,15 @@ nvim-lspconfig lsp-status-nvim rustaceanvim - neodev-nvim + lazydev-nvim none-ls-nvim lsp_lines-nvim - lsp-inlayhints-nvim + lspkind-nvim + + # Copilot + copilot-lua + copilot-cmp + codecompanion-nvim # debugging nvim-dap @@ -91,6 +83,12 @@ # vim-wiki vimwiki + + # firenvim + firenvim + + # tmux + vim-tmux-navigator ]; withNodeJs = true; @@ -111,12 +109,14 @@ texlab nixd nixpkgs-fmt - bitbake-language-server - (python3.withPackages (ps: with ps; [ - pep8 - autopep8 - python-lsp-server - ])) + pyright + + (python3.withPackages (ps: + with ps; [ + pep8 + autopep8 + python-lsp-server + ])) #clipboard xclip @@ -137,17 +137,18 @@ require("local_toggleterm") require("local_notify") require("local_comment") - require("local_lualine") - require("local_tabline") + + if vim.g.started_by_firenvim ~= true then + require("local_lualine") + end + require("local_indent-blankline") require("local_gitsigns") - require("local_luasnip") - require("local_nvim-cmp") + require("local_blink-cmp") require("local_telescope") require("local_themes").setup("${theme}") - require("local_project-nvim") require("local_dap") require("local_illuminate") require("local_wilder") @@ -157,7 +158,26 @@ vim.g.gitblame_date_format = "%r" require("nvim-autopairs").setup({}) - require("neogen").setup({ snippet_engine = "luasnip" }) + + require("local_firenvim") + + require("local_codecompanion") + + require("diffview").setup({ + view = { + merge_tool = { + layout = "diff4_mixed", + disable_diagnostics = true, + } + } + }) + + require("render-markdown").setup({ + file_types = { "markdown", "vimwiki", "copilot-chat" }, + }) + + vim.g.strip_whitespace_on_save = 1 + vim.g.strip_whitespace_confirm = 0 ''; }; }; @@ -172,18 +192,17 @@ home.file.".config/nvim/lua/local_notify.lua".source = ./notify.lua; home.file.".config/nvim/lua/local_comment.lua".source = ./comment.lua; home.file.".config/nvim/lua/local_lualine.lua".source = ./lualine.lua; - home.file.".config/nvim/lua/local_tabline.lua".source = ./tabline.lua; home.file.".config/nvim/lua/local_indent-blankline.lua".source = ./indent-blankline.lua; home.file.".config/nvim/lua/local_gitsigns.lua".source = ./gitsigns.lua; - home.file.".config/nvim/lua/local_luasnip.lua".source = ./luasnip.lua; - home.file.".config/nvim/lua/local_nvim-cmp.lua".source = ./nvim-cmp.lua; + home.file.".config/nvim/lua/local_blink-cmp.lua".source = ./blink-cmp.lua; home.file.".config/nvim/lua/local_telescope.lua".source = ./telescope.lua; home.file.".config/nvim/lua/local_themes.lua".source = ./themes.lua; home.file.".config/nvim/lua/local_vimwiki.lua".source = ./vimwiki.lua; - home.file.".config/nvim/lua/local_project-nvim.lua".source = ./project-nvim.lua; home.file.".config/nvim/lua/local_dap.lua".source = ./dap.lua; home.file.".config/nvim/lua/local_illuminate.lua".source = ./illuminate.lua; home.file.".config/nvim/lua/local_wilder.lua".source = ./wilder.lua; + home.file.".config/nvim/lua/local_firenvim.lua".source = ./firenvim.lua; + home.file.".config/nvim/lua/local_codecompanion.lua".source = ./codecompanion.lua; } diff --git a/neovim/firenvim.lua b/neovim/firenvim.lua new file mode 100644 index 0000000..260bbd2 --- /dev/null +++ b/neovim/firenvim.lua @@ -0,0 +1,38 @@ +if vim.g.started_by_firenvim ~= true then + return +end + +vim.g.firenvim_config = { + globalSettings = { alt = "all" }, + localSettings = { + [".*"] = { + cmdline = "neovim", + content = "text", + priority = 0, + selector = "textarea", + takeover = "never" + } + } +} + +vim.api.nvim_create_autocmd('UIEnter', { + callback = function() + local client = vim.api.nvim_get_chan_info(vim.v.event.chan).client + if client ~= nil and client.name == "Firenvim" then + vim.o.laststatus = 0 + end + end +}) + +vim.api.nvim_create_autocmd({ 'TextChanged', 'TextChangedI' }, { + callback = function() + if vim.g.timer_started == true then + return + end + vim.g.timer_started = true + vim.fn.timer_start(500, function() + vim.g.timer_started = false + vim.cmd('silent write') + end) + end +}) diff --git a/neovim/keymaps.lua b/neovim/keymaps.lua index 2179b03..b37e1f7 100644 --- a/neovim/keymaps.lua +++ b/neovim/keymaps.lua @@ -12,19 +12,19 @@ nnoremap("", ":wincmd k") nnoremap("", ":wincmd l") -- Switch buffers -nnoremap("", ":TablineBufferNext") -nnoremap("", ":TablineBufferPrevious") +nnoremap("", ":bnext") +nnoremap("", ":bprevious") -- fugitive nnoremap("g", ":0Git") -- vim-flog nnoremap("G", ":Flog -all -date=relative -open-cmd=new") +nnoremap("F", ":Flog -path=% -date=relative -open-cmd=new") -- telescope local telescope = require("telescope.builtin") local telescope_themes = require("telescope.themes") -local telescope_projects = require("telescope").extensions.projects local function map_telescope(key, telescope_function) vim.api.nvim_set_keymap("n", key, "", { @@ -39,7 +39,6 @@ end map_telescope("ff", telescope.find_files) map_telescope("fb", telescope.buffers) map_telescope("fg", telescope.git_files) -map_telescope("fp", telescope_projects.projects) map_telescope("fs", telescope.lsp_document_symbols) map_telescope("fS", telescope.lsp_dynamic_workspace_symbols) map_telescope("", telescope.grep_string) @@ -60,10 +59,10 @@ vim.api.nvim_create_autocmd("TermOpen", { }) -- buffer closing -nnoremap("gq", ":bdelete") +nnoremap("gq", ":Bdelete") -- toggle search highlighting vim.cmd('nnoremap * v:hlsearch ? ":nohlsearch" : "*"') --- insert-map jj/jk to escape -require("better_escape").setup() +-- open CodeCompanion chat window +nnoremap("cc", ":CodeCompanionChat #buffer{watch} #lsp @full_stack_dev") diff --git a/neovim/lspconfig.lua b/neovim/lspconfig.lua index ea85b43..f687087 100644 --- a/neovim/lspconfig.lua +++ b/neovim/lspconfig.lua @@ -12,8 +12,6 @@ local on_attach = function(client, bufnr) }) end - require("lsp-inlayhints").on_attach(client, bufnr) - local telescope = require("telescope.builtin") nnoremap("gD", vim.lsp.buf.declaration) @@ -41,8 +39,6 @@ local on_attach = function(client, bufnr) end end -require("lsp-inlayhints").setup({}) - local lsp_status = require("lsp-status") lsp_status.config({ current_function = false, @@ -52,21 +48,10 @@ lsp_status.config({ }) lsp_status.register_progress() --- setup lua language server for init.nvim and nvim plugin development -require("neodev").setup({ - override = function(root_dir, options) - if require("neodev.util").has_file(root_dir, "/etc/nixos") then - options.enabled = true - options.plugins = true - end - end, -}) - -local capabilities = require("cmp_nvim_lsp").default_capabilities(lsp_status.capabilities) +require('lazydev').setup() local servers = { ["bashls"] = {}, - ["bitbake_language_server"] = {}, ["clangd"] = {}, ["cmake"] = {}, ["dockerls"] = {}, @@ -113,6 +98,7 @@ local servers = { } } }, + ["pyright"] = {}, ["texlab"] = {}, ["yamlls"] = { yaml = { diff --git a/neovim/lualine.lua b/neovim/lualine.lua index 0c20c9b..cb56d65 100644 --- a/neovim/lualine.lua +++ b/neovim/lualine.lua @@ -3,5 +3,13 @@ require('lualine').setup({ sections = { lualine_c = { { "filename", path = 1 }, "require('lsp-status').status()" } }, - extensions = { "toggleterm" } + tabline = { + lualine_a = { 'buffers' }, + lualine_z = { 'tabs' } + }, + extensions = { + "fugitive", + "fzf", + "toggleterm" + } }) diff --git a/neovim/luasnip.lua b/neovim/luasnip.lua deleted file mode 100644 index 80309d7..0000000 --- a/neovim/luasnip.lua +++ /dev/null @@ -1 +0,0 @@ -require("luasnip.loaders.from_vscode").lazy_load() diff --git a/neovim/nvim-cmp.lua b/neovim/nvim-cmp.lua deleted file mode 100644 index 098ce04..0000000 --- a/neovim/nvim-cmp.lua +++ /dev/null @@ -1,87 +0,0 @@ -local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and - vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub( - col, col):match("%s") == nil -end - -local cmp = require("cmp") -local luasnip = require("luasnip") - -cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end - }, - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "nvim_lsp_signature_help" }, - { name = "luasnip" }, - { name = "path" }, - { name = "buffer" }, - { name = "nvim-lua" }, - { name = "calc" }, - }), - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete({}), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - experimental = { ghost_text = true }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - formatting = { - fields = { "menu", "abbr", "kind" }, - format = function(entry, item) - local menu_icon = { - nvim_lsp = "λ", - luasnip = "⋗", - buffer = "Ω", - path = "🖿", - } - - item.menu = menu_icon[entry.source.name] - return item - end, - }, -}) - --- `/` cmdline setup. -cmp.setup.cmdline("/", { - sources = cmp.config.sources( - { name = "buffer" } - ) -}) - --- `:` cmdline setup. -cmp.setup.cmdline(":", { - sources = cmp.config.sources( - { name = "path" }, - { name = "cmdline" } - ) -}) diff --git a/neovim/options.lua b/neovim/options.lua index 3ac11ae..f1f934a 100644 --- a/neovim/options.lua +++ b/neovim/options.lua @@ -14,8 +14,8 @@ vim.opt.expandtab = true -- scroll offset vim.opt.scrolloff = 4 --- don't warp lines -vim.opt.wrap = false +-- wrap lines +vim.opt.wrap = true -- split to right/below vim.opt.splitright = true diff --git a/neovim/project-nvim.lua b/neovim/project-nvim.lua deleted file mode 100644 index 3b5902f..0000000 --- a/neovim/project-nvim.lua +++ /dev/null @@ -1 +0,0 @@ -require('project_nvim').setup({}) diff --git a/neovim/tabline.lua b/neovim/tabline.lua deleted file mode 100644 index 74da8bb..0000000 --- a/neovim/tabline.lua +++ /dev/null @@ -1 +0,0 @@ -require('tabline').setup({ enable = true, options = { show_bufnr = true, show_filename_only = true } }) diff --git a/neovim/telescope.lua b/neovim/telescope.lua index ef9245d..fe6efcd 100644 --- a/neovim/telescope.lua +++ b/neovim/telescope.lua @@ -26,4 +26,3 @@ telescope.setup({ telescope.load_extension("fzf") telescope.load_extension("ui-select") -telescope.load_extension("projects") diff --git a/private.nix b/private.nix index 9df6b32..4944525 100644 --- a/private.nix +++ b/private.nix @@ -1,4 +1,4 @@ -{ pkgs, user, ... }: +{ pkgs, user, lib, ... }: { home.username = user; @@ -13,7 +13,8 @@ thunderbird keepassxc light - element-desktop-wayland + # element-desktop-wayland + element-desktop darktable kubectl kubectx @@ -25,6 +26,11 @@ evince inkscape chromium + zoom-us + ]; + + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "zoom" ]; programs.home-manager.enable = true; @@ -34,5 +40,6 @@ ./kitty.nix ./nextcloud.nix ./sway + ./private/ssh.nix ]; } diff --git a/private/ssh.nix b/private/ssh.nix new file mode 100644 index 0000000..0a603ba --- /dev/null +++ b/private/ssh.nix @@ -0,0 +1,19 @@ +{ ... }: + +{ + programs = { + ssh = { + enable = true; + matchBlocks = { + tc-0x = { + host = "tc-*"; + user = "root"; + }; + ed-0x = { + host = "ed-*"; + user = "root"; + }; + }; + }; + }; +} diff --git a/shell/default.nix b/shell/default.nix index dcddb25..0aeb151 100644 --- a/shell/default.nix +++ b/shell/default.nix @@ -1,13 +1,15 @@ -{ pkgs, ... }: -{ +{pkgs, ...}: { home.packages = with pkgs; [ + devenv difftastic dust htop jq nh + sshfs unzip xclip + llm ]; imports = [ @@ -22,6 +24,7 @@ ./rsync.nix ./shell_aliases.nix ./starship.nix + ./tmux.nix ./tree.nix ./zoxide.nix ./zsh.nix diff --git a/shell/direnv.nix b/shell/direnv.nix index 005868d..bfff889 100644 --- a/shell/direnv.nix +++ b/shell/direnv.nix @@ -4,6 +4,7 @@ programs = { direnv = { enable = true; + silent = true; enableZshIntegration = true; nix-direnv.enable = true; }; diff --git a/shell/shell_aliases.nix b/shell/shell_aliases.nix index 2b39161..1ab320f 100644 --- a/shell/shell_aliases.nix +++ b/shell/shell_aliases.nix @@ -7,7 +7,7 @@ gs = "git status"; gd = "git diff"; gf = "git fetch"; - gfp = "git fetch --prune"; + gfg = "git fetch --no-recurse-submodules && git graph --all --max-count 32"; k = "kubectl"; ww = "nvim -c VimwikiIndex"; }; diff --git a/shell/tmux.nix b/shell/tmux.nix new file mode 100644 index 0000000..3938742 --- /dev/null +++ b/shell/tmux.nix @@ -0,0 +1,28 @@ +{pkgs, ...}: { + programs = { + tmux = { + enable = true; + clock24 = true; + keyMode = "vi"; + escapeTime = 0; + plugins = with pkgs.tmuxPlugins; [ + tmux-colors-solarized + vim-tmux-navigator + { + plugin = power-theme; + extraConfig = '' + set -g @tmux_power_theme "colour4" + ''; + } + ]; + terminal = "xterm-256color"; + extraConfig = '' + # Terminal overrides + set-option -sa terminal-overrides ",xterm-256color:Tc" + + # Reload tmux config to ensure theme is applied + bind r source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded!" + ''; + }; + }; +} diff --git a/shell/zsh.nix b/shell/zsh.nix index 1b37e36..9f415bd 100644 --- a/shell/zsh.nix +++ b/shell/zsh.nix @@ -1,8 +1,13 @@ -{ pkgs, theme, ... }: -let - zsh_autosuggest_highlight_style = if theme == "light" then "fg=180" else "fg=10"; -in { + pkgs, + theme, + ... +}: let + zsh_autosuggest_highlight_style = + if theme == "light" + then "fg=180" + else "fg=10"; +in { programs.zsh = { enable = true; enableCompletion = true; @@ -13,7 +18,16 @@ in highlight = zsh_autosuggest_highlight_style; }; - initExtra = '' + initContent = '' + # Auto-start tmux if conditions are met + if [[ -z "$TMUX" && -z "$SSH_TTY" && $- == *i* ]]; then + # Check if tmux is available and terminal supports it + if command -v tmux >/dev/null 2>&1; then + # Try to attach to existing session, or create new one + exec tmux new-session -A -s default + fi + fi + function set_win_title(){ local TITLE=$(git config --get remote.origin.url || echo "$PWD") echo -ne "\033]0; $(basename "$TITLE") \007"