From 74c81d7feaf9a1cb04ba90d3165573cf44d48b4b Mon Sep 17 00:00:00 2001 From: Yadunand Prem Date: Mon, 18 Nov 2024 12:27:24 -0500 Subject: [PATCH] feat: add formatter --- flake.nix | 22 ++-- modules/neovim.nix | 235 ++++++++++++++++++++++++++++-------- modules/wezterm/wezterm.lua | 10 ++ 3 files changed, 210 insertions(+), 57 deletions(-) diff --git a/flake.nix b/flake.nix index 80e3bf6..31b0d15 100644 --- a/flake.nix +++ b/flake.nix @@ -9,14 +9,22 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - flake-utils.url = "github:numtide/flake-utils"; nixvim = { - url = "github:nix-community/nixvim"; - inputs.nixpkgs.follows = "nixpkgs"; + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; }; + flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { nixpkgs, home-manager, flake-utils, agenix, nixvim, ... }@inputs: { + outputs = { + nixpkgs, + home-manager, + flake-utils, + agenix, + nixvim, + ... + } @ inputs: { + formatter.aarch64-darwin = nixpkgs.legacyPackages.aarch64-darwin.alejandra; homeConfigurations = { "yadunut@yadunut-mbp" = home-manager.lib.homeManagerConfiguration { pkgs = import nixpkgs { @@ -28,7 +36,7 @@ extraSpecialArgs = { inherit inputs; }; - modules = [ ./yadunut-mbp/home.nix ]; + modules = [./yadunut-mbp/home.nix]; }; "yadunut@yadunut-mba" = home-manager.lib.homeManagerConfiguration { pkgs = import nixpkgs { @@ -44,13 +52,13 @@ ./yadunut-mba/home.nix ]; }; - }; + }; nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./falcon-nixos/configuration.nix agenix.nixosModules.default - { _module.args = { inherit inputs; };} + {_module.args = {inherit inputs;};} home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; diff --git a/modules/neovim.nix b/modules/neovim.nix index a403c83..cb65a41 100644 --- a/modules/neovim.nix +++ b/modules/neovim.nix @@ -1,9 +1,15 @@ -{ config, pkgs, inputs, lib, ... }: { + config, + pkgs, + inputs, + lib, + ... +}: { imports = [ inputs.nixvim.homeManagerModules.nixvim ]; programs.nixvim = { + nixpkgs.pkgs = pkgs; performance.combinePlugins.enable = false; performance.byteCompileLua.enable = true; @@ -13,13 +19,22 @@ enable = true; defaultEditor = true; colorschemes.gruvbox.enable = true; - extraPlugins = [ pkgs.vimPlugins.todo-txt-vim ]; + extraPlugins = [pkgs.vimPlugins.todo-txt-vim]; plugins = { flash.enable = true; oil.enable = true; neogit.enable = true; hardtime.enable = true; lsp = { + package = pkgs.vimUtils.buildVimPlugin { + name = "lsp"; + src = pkgs.fetchFromGitHub { + owner = "neovim"; + repo = "nvim-lspconfig"; + rev = "541f3a2781de481bb84883889e4d9f0904250a56"; + hash = "sha256-f9CqwKBWZgC2ystm+g7FmsHR0fLcM6Wj+GkSwoUIanw="; + }; + }; enable = true; servers = { gleam.enable = true; @@ -39,17 +54,44 @@ gopls.enable = true; }; keymaps.lspBuf = { - gd = { action = "definition"; desc = "Goto Definition"; }; - gr = { action = "references"; desc = "Goto References"; }; - gD = { action = "declaration"; desc = "Goto Declaration"; }; - gI = { action = "implementation"; desc = "Goto Implementation"; }; - gT = { action = "type_definition"; desc = "Type Definition"; }; - K = { action = "hover"; desc = "Hover"; }; - "rn" = { action = "rename"; desc = "Rename"; }; + gd = { + action = "definition"; + desc = "Goto Definition"; + }; + gr = { + action = "references"; + desc = "Goto References"; + }; + gD = { + action = "declaration"; + desc = "Goto Declaration"; + }; + gI = { + action = "implementation"; + desc = "Goto Implementation"; + }; + gT = { + action = "type_definition"; + desc = "Type Definition"; + }; + K = { + action = "hover"; + desc = "Hover"; + }; + "rn" = { + action = "rename"; + desc = "Rename"; + }; }; keymaps.extra = [ - { action.__raw = "vim.lsp.buf.code_action"; key = "la"; } - { action.__raw = "function() vim.lsp.buf.format { async = true } end"; key = "lf"; } + { + action.__raw = "vim.lsp.buf.code_action"; + key = "la"; + } + { + action.__raw = "function() vim.lsp.buf.format { async = true } end"; + key = "lf"; + } ]; keymaps.diagnostic = { "cd" = { @@ -72,13 +114,23 @@ autoEnableSources = true; settings = { sources = [ - { name = "nvim_lsp"; } - { name = "nvim_lua"; } - { name = "emoji"; } - { name = "emoji"; } - { name = "buffer"; option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; keywordLength = 3; } - { name = "path"; keywordLength = 3; } - { name = "luasnip"; keywordLength = 3; } + {name = "nvim_lsp";} + {name = "nvim_lua";} + {name = "emoji";} + {name = "emoji";} + { + name = "buffer"; + option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; + keywordLength = 3; + } + { + name = "path"; + keywordLength = 3; + } + { + name = "luasnip"; + keywordLength = 3; + } ]; window = { # completion = { border = "solid"; }; @@ -108,7 +160,21 @@ updateFocusedFile.enable = true; }; - luasnip.enable = true; + friendly-snippets.enable = true; + + luasnip = { + enable = true; + settings = { + enable_autosnippets = true; + store_selection_keys = ""; + }; + fromVscode = [ + { + lazyLoad = true; + paths = "${pkgs.vimPlugins.friendly-snippets}"; + } + ]; + }; bufferline.enable = true; @@ -143,29 +209,40 @@ move = { enable = true; gotoNextStart = { - "]m" = { query = "@function.outer"; }; - "]]" = { query = "@class.outer"; desc = "Next class start"; }; - "]o" = { query = "@loop.*"; }; - "]s" = { query = "@scope"; queryGroup = "locals"; desc = "Next scope"; }; - "]z" = { query = "@fold"; queryGroup = "folds"; desc = "Next fold"; }; + "]m" = {query = "@function.outer";}; + "]]" = { + query = "@class.outer"; + desc = "Next class start"; + }; + "]o" = {query = "@loop.*";}; + "]s" = { + query = "@scope"; + queryGroup = "locals"; + desc = "Next scope"; + }; + "]z" = { + query = "@fold"; + queryGroup = "folds"; + desc = "Next fold"; + }; }; gotoNextEnd = { - "]M" = { query = "@function.outer"; }; - "][" = { query = "@class.outer"; }; + "]M" = {query = "@function.outer";}; + "][" = {query = "@class.outer";}; }; gotoPreviousStart = { - "[m" = { query = "@function.outer"; }; - "[[" = { query = "@class.outer"; }; + "[m" = {query = "@function.outer";}; + "[[" = {query = "@class.outer";}; }; gotoPreviousEnd = { - "[M" = { query = "@function.outer"; }; - "[]" = { query = "@class.outer"; }; + "[M" = {query = "@function.outer";}; + "[]" = {query = "@class.outer";}; }; gotoNext = { - "]d" = { query = "@conditional.outer"; }; + "]d" = {query = "@conditional.outer";}; }; gotoPrevious = { - "[d" = { query = "@conditional.outer"; }; + "[d" = {query = "@conditional.outer";}; }; }; }; @@ -178,20 +255,18 @@ settings = { defaults = { mappings = { - i = { "".__raw = "require('trouble.sources.telescope').open"; }; - n = { "".__raw = "require('trouble.sources.telescope').open"; }; + i = {"".__raw = "require('trouble.sources.telescope').open";}; + n = {"".__raw = "require('trouble.sources.telescope').open";}; }; }; }; }; - project-nvim = { enable = true; enableTelescope = true; }; web-devicons.enable = true; - }; opts = { number = true; @@ -219,25 +294,85 @@ maplocalleader = " "; }; keymaps = [ - { action = ":"; key = ";"; mode = [ "n" ]; } + { + action = ":"; + key = ";"; + mode = ["n"]; + } # { action = "gj"; key = "j"; mode = [ "n" ]; } # { action = "gk"; key = "k"; mode = [ "n" ]; } - { action = ""; key = "jk"; mode = [ "i" ]; } + { + action = ""; + key = "jk"; + mode = ["i"]; + } - { action = "Telescope find_files"; key = ""; options.desc = "Find Files"; } - { action = "Telescope live_grep"; key = "fg"; options.desc = "Grep";} - { action = "Telescope buffers"; key = "fb"; options.desc = "Find Buffers";} - { action = "Telescope projects"; key = "pp"; options.desc = "Switch Projects";} + { + action = "Telescope find_files"; + key = ""; + options.desc = "Find Files"; + } + { + action = "Telescope live_grep"; + key = "fg"; + options.desc = "Grep"; + } + { + action = "Telescope buffers"; + key = "fb"; + options.desc = "Find Buffers"; + } + { + action = "Telescope projects"; + key = "pp"; + options.desc = "Switch Projects"; + } - { action = "Trouble diagnostics toggle"; key = "tr"; } - { action = "Neogit"; key = "gg"; options.desc = "Open Git"; } - { action = "NvimTreeToggle"; key = "tt"; options.desc = "Tree View";} + { + action = "Trouble diagnostics toggle"; + key = "tr"; + } + { + action = "Neogit"; + key = "gg"; + options.desc = "Open Git"; + } + { + action = "NvimTreeToggle"; + key = "tt"; + options.desc = "Tree View"; + } - { action.__raw = "function() require('flash').jump() end"; key = "s"; mode = [ "n" "x" "o" ]; options.desc = "Flash"; } - { action.__raw = "function() require('flash').treesitter() end"; key = "S"; mode = [ "n" "x" "o" ]; options.desc = "Flash Treesitter"; } - { action.__raw = "function() require('flash').remote() end"; key = "r"; mode = [ "o" ]; options.desc = "Remote Flash"; } - { action.__raw = "function() require('flash').treesitter_search() end"; key = "R"; mode = [ "o" ]; options.desc = "Treesitter Search"; } - { action.__raw = "function() require('flash').toggle() end"; key = ""; mode = [ "c" ]; options.desc = "Toggle Flash"; } + { + action.__raw = "function() require('flash').jump() end"; + key = "s"; + mode = ["n" "x" "o"]; + options.desc = "Flash"; + } + { + action.__raw = "function() require('flash').treesitter() end"; + key = "S"; + mode = ["n" "x" "o"]; + options.desc = "Flash Treesitter"; + } + { + action.__raw = "function() require('flash').remote() end"; + key = "r"; + mode = ["o"]; + options.desc = "Remote Flash"; + } + { + action.__raw = "function() require('flash').treesitter_search() end"; + key = "R"; + mode = ["o"]; + options.desc = "Treesitter Search"; + } + { + action.__raw = "function() require('flash').toggle() end"; + key = ""; + mode = ["c"]; + options.desc = "Toggle Flash"; + } ]; }; } diff --git a/modules/wezterm/wezterm.lua b/modules/wezterm/wezterm.lua index 34e5bfe..259f93f 100644 --- a/modules/wezterm/wezterm.lua +++ b/modules/wezterm/wezterm.lua @@ -60,6 +60,16 @@ config.keys = { nav_pane("j", "Down"), nav_pane("k", "Up"), nav_pane("l", "Right"), + { + key = ">", + mods = "LEADER", + action = wezterm.action.MoveTabRelative(1) + }, + { + key = "<", + mods = "LEADER", + action = wezterm.action.MoveTabRelative(-1) + }, } local function get_current_working_dir(tab)