From 123fd7b129655f80ac980d72115748659e29f54c Mon Sep 17 00:00:00 2001 From: Vivian Date: Thu, 21 Mar 2024 14:41:17 +0100 Subject: [PATCH] more nvim config --- common/desktop/home.nix | 8 +- .../default.nix} | 6 +- common/hm-modules/default.nix | 2 +- common/hm-modules/nvim/default.nix | 73 +++++++++++++------ .../hm-modules/nvim/lua/obsidian_picker.lua | 44 +++++++++++ .../startup/themes/my_theme.lua} | 0 common/hm-modules/nvim/obsidian_picker.lua | 35 +++++++++ common/modules/gnome/hm.nix | 4 +- flake.lock | 54 +++++++------- flake.nix | 6 -- 10 files changed, 171 insertions(+), 61 deletions(-) rename common/hm-modules/{catppuccin.nix => catppuccin/default.nix} (87%) create mode 100644 common/hm-modules/nvim/lua/obsidian_picker.lua rename common/hm-modules/nvim/{dashboard.lua => lua/startup/themes/my_theme.lua} (100%) create mode 100644 common/hm-modules/nvim/obsidian_picker.lua diff --git a/common/desktop/home.nix b/common/desktop/home.nix index 709383a5..dfc15b78 100644 --- a/common/desktop/home.nix +++ b/common/desktop/home.nix @@ -30,7 +30,6 @@ in { mattermost-desktop mullvad-vpn neofetch - nixfmt nixpkgs-review plex-media-player plexamp @@ -44,7 +43,7 @@ in { # Enable my own hm modules themes.v.catppuccin.enable = true; - programs = { +programs = { v = { vscode.enable = true; nvim.enable = true; @@ -77,8 +76,11 @@ in { enable = true; profiles.default = { isDefault = true; }; }; + kitty = { + enable = true; + shellIntegration.enableZshIntegration = true; }; - +}; # Syncthing services.syncthing.enable = true; xdg.userDirs = let home = config.home.homeDirectory; diff --git a/common/hm-modules/catppuccin.nix b/common/hm-modules/catppuccin/default.nix similarity index 87% rename from common/hm-modules/catppuccin.nix rename to common/hm-modules/catppuccin/default.nix index e4c97c5a..ee6c76b3 100644 --- a/common/hm-modules/catppuccin.nix +++ b/common/hm-modules/catppuccin/default.nix @@ -1,6 +1,7 @@ { config, pkgs, lib, ... }: with lib; -let cfg = config.themes.v.catppuccin; +let + cfg = config.themes.v.catppuccin; in { options.themes.v.catppuccin = { enable = mkEnableOption "catppuccin"; }; config = let @@ -13,6 +14,9 @@ in { package = pkgs.bibata-cursors-translucent; }; + programs.kitty.theme = "Catppuccin-Frappe"; + programs.kitty.font.name = "DejaVuSansMono Nerd Font"; + gtk = { enable = true; theme = { diff --git a/common/hm-modules/default.nix b/common/hm-modules/default.nix index bd774cfc..af1e0614 100644 --- a/common/hm-modules/default.nix +++ b/common/hm-modules/default.nix @@ -1,3 +1,3 @@ { ... }: { - imports = [ ./catppuccin.nix ./nvim ./riff.nix ./vscode.nix ./git.nix ./rust.nix ]; + imports = [ ./catppuccin ./nvim ./riff.nix ./vscode.nix ./git.nix ./rust.nix ]; } diff --git a/common/hm-modules/nvim/default.nix b/common/hm-modules/nvim/default.nix index c5174970..ddc9a4cf 100644 --- a/common/hm-modules/nvim/default.nix +++ b/common/hm-modules/nvim/default.nix @@ -1,12 +1,20 @@ -{ config, pkgs, lib, ... }: -let cfg = config.programs.v.nvim; -in with lib; { - options.programs.v.nvim = { enable = mkEnableOption "nvim"; }; +{ + config, + pkgs, + lib, + ... +}: +let + cfg = config.programs.v.nvim; +in +with lib; +{ + options.programs.v.nvim = { + enable = mkEnableOption "nvim"; + }; config = mkIf cfg.enable { home.packages = with pkgs; [ fd ]; - home.file.".config/nvim/lua/startup/themes/my_theme.lua" = { - source = ./dashboard.lua; - }; + home.file.".config/nvim/lua".source = ./lua; programs.nixvim = { enable = true; package = pkgs.neovim-unwrapped; @@ -55,16 +63,22 @@ in with lib; { key = "fr"; action = ":Telescope frecency"; } + { + mode = "n"; + key = "ob"; + action = "require('obsidian_picker').obsidian_picker"; + lua = true; + } # Commenting { mode = "n"; - key = ""; + key = ""; action = "require('Comment.api').toggle.linewise.current"; lua = true; } { mode = "x"; - key = ""; + key = ""; action = '' function() local esc = vim.api.nvim_replace_termcodes( @@ -138,8 +152,7 @@ in with lib; { mode = "n"; key = "nf"; lua = true; - action = - "function() require('neotest').run.run(vim.fn.expand('%')) end"; + action = "function() require('neotest').run.run(vim.fn.expand('%')) end"; } # LSP { @@ -162,6 +175,9 @@ in with lib; { extraConfigLua = ""; plugins = { + image = { + enable = true; + }; bufferline.enable = true; nix.enable = true; luasnip.enable = true; @@ -170,7 +186,6 @@ in with lib; { enable = true; theme = "my_theme"; }; - none-ls.enable = false; obsidian = { enable = true; settings = { @@ -210,7 +225,7 @@ in with lib; { end return tostring(os.time()) .. "-" .. suffix end - ''; + ''; }; }; fidget = { @@ -219,7 +234,9 @@ in with lib; { ignoreDoneAlready = true; ignore = [ "ltex" ]; }; - notification = { overrideVimNotify = true; }; + notification = { + overrideVimNotify = true; + }; }; neotest = { enable = true; @@ -252,8 +269,20 @@ in with lib; { extensions.fzf-native.enable = true; extensions.fzf-native.fuzzy = true; extensions.frecency.enable = true; + extraOptions = { }; }; comment-nvim.enable = true; + none-ls = { + enable = true; + sources = { + formatting = { + nixfmt = { + enable = true; + package = pkgs.nixfmt-rfc-style; + }; + }; + }; + }; lsp = { enable = true; keymaps = { @@ -274,6 +303,7 @@ in with lib; { nil_ls.enable = true; dockerls.enable = true; rust-analyzer = { + enable = true; installCargo = false; installRustc = false; }; @@ -285,12 +315,15 @@ in with lib; { enabled = true; cache_config = true; }; - pycodestyle = { maxLineLength = 100; }; + pycodestyle = { + maxLineLength = 100; + }; }; }; elixirls.enable = true; clangd.enable = true; yamlls.enable = true; + lua-ls.enable = true; }; }; trouble.enable = true; @@ -306,13 +339,11 @@ in with lib; { enable = true; autoEnableSources = true; settings = { - snippet.expand = - "function(args) require('luasnip').lsp_expand(args.body) end"; + cmdline.":".sources = [ { name = "path"; } ]; + snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; mapping = { - "" = - "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; - "" = - "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; + "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; "" = "cmp.mapping.confirm({ select = true })"; "" = "cmp.mapping.complete()"; "" = "cmp.mapping.close()"; diff --git a/common/hm-modules/nvim/lua/obsidian_picker.lua b/common/hm-modules/nvim/lua/obsidian_picker.lua new file mode 100644 index 00000000..cf23df4b --- /dev/null +++ b/common/hm-modules/nvim/lua/obsidian_picker.lua @@ -0,0 +1,44 @@ +local pickers = require "telescope.pickers" +local finders = require "telescope.finders" +local conf = require("telescope.config").values +local actions = require("telescope.actions") +local action_state = require("telescope.actions.state") + +local obsidian_commands = require("obsidian.commands").commands +local results = {} +for key, _ in pairs(obsidian_commands) do + table.insert(results, string.sub(key, 9)) +end + +local obsidian_picker = function(opts) + opts = opts or require("telescope.themes").get_dropdown{} + pickers.new(opts, { + prompt_title = "Obsidian", + finder = finders.new_table { + results = results, + -- entry_maker = function(entry) + -- return { + -- value = entry, + -- display = entry[1], + -- ordinal = entry[1], + -- } + -- end + }, + sorter = conf.generic_sorter(opts), + attach_mappings = function(prompt_bufnr, map) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + vim.cmd(':Obsidian' .. selection[1]) + end) + return true + end, + }):find() +end + +-- obsidian_picker() + +return { + obsidian_picker = obsidian_picker +} + diff --git a/common/hm-modules/nvim/dashboard.lua b/common/hm-modules/nvim/lua/startup/themes/my_theme.lua similarity index 100% rename from common/hm-modules/nvim/dashboard.lua rename to common/hm-modules/nvim/lua/startup/themes/my_theme.lua diff --git a/common/hm-modules/nvim/obsidian_picker.lua b/common/hm-modules/nvim/obsidian_picker.lua new file mode 100644 index 00000000..0a2276d1 --- /dev/null +++ b/common/hm-modules/nvim/obsidian_picker.lua @@ -0,0 +1,35 @@ +local pickers = require "telescope.pickers" +local finders = require "telescope.finders" +local conf = require("telescope.config").values +local actions = require("telescope.actions") +local action_state = require("telescope.actions.state") + +local obsidian_commands = require("obsidian.commands").commands +local results = {} +for key, _ in pairs(obsidian_commands) do + table.insert(results, string.sub(key, 9)) +end + +local obsidian_picker = function(opts) + opts = opts or require("telescope.themes").get_dropdown {} + pickers.new(opts, { + prompt_title = "Obsidian", + finder = finders.new_table { + results = results, + }, + sorter = conf.generic_sorter(opts), + attach_mappings = function(prompt_bufnr, map) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + vim.cmd(':Obsidian' .. selection[1]) + end) + return true + end, + }):find() +end + + +return { + obsidian_picker = obsidian_picker +} diff --git a/common/modules/gnome/hm.nix b/common/modules/gnome/hm.nix index babdec76..95e3cdf4 100644 --- a/common/modules/gnome/hm.nix +++ b/common/modules/gnome/hm.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, pkgs, ... }: with lib.hm.gvariant; let @@ -120,7 +120,7 @@ in { } // generate_custom_keybindings { "terminal" = { binding = "Return"; - command = "kgx"; + command = "${pkgs.kitty}/bin/kitty"; name = "Open Terminal"; }; "firefox" = { diff --git a/flake.lock b/flake.lock index 4f963e81..8667aff4 100644 --- a/flake.lock +++ b/flake.lock @@ -764,11 +764,11 @@ "systems": "systems_10" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -840,11 +840,11 @@ ] }, "locked": { - "lastModified": 1703887061, - "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", - "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { @@ -918,11 +918,11 @@ ] }, "locked": { - "lastModified": 1710714957, - "narHash": "sha256-eZCxuF58YWgaJMMRrn8oRkwRhxooe5kBS/s2wRVr9PA=", + "lastModified": 1710820906, + "narHash": "sha256-2bNMraoRB4pdw/HtxgYTFeMhEekBZeQ53/a8xkqpbZc=", "owner": "nix-community", "repo": "home-manager", - "rev": "7b3fca5adcf6c709874a8f2e0c364fe9c58db989", + "rev": "022464438a85450abb23d93b91aa82e0addd71fb", "type": "github" }, "original": { @@ -944,11 +944,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1710754079, - "narHash": "sha256-i2GEmGDjFP8K86x5OcH0JbCoYZqLW5H+P866pVTSxU4=", + "lastModified": 1710837180, + "narHash": "sha256-WVkLclGrUliLJUl+XaJplo09VdxyqHxZtkEmmDW2QYY=", "owner": "nix-community", "repo": "lanzaboote", - "rev": "67dbf85b7c35b5e0be476facf1b360b791e4a3ae", + "rev": "ded8d23709f94aedb1407bee9e26581f258e9e3a", "type": "github" }, "original": { @@ -1393,11 +1393,11 @@ }, "nixpkgs_7": { "locked": { - "lastModified": 1710803033, - "narHash": "sha256-7sRXMRZPHUbHY9n3unU5/2SxT50MH9uJAFr1vkjiQYc=", + "lastModified": 1710861126, + "narHash": "sha256-q8fiy9mgUvTAt2OMjiVpQgDlykyGury9Fpsm0jekBfY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c2f60aeadc7af3f832c1ffa86bae06518d227fbf", + "rev": "2dcadb7087e38314cebb15af65f8f2a15d2940cc", "type": "github" }, "original": { @@ -1408,11 +1408,11 @@ }, "nixpkgs_8": { "locked": { - "lastModified": 1710631334, - "narHash": "sha256-rL5LSYd85kplL5othxK5lmAtjyMOBg390sGBTb3LRMM=", + "lastModified": 1710806803, + "narHash": "sha256-qrxvLS888pNJFwJdK+hf1wpRCSQcqA6W5+Ox202NDa0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c75037bbf9093a2acb617804ee46320d6d1fea5a", + "rev": "b06025f1533a1e07b6db3e75151caa155d1c7eb3", "type": "github" }, "original": { @@ -1449,11 +1449,11 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1710799652, - "narHash": "sha256-TWX1slRN1IQcalrY64ltQUpVhbxGnT0PaIHqNcC0VtY=", + "lastModified": 1710936779, + "narHash": "sha256-ecYnUzSWqRae10pp7J6ZE2BznTPJ9f8sLiIoDBQtRBw=", "owner": "pta2002", "repo": "nixvim", - "rev": "975f1ca526e37c9cb9c646399f03613ea77f5ec2", + "rev": "4f6e90212c7ec56d7c03611fb86befa313e7f61f", "type": "github" }, "original": { @@ -1464,11 +1464,11 @@ }, "nur": { "locked": { - "lastModified": 1710833135, - "narHash": "sha256-vtF350PUNgnQpVSy0EPS5uwza8gIFpaIx9dDk14EWI4=", + "lastModified": 1710940845, + "narHash": "sha256-hDL4J2VgG0fmCuq+X1M6e7nVp2a5xHl05PfQZlANhkQ=", "owner": "nix-community", "repo": "NUR", - "rev": "cee2a9bfe726df39af812591e8b17e8a2f319bd5", + "rev": "1593636f37dc0b788e75fb843916ce1afd21fcd0", "type": "github" }, "original": { @@ -1509,11 +1509,11 @@ ] }, "locked": { - "lastModified": 1708018599, - "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=", + "lastModified": 1710843117, + "narHash": "sha256-b6iKQeHegzpc697rxTPA3bpwGN3m50eLCgdQOmceFuE=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431", + "rev": "e8dc1b4fe80c6fcededde7700e6a23bcdf7f3347", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 778b809b..a7e96a9a 100644 --- a/flake.nix +++ b/flake.nix @@ -139,16 +139,10 @@ deploy.packages.${system}.deploy-rs deadnix statix - # nixfmt - # nixpkgs-fmt nixUnstable - # nil vault yamllint jq - # (vault-push-approle-envs self { }) - # (vault-push-approles self { }) - # fast-repl fup-repl ]; };