From e2d4143c2a27e6d783689751402e08a2cc0805fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 2 Mar 2023 09:13:46 +0100 Subject: [PATCH 1/3] nvim: add neovide --- modules/programs/hyprland/config.nix | 5 +- modules/programs/nvim/default.nix | 128 +++++++++++++++------------ modules/programs/nvim/init.lua | 6 +- overlays/default.nix | 13 +++ 4 files changed, 90 insertions(+), 62 deletions(-) diff --git a/modules/programs/hyprland/config.nix b/modules/programs/hyprland/config.nix index 5bfba05..1657d1b 100644 --- a/modules/programs/hyprland/config.nix +++ b/modules/programs/hyprland/config.nix @@ -137,12 +137,13 @@ in # Emacs windowrulev2 = opaque, class:^emacs$ - # Fullscreen Applications - # ${mkRules ["opaque" "noblur" "noborder" "noshadow" "forceinput"] ["fullscreen:1"]} + ${mkRules ["opaque" "noblur" "noborder" "noshadow" "forceinput"] ["fullscreen:1"]} ${mkRules ["opaque" "noblur" "noshadow"] ["class:^jetbrains-pycharm$"]} + ${mkRules ["tile" "opaque"] ["class:^neovide$"]} + # See https://wiki.hyprland.org/Configuring/Keywords/ for more $mainMod = SUPER $windowMod = ALT diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index 4a4bdfe..a9bc13c 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -19,66 +19,76 @@ in }; config = mkIf cfg.enable { - home-manager.users.moritz.programs.neovim = { - enable = true; - package = pkgs.neovim-nightly; - vimAlias = true; - vimdiffAlias = true; - withNodeJs = true; - withPython3 = true; - extraLuaConfig = builtins.readFile ./init.lua; - extraPackages = with pkgs; [ - alejandra - black - isort - nil - nixpkgs-fmt - rustfmt - shfmt - stylua - sumneko-lua-language-server - taplo - yamlfmt - ]; - plugins = with pkgs.vimPlugins; [ - catppuccin-nvim - cmp-nvim-lsp - cmp_luasnip - comment-nvim - copilot-cmp - copilot-lua - dashboard-nvim - formatter-nvim - gitsigns-nvim - lsp_lines-nvim - lspkind-nvim - lspsaga-nvim-original - lualine-lsp-progress - lualine-nvim - luasnip - neogit - noice-nvim - nui-nvim # for noice-nvim - nvim-autopairs - nvim-cmp - nvim-lastplace - nvim-lspconfig - nvim-surround - nvim-tree-lua - nvim-treesitter-textsubjects - nvim-treesitter.withAllGrammars - nvim-ts-context-commentstring - nvim-web-devicons # for dashboard-nvim - orgmode - plenary-nvim # for telescope, neogit - popup-nvim - smartcolumn-nvim - telescope-fzf-native-nvim - telescope-nvim - telescope-zoxide - vim-lion - which-key-nvim + home-manager.users.moritz = { + home.packages = with pkgs; [ + ( + if config.my.programs.hyprland.enable + then neovide-hyprland + else neovide + ) ]; + + programs.neovim = { + enable = true; + package = pkgs.neovim-nightly; + vimAlias = true; + vimdiffAlias = true; + withNodeJs = true; + withPython3 = true; + extraLuaConfig = builtins.readFile ./init.lua; + extraPackages = with pkgs; [ + alejandra + black + isort + nil + nixpkgs-fmt + rustfmt + shfmt + stylua + sumneko-lua-language-server + taplo + yamlfmt + ]; + plugins = with pkgs.vimPlugins; [ + catppuccin-nvim + cmp-nvim-lsp + cmp_luasnip + comment-nvim + copilot-cmp + copilot-lua + dashboard-nvim + formatter-nvim + gitsigns-nvim + lsp_lines-nvim + lspkind-nvim + lspsaga-nvim-original + lualine-lsp-progress + lualine-nvim + luasnip + neogit + noice-nvim + nui-nvim # for noice-nvim + nvim-autopairs + nvim-cmp + nvim-lastplace + nvim-lspconfig + nvim-surround + nvim-tree-lua + nvim-treesitter-textsubjects + nvim-treesitter.withAllGrammars + nvim-ts-context-commentstring + nvim-web-devicons # for dashboard-nvim + orgmode + plenary-nvim # for telescope, neogit + popup-nvim + smartcolumn-nvim + telescope-fzf-native-nvim + telescope-nvim + telescope-zoxide + vim-lion + which-key-nvim + ]; + }; }; }; } diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index 7b63b3f..0a92453 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -12,7 +12,6 @@ vim.opt.backupdir = { vim.fn.stdpath("state") .. "/nvim/backup//" } -- don't sto vim.opt.clipboard = "unnamedplus" -- sync with system clipboard vim.opt.conceallevel = 2 vim.opt.expandtab = true -- spaces instead of tabs -vim.opt.guifont = "Fira Code Nerd Font:h1" vim.opt.ignorecase = true vim.opt.mouse = "a" -- mouse for all modes vim.opt.number = true @@ -33,6 +32,11 @@ vim.opt.updatetime = 300 vim.opt_local.spell = true vim.opt_local.spelllang = { "en", "de_20" } -- all English regions and new German spelling +if vim.g.neovide then + vim.opt.guifont = "Fira Code Nerd Font:h10" + vim.g.neovide_scale_factor = 0.7 +end + require("catppuccin").setup({ compile_path = vim.fn.stdpath("cache") .. "/catppuccin", -- fix issue of writing to nix store integrations = { diff --git a/overlays/default.nix b/overlays/default.nix index 8d802d2..4d92b75 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -56,6 +56,19 @@ in }); }; + neovide-hyprland = final.symlinkJoin { + name = "neovide-hyprland-${final.neovide.version}"; + paths = [ final.neovide ]; + nativeBuildInputs = [ final.makeWrapper ]; + postBuild = '' + rm $out/bin/neovide + makeWrapper ${final.neovide}/bin/neovide $out/bin/neovide --set WINIT_UNIX_BACKEND x11 + ''; + meta = final.neovide.meta // { + mainProgram = "neovide"; + }; + }; + master = import inputs.master { inherit (prev) system; config.allowUnfree = true; From 05631f016d8e1483faa0468fe8e05dd0387b1225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 2 Mar 2023 09:14:27 +0100 Subject: [PATCH 2/3] nvim: add json formatter --- modules/programs/nvim/default.nix | 1 + modules/programs/nvim/init.lua | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index a9bc13c..cb2b264 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -40,6 +40,7 @@ in alejandra black isort + jq nil nixpkgs-fmt rustfmt diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/init.lua index 0a92453..5a1dec9 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/init.lua @@ -193,11 +193,10 @@ require("formatter").setup({ log_level = vim.log.levels.WARN, -- All formatter configurations are opt-in filetype = { - -- Formatter configurations for filetype "lua" go here - -- and will be executed in order + json = { + require("formatter.filetypes.json").jq, + }, lua = { - -- "formatter.filetypes.lua" defines default configurations for the - -- "lua" filetype require("formatter.filetypes.lua").stylua, }, nix = { From 8f6650bbd1f28b2409fca4e7c325522c19a23432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 2 Mar 2023 09:15:09 +0100 Subject: [PATCH 3/3] overlays: improve mkVersion Add dash to mkVersionInput Add mkVersionSrc for normal src. --- overlays/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/overlays/default.nix b/overlays/default.nix index 4d92b75..ccea795 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -5,7 +5,8 @@ let (builtins.substring 4 2 longDate) (builtins.substring 6 2 longDate) ]); - mkVersionInput = input: "unstable" + mkDate (input.lastModifiedDate or "19700101") + "_" + (input.shortRev or "dirty"); + mkVersionSrc = src: "unstable-" + builtins.substring 0 7 src.rev; + mkVersionInput = input: "unstable-" + mkDate (input.lastModifiedDate or "19700101") + "_" + (input.shortRev or "dirty"); in { agenix = inputs.agenix.packages.${prev.system}.default;