diff --git a/.envrc b/.envrc index e3c2943..a8d08c3 100644 --- a/.envrc +++ b/.envrc @@ -1,7 +1,8 @@ -export DIRENV_WARN_TIMEOUT=20s +use flake .nix -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 +if on_git_branch; then + echo + git status --short --branch + echo + git fetch +fi diff --git a/.gitignore b/.gitignore index 47f7f20..3357b94 100644 --- a/.gitignore +++ b/.gitignore @@ -2,13 +2,3 @@ # 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 new file mode 100644 index 0000000..2ac74d2 --- /dev/null +++ b/.nix/flake.lock @@ -0,0 +1,25 @@ +{ + "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 new file mode 100644 index 0000000..0cbe327 --- /dev/null +++ b/.nix/flake.nix @@ -0,0 +1,32 @@ +{ + 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 new file mode 100644 index 0000000..87f991d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +# 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 deleted file mode 100644 index 05d4282..0000000 --- a/devenv.lock +++ /dev/null @@ -1,103 +0,0 @@ -{ - "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 deleted file mode 100644 index 7883385..0000000 --- a/devenv.nix +++ /dev/null @@ -1,27 +0,0 @@ -{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 deleted file mode 100644 index 116a2ad..0000000 --- a/devenv.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# 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 e42e83e..b3174e7 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1750730235, - "narHash": "sha256-rZErlxiV7ssvI8t7sPrKU+fRigNc2KvoKZG3gtUtK50=", + "lastModified": 1734093295, + "narHash": "sha256-hSwgGpcZtdDsk1dnzA0xj5cNaHgN9A99hRF/mxMtwS4=", "owner": "nix-community", "repo": "home-manager", - "rev": "d07e9cceb4994ed64a22b9b36f8b76923e87ac38", + "rev": "66c5d8b62818ec4c1edb3e941f55ef78df8141a8", "type": "github" }, "original": { @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1750506804, - "narHash": "sha256-VLFNc4egNjovYVxDGyBYTrvVCgDYgENp5bVi9fPTDYc=", + "lastModified": 1734119587, + "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4206c4cb56751df534751b058295ea61357bbbaa", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8737aba..0fe7fb7 100644 --- a/flake.nix +++ b/flake.nix @@ -59,6 +59,27 @@ 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 2a63730..183cddd 100644 --- a/git/default.nix +++ b/git/default.nix @@ -1,17 +1,9 @@ +{ 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; @@ -24,24 +16,9 @@ signByDefault = true; }; - 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; + enable = true; background = "light"; - display = "side-by-side-show-both"; - enableAsDifftool = true; }; lfs = { @@ -49,34 +26,14 @@ }; extraConfig = { - branch.sort = "-committerdate"; + core.editor = "nvim"; + core.pager = "less -FX"; - core = { - editor = "nvim"; - fsmonitor = true; - untrackedCache = true; - }; + diff.ignoreSubmodules = "none"; - 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; - }; + fetch.parallel = 8; + fetch.writeCommitGraph = true; + fetch.recurseSubmodules = true; format.pretty = "format:%C(yellow)%h %Cblue%>(12)%ad %C(red)%G? %Cgreen%<(7,trunc)%aN%Cred%d %Creset%s"; @@ -84,49 +41,28 @@ log.date = "relative"; - merge = { - conflictstyle = "zdiff3"; - ff = false; - tool = "nvim"; - }; + merge.ff = false; + merge.tool = "nvim"; - mergetool.nvim.cmd = "nvim -d $BASE $LOCAL $REMOTE $MERGED -c 'DiffviewOpen'"; - mergetool.nvim.trustExitCode = false; + mergetool.nvim.cmd = "nvim -f -c \"Gdiffsplit!\" \"$MERGED\""; mergetool.prompt = false; pager.difftool = true; pull.rebase = true; - push = { - autoSetupRemote = true; - default = "simple"; - followTags = true; - recurseSubmodules = "on-demand"; - }; + push.recurseSubmodules = "on-demand"; - rebase = { - qutoSquash = true; - autoStash = true; - updateRefs = true; - }; + rebase.autostash = true; - rerere = { - autoupdate = true; - enabled = true; - }; + rerere.enabled = true; status.submoduleSummary = true; submodule.fetchJobs = 8; submodule.recurse = true; - tag.sort = "version:refname"; - - worktree = { - guessRemote = true; - useRelativePaths = true; - }; + worktree.guessRemote = true; }; aliases = { @@ -165,5 +101,26 @@ 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 00d7857..4a3069c 100644 --- a/gpg/default.nix +++ b/gpg/default.nix @@ -4,7 +4,7 @@ services.gpg-agent = { enable = true; enableZshIntegration = true; - pinentry.package = pkgs.pinentry-curses; + pinentryPackage = pkgs.pinentry-curses; enableSshSupport = true; sshKeys = gpgSSHKeys; defaultCacheTtl = 3600 * 12; diff --git a/horsch/github.nix b/horsch/github.nix index 0a94235..2015359 100644 --- a/horsch/github.nix +++ b/horsch/github.nix @@ -1,43 +1,11 @@ +{ ... }: + { - pkgs, - lib, - ... -}: { - nixpkgs.config.allowUnfreePredicate = pkg: - builtins.elem (lib.getName pkg) [ - "gh-copilot" - ]; + programs.gh = { + enable = true; - 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"; - }; + settings = { + git_protocol = "ssh"; }; }; } diff --git a/horsch/ssh.nix b/horsch/ssh.nix index b3be0ad..7890487 100644 --- a/horsch/ssh.nix +++ b/horsch/ssh.nix @@ -1,4 +1,6 @@ -{...}: { +{ ... }: + +{ programs = { ssh = { enable = true; @@ -15,7 +17,7 @@ }; }; Fusion-USB = { - host = "fusion-usb 172.16.0.1"; + host = "fusion-usb fusion 172.16.0.1"; user = "root"; hostname = "172.16.0.1"; checkHostIP = false; @@ -26,7 +28,7 @@ }; }; Fusion-Wifi = { - host = "fusion-wifi fusion 172.16.1.1"; + host = "fusion-wifi 172.16.1.1"; user = "root"; hostname = "172.16.1.1"; checkHostIP = false; diff --git a/horsch/zsh.nix b/horsch/zsh.nix index 5d091c6..407e92b 100644 --- a/horsch/zsh.nix +++ b/horsch/zsh.nix @@ -1,5 +1,6 @@ -{...}: { - programs.zsh.initContent = '' +{ ... }: +{ + programs.zsh.initExtra = '' if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ]; then source $HOME/.nix-profile/etc/profile.d/nix.sh @@ -53,11 +54,8 @@ 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 --exit-0 --header "Select a update file" --preview=''${fzf_preview} --preview-window=top) + update_file=$(find build/tmp/deploy/images -name "*.swu" -type f | fzf --select-1) fi if [ -z ''${update_file} ]; then @@ -99,7 +97,7 @@ local wic_file=''${2} if [ -z ''${bootloader_file} ]; then - bootloader_file=$(find build/tmp/deploy/images -name "imx-boot-horsch-*" -type f \ + bootloader_file=$(find build/tmp/deploy/images -name "imx-boot-horsch-fusion-sd*" -type f \ | fzf --select-1 --exit-0 --header "Select a bootloader file" --preview=''${fzf_preview} --preview-window=top) fi @@ -134,16 +132,5 @@ --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 deleted file mode 100644 index 8d5bcfb..0000000 --- a/neovim/blink-cmp.lua +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100644 index efd6d72..0000000 --- a/neovim/codecompanion.lua +++ /dev/null @@ -1,35 +0,0 @@ -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 c7331e7..a36d4ee 100644 --- a/neovim/dap.lua +++ b/neovim/dap.lua @@ -1,26 +1,6 @@ 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 9630896..d138ddf 100644 --- a/neovim/default.nix +++ b/neovim/default.nix @@ -1,9 +1,8 @@ +{ pkgs, theme, vimwikiPath, ... }: { - pkgs, - theme, - vimwikiPath, - ... -}: { + # symlink for a stable path + home.file.".vscode-extensions/vscode-lldb".source = pkgs.vscode-extensions.vadimcn.vscode-lldb; + programs = { neovim = { enable = true; @@ -13,33 +12,37 @@ # 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 - # better quickfix + # undo-tree + undotree + + # 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 @@ -52,11 +55,21 @@ vim-flog git-blame-nvim nvim-web-devicons # used by diffview-nvim - diffview-nvim + + # snippets + friendly-snippets + luasnip # auto-completion - blink-cmp - blink-copilot + nvim-cmp + cmp-nvim-lsp + cmp-buffer + cmp-path + cmp-cmdline + cmp-nvim-lua + cmp_luasnip + cmp-calc + cmp-nvim-lsp-signature-help # telescope telescope-nvim @@ -67,15 +80,10 @@ nvim-lspconfig lsp-status-nvim rustaceanvim - lazydev-nvim + neodev-nvim none-ls-nvim lsp_lines-nvim - lspkind-nvim - - # Copilot - copilot-lua - copilot-cmp - codecompanion-nvim + lsp-inlayhints-nvim # debugging nvim-dap @@ -83,12 +91,6 @@ # vim-wiki vimwiki - - # firenvim - firenvim - - # tmux - vim-tmux-navigator ]; withNodeJs = true; @@ -109,14 +111,12 @@ texlab nixd nixpkgs-fmt - pyright - - (python3.withPackages (ps: - with ps; [ - pep8 - autopep8 - python-lsp-server - ])) + bitbake-language-server + (python3.withPackages (ps: with ps; [ + pep8 + autopep8 + python-lsp-server + ])) #clipboard xclip @@ -137,18 +137,17 @@ require("local_toggleterm") require("local_notify") require("local_comment") - - if vim.g.started_by_firenvim ~= true then - require("local_lualine") - end - + require("local_lualine") + require("local_tabline") require("local_indent-blankline") require("local_gitsigns") - require("local_blink-cmp") + require("local_luasnip") + require("local_nvim-cmp") require("local_telescope") require("local_themes").setup("${theme}") + require("local_project-nvim") require("local_dap") require("local_illuminate") require("local_wilder") @@ -158,26 +157,7 @@ vim.g.gitblame_date_format = "%r" require("nvim-autopairs").setup({}) - - 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 + require("neogen").setup({ snippet_engine = "luasnip" }) ''; }; }; @@ -192,17 +172,18 @@ 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_blink-cmp.lua".source = ./blink-cmp.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_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 deleted file mode 100644 index 260bbd2..0000000 --- a/neovim/firenvim.lua +++ /dev/null @@ -1,38 +0,0 @@ -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 b37e1f7..2179b03 100644 --- a/neovim/keymaps.lua +++ b/neovim/keymaps.lua @@ -12,19 +12,19 @@ nnoremap("", ":wincmd k") nnoremap("", ":wincmd l") -- Switch buffers -nnoremap("", ":bnext") -nnoremap("", ":bprevious") +nnoremap("", ":TablineBufferNext") +nnoremap("", ":TablineBufferPrevious") -- 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,6 +39,7 @@ 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) @@ -59,10 +60,10 @@ vim.api.nvim_create_autocmd("TermOpen", { }) -- buffer closing -nnoremap("gq", ":Bdelete") +nnoremap("gq", ":bdelete") -- toggle search highlighting vim.cmd('nnoremap * v:hlsearch ? ":nohlsearch" : "*"') --- open CodeCompanion chat window -nnoremap("cc", ":CodeCompanionChat #buffer{watch} #lsp @full_stack_dev") +-- insert-map jj/jk to escape +require("better_escape").setup() diff --git a/neovim/lspconfig.lua b/neovim/lspconfig.lua index f687087..ea85b43 100644 --- a/neovim/lspconfig.lua +++ b/neovim/lspconfig.lua @@ -12,6 +12,8 @@ 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) @@ -39,6 +41,8 @@ local on_attach = function(client, bufnr) end end +require("lsp-inlayhints").setup({}) + local lsp_status = require("lsp-status") lsp_status.config({ current_function = false, @@ -48,10 +52,21 @@ lsp_status.config({ }) lsp_status.register_progress() -require('lazydev').setup() +-- 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) local servers = { ["bashls"] = {}, + ["bitbake_language_server"] = {}, ["clangd"] = {}, ["cmake"] = {}, ["dockerls"] = {}, @@ -98,7 +113,6 @@ local servers = { } } }, - ["pyright"] = {}, ["texlab"] = {}, ["yamlls"] = { yaml = { diff --git a/neovim/lualine.lua b/neovim/lualine.lua index cb56d65..0c20c9b 100644 --- a/neovim/lualine.lua +++ b/neovim/lualine.lua @@ -3,13 +3,5 @@ require('lualine').setup({ sections = { lualine_c = { { "filename", path = 1 }, "require('lsp-status').status()" } }, - tabline = { - lualine_a = { 'buffers' }, - lualine_z = { 'tabs' } - }, - extensions = { - "fugitive", - "fzf", - "toggleterm" - } + extensions = { "toggleterm" } }) diff --git a/neovim/luasnip.lua b/neovim/luasnip.lua new file mode 100644 index 0000000..80309d7 --- /dev/null +++ b/neovim/luasnip.lua @@ -0,0 +1 @@ +require("luasnip.loaders.from_vscode").lazy_load() diff --git a/neovim/nvim-cmp.lua b/neovim/nvim-cmp.lua new file mode 100644 index 0000000..098ce04 --- /dev/null +++ b/neovim/nvim-cmp.lua @@ -0,0 +1,87 @@ +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 f1f934a..3ac11ae 100644 --- a/neovim/options.lua +++ b/neovim/options.lua @@ -14,8 +14,8 @@ vim.opt.expandtab = true -- scroll offset vim.opt.scrolloff = 4 --- wrap lines -vim.opt.wrap = true +-- don't warp lines +vim.opt.wrap = false -- split to right/below vim.opt.splitright = true diff --git a/neovim/project-nvim.lua b/neovim/project-nvim.lua new file mode 100644 index 0000000..3b5902f --- /dev/null +++ b/neovim/project-nvim.lua @@ -0,0 +1 @@ +require('project_nvim').setup({}) diff --git a/neovim/tabline.lua b/neovim/tabline.lua new file mode 100644 index 0000000..74da8bb --- /dev/null +++ b/neovim/tabline.lua @@ -0,0 +1 @@ +require('tabline').setup({ enable = true, options = { show_bufnr = true, show_filename_only = true } }) diff --git a/neovim/telescope.lua b/neovim/telescope.lua index fe6efcd..ef9245d 100644 --- a/neovim/telescope.lua +++ b/neovim/telescope.lua @@ -26,3 +26,4 @@ telescope.setup({ telescope.load_extension("fzf") telescope.load_extension("ui-select") +telescope.load_extension("projects") diff --git a/private.nix b/private.nix index 4944525..9df6b32 100644 --- a/private.nix +++ b/private.nix @@ -1,4 +1,4 @@ -{ pkgs, user, lib, ... }: +{ pkgs, user, ... }: { home.username = user; @@ -13,8 +13,7 @@ thunderbird keepassxc light - # element-desktop-wayland - element-desktop + element-desktop-wayland darktable kubectl kubectx @@ -26,11 +25,6 @@ evince inkscape chromium - zoom-us - ]; - - nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ - "zoom" ]; programs.home-manager.enable = true; @@ -40,6 +34,5 @@ ./kitty.nix ./nextcloud.nix ./sway - ./private/ssh.nix ]; } diff --git a/private/ssh.nix b/private/ssh.nix deleted file mode 100644 index 0a603ba..0000000 --- a/private/ssh.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ ... }: - -{ - 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 0aeb151..dcddb25 100644 --- a/shell/default.nix +++ b/shell/default.nix @@ -1,15 +1,13 @@ -{pkgs, ...}: { +{ pkgs, ... }: +{ home.packages = with pkgs; [ - devenv difftastic dust htop jq nh - sshfs unzip xclip - llm ]; imports = [ @@ -24,7 +22,6 @@ ./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 bfff889..005868d 100644 --- a/shell/direnv.nix +++ b/shell/direnv.nix @@ -4,7 +4,6 @@ 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 1ab320f..2b39161 100644 --- a/shell/shell_aliases.nix +++ b/shell/shell_aliases.nix @@ -7,7 +7,7 @@ gs = "git status"; gd = "git diff"; gf = "git fetch"; - gfg = "git fetch --no-recurse-submodules && git graph --all --max-count 32"; + gfp = "git fetch --prune"; k = "kubectl"; ww = "nvim -c VimwikiIndex"; }; diff --git a/shell/tmux.nix b/shell/tmux.nix deleted file mode 100644 index 3938742..0000000 --- a/shell/tmux.nix +++ /dev/null @@ -1,28 +0,0 @@ -{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 9f415bd..1b37e36 100644 --- a/shell/zsh.nix +++ b/shell/zsh.nix @@ -1,13 +1,8 @@ +{ 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; @@ -18,16 +13,7 @@ in { highlight = zsh_autosuggest_highlight_style; }; - 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 - + initExtra = '' function set_win_title(){ local TITLE=$(git config --get remote.origin.url || echo "$PWD") echo -ne "\033]0; $(basename "$TITLE") \007"