From 91fb09086395464952a351bfd5777444651cb7c7 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Sat, 24 Aug 2024 23:04:20 -0700 Subject: [PATCH] refactor: heavily modularize EVERYTHING --- default.nix | 687 ----------------------- flake.nix | 2 +- homeManagerModule/default.nix | 21 + homeManagerModule/init.nix | 12 + homeManagerModule/keymaps.nix | 360 ++++++++++++ homeManagerModule/plugins/cmp.nix | 66 +++ homeManagerModule/plugins/default.nix | 3 + homeManagerModule/plugins/formatters.nix | 47 ++ homeManagerModule/plugins/lsps.nix | 49 ++ homeManagerModule/plugins/mini.nix | 17 + homeManagerModule/plugins/misc.nix | 23 + homeManagerModule/plugins/navigation.nix | 67 +++ homeManagerModule/plugins/qol.nix | 46 ++ homeManagerModule/plugins/setup.nix | 9 + homeManagerModule/plugins/treesitter.nix | 15 + 15 files changed, 736 insertions(+), 688 deletions(-) delete mode 100644 default.nix create mode 100644 homeManagerModule/default.nix create mode 100644 homeManagerModule/init.nix create mode 100644 homeManagerModule/keymaps.nix create mode 100644 homeManagerModule/plugins/cmp.nix create mode 100644 homeManagerModule/plugins/default.nix create mode 100644 homeManagerModule/plugins/formatters.nix create mode 100644 homeManagerModule/plugins/lsps.nix create mode 100644 homeManagerModule/plugins/mini.nix create mode 100644 homeManagerModule/plugins/misc.nix create mode 100644 homeManagerModule/plugins/navigation.nix create mode 100644 homeManagerModule/plugins/qol.nix create mode 100644 homeManagerModule/plugins/setup.nix create mode 100644 homeManagerModule/plugins/treesitter.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 1fd440c..0000000 --- a/default.nix +++ /dev/null @@ -1,687 +0,0 @@ -{pkgs, ...}: { - programs.nixvim = { - enable = true; - viAlias = true; - vimAlias = true; - withNodeJs = true; - withRuby = true; - - extraPackages = with pkgs; [ - # TS/JS - nodePackages.prettier - - # Rust - rust-analyzer - rustfmt - - # Nix - alejandra - - # Python - black - - # Lua - stylua - lua-language-server - - # Haskell - haskellPackages.fourmolu - - # Misc - codespell - ripgrep - yazi - fd - ]; - - luaLoader.enable = true; - performance = { - combinePlugins.enable = true; - byteCompileLua.enable = true; - }; - - colorschemes.rose-pine.enable = true; - - opts = { - laststatus = 3; - relativenumber = true; - number = true; - }; - - globals = { - mapleader = " "; - }; - - extraConfigLua = '' - require("telescope").load_extension("yank_history") - vim.diagnostic.config({ virtual_lines = false }); - ''; - - keymaps = [ - { - # Unmap space (leader) - action = ""; - key = ""; - options = { - noremap = true; - silent = true; - }; - mode = "n"; - } - { - action = "spj"; - key = "-"; - options.silent = true; - options.desc = "Split window horizontally"; - } - { - action = "vspl"; - key = "\\"; - options.silent = true; - options.desc = "Split window vertically"; - } - { - action = "ZenMode"; - key = "wz"; - options = { - silent = true; - noremap = true; - desc = "Zen mode"; - }; - } - { - action = "h"; - key = ""; - options = { - silent = true; - noremap = true; - desc = "Move to left window"; - }; - } - { - action = "j"; - key = ""; - options = { - silent = true; - noremap = true; - desc = "Move to lower window"; - }; - } - { - action = "k"; - key = ""; - options = { - silent = true; - noremap = true; - desc = "Move to upper window"; - }; - } - { - action = "l"; - key = ""; - options = { - silent = true; - noremap = true; - desc = "Move to right window"; - }; - } - { - action = "close"; - key = "wd"; - options = { - silent = true; - noremap = true; - desc = "Close current window"; - }; - } - { - action = "Telescope find_files"; - key = "ff"; - options = { - silent = true; - noremap = true; - desc = "Find files"; - }; - } - { - action = "Telescope live_grep"; - key = "/"; - options = { - silent = true; - noremap = true; - desc = "Live grep"; - }; - } - { - action = "Telescope buffers"; - key = "fb"; - options = { - silent = true; - noremap = true; - desc = "List buffers"; - }; - } - { - action = "Telescope help_tags"; - key = "fh"; - options = { - silent = true; - noremap = true; - desc = "Help tags"; - }; - } - { - action = "lua require'telescope.builtin'.lsp_definitions{}"; - key = "gd"; - options = { - silent = true; - noremap = true; - desc = "Go to definition"; - }; - } - { - action = "lua require'telescope.builtin'.git_files{}"; - key = " "; - options = { - silent = true; - noremap = true; - desc = "List Git files"; - }; - } - { - action = "lua require'telescope.builtin'.find_files{}"; - key = "ff"; - options = { - silent = true; - noremap = true; - desc = "List all files"; - }; - } - { - action = ""; - key = ""; - options = { - silent = true; - noremap = true; - desc = "Go to normal mode in built-in terminal."; - }; - mode = "t"; - } - { - action = ":resize +4"; - key = "w="; - options = { - silent = true; - noremap = true; - desc = "Increase window height."; - }; - } - { - action = ":resize -4"; - key = "w-"; - options = { - silent = true; - noremap = true; - desc = "Decrease window height."; - }; - } - { - action = ":vertical resize +4"; - key = "w]"; - options = { - silent = true; - noremap = true; - desc = "Increase window width."; - }; - } - { - action = ":vertical resize -4"; - key = "w["; - options = { - silent = true; - noremap = true; - desc = "Decrease window width."; - }; - } - { - action = ":Bdelete!"; - key = "bd"; - options = { - silent = true; - noremap = true; - desc = "Close buffer"; - }; - } - { - action = ":bprev"; - key = "H"; - options = { - silent = true; - noremap = true; - desc = "Move to the previous buffer."; - }; - } - { - action = ":bnext"; - key = "L"; - options = { - silent = true; - noremap = true; - desc = "Move to the next buffer."; - }; - } - { - action = ":LazyGit"; - key = "gg"; - options = { - silent = true; - noremap = true; - desc = "Open LazyGit"; - }; - } - { - action = ":split | wincmd j | resize 15 | term"; - key = "tt"; - options = { - silent = true; - noremap = true; - desc = "Open a half-size horizontal terminal split"; - }; - mode = "n"; - } - { - action = ":split | wincmd j | term"; - key = "te"; - options = { - silent = true; - noremap = true; - desc = "Open a horizontal terminal split"; - }; - mode = "n"; - } - { - action = ":vsplit | wincmd l | term"; - key = "tv"; - options = { - silent = true; - noremap = true; - desc = "Open a vertical terminal split"; - }; - mode = "n"; - } - { - action = ":Trouble diagnostics"; - key = "xx"; - options = { - silent = true; - noremap = true; - desc = "View trouble diagnostics"; - }; - mode = "n"; - } - { - action = ":Trouble symbols"; - key = "xs"; - options = { - silent = true; - noremap = true; - desc = "View symbols"; - }; - mode = "n"; - } - { - action = "(YankyPutAfter)"; - key = "p"; - mode = ["n" "x"]; - } - { - action = "(YankyPutBefore)"; - key = "P"; - mode = ["n" "x"]; - } - { - action = "(YankyGPutAfter)"; - key = "gp"; - mode = ["n" "x"]; - } - { - action = "(YankyGPutBefore)"; - key = "gP"; - mode = ["n" "x"]; - } - { - action = ":Telescope yank_history"; - key = "p"; - mode = "n"; - } - { - action = '':lua require("yazi").yazi()''; - key = "mm"; - options = { - desc = "Open Yazi current nvim working directory"; - noremap = true; - silent = true; - }; - } - { - action = '':lua vim.lsp.buf.code_action()''; - key = "ca"; - options = { - desc = "View available code actions"; - noremap = true; - silent = true; - }; - } - { - action = '':lua vim.lsp.buf.rename()''; - key = "cr"; - options = { - desc = "Rename symbol"; - noremap = true; - silent = true; - }; - } - { - action = '':lua require("lsp_lines").toggle()''; - key = "cd"; - options = { - desc = "Toggle lsp lines"; - noremap = true; - silent = true; - }; - } - # { - # action = ":Yazi"; - # key = "mf"; - # options = { - # desc = "Open Yazi at current file"; - # noremap = true; - # silent = true; - # }; - # } - # { - # action = "lua require'conform'.format({ bufnr = args.bf })"; - # key = "cf"; - # options = { - # silent = true; - # noremap = true; - # desc = "Format buffer"; - # }; - # } - ]; - - plugins = { - # LSP and Treesitter related - lsp = { - enable = true; - inlayHints = true; - servers = { - bashls.enable = true; - clangd.enable = true; - pyright.enable = true; - nixd.enable = true; - nushell.enable = true; - svelte.enable = true; - tailwindcss.enable = true; - typst-lsp.enable = true; - marksman.enable = true; - }; - }; - treesitter = { - enable = true; - settings = { - highlight.enable = true; - indent.enable = true; - folding.enable = true; - }; - }; - lsp-lines.enable = true; - crates-nvim.enable = true; - treesitter-context.enable = true; - - # Language specific tools - markdown-preview.enable = true; - # rustaceanvim.enable = true; - typescript-tools.enable = true; - - # git stuff - lazygit.enable = true; - gitsigns.enable = true; - - # QoL and utility - intellitab.enable = true; - guess-indent.enable = true; - vim-bbye.enable = true; - indent-blankline.enable = true; - which-key.enable = true; - zen-mode.enable = true; - nvim-autopairs.enable = true; - yanky = { - enable = true; - enableTelescope = true; - }; - telescope = { - enable = true; - extensions = { - ui-select = { - enable = true; - settings = { - codeactions = true; - }; - }; - media-files = { - enable = true; - settings = { - filetypes = [ - "png" - "webp" - "jpg" - "jpeg" - "mp4" - "svg" - "pdf" - "mov" - "mkv" - "avi" - ]; - find_cmd = "rg"; - }; - dependencies = { - imageMagick.enable = true; - pdftoppm.enable = true; - ffmpegthumbnailer.enable = true; - }; - }; - }; - }; - trouble.enable = true; - direnv.enable = true; - yazi = { - enable = true; - settings = { - open_for_directories = true; - }; - }; - harpoon = { - enable = true; - keymaps = { - addFile = "hh"; - cmdToggleQuickMenu = "hm"; - gotoTerminal = { - "1" = "ht"; - "2" = "2"; - "3" = "3"; - "4" = "4"; - }; - navFile = { - "1" = "ha"; - "2" = "hs"; - "3" = "hd"; - "4" = "hf"; - }; - navNext = "h]"; - navPrev = "h["; - toggleQuickMenu = "hk"; - }; - }; - - # Code formatting - conform-nvim = { - enable = true; - settings = { - format_on_save = { - timeoutMs = 500; - lspFallback = true; - }; - formatters_by_ft = { - lua = ["stylua"]; - python = ["black"]; - nix = ["alejandra"]; - svelte = ["prettier"]; - rust = ["rustfmt"]; - haskell = ["fourmolu"]; - "*" = ["codespell"]; - "_" = ["trim_whitespace"]; - }; - }; - }; - - # mini.nvim - mini = { - enable = true; - modules = { - surround = {}; - ai = {}; - hipatterns = {}; - notify = {}; - tabline = {}; - trailspace = {}; - comment = {}; - cursorword = {}; - bracketed = {}; - }; - }; - - # Completion - cmp-async-path.enable = true; - cmp = { - enable = true; - settings = { - autoEnableSources = true; - experimental = {ghost_text = true;}; - performance = { - debounce = 60; - fetchingTimeout = 200; - maxViewEntries = 30; - }; - snippet = {expand = "luasnip";}; - formatting = {fields = ["kind" "abbr" "menu"];}; - sources = [ - {name = "nvim_lsp";} - {name = "emoji";} - { - name = "buffer"; # text within current buffer - option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; - keywordLength = 3; - } - # { name = "copilot"; } # enable/disable copilot - { - name = "path"; # file system paths - keywordLength = 3; - } - { - name = "luasnip"; # snippets - keywordLength = 3; - } - ]; - - window = { - completion = {border = "solid";}; - documentation = {border = "solid";}; - }; - - mapping = { - "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; - "" = "cmp.mapping.select_next_item()"; - "" = "cmp.mapping.select_prev_item()"; - "" = "cmp.mapping.abort()"; - "" = "cmp.mapping.scroll_docs(-4)"; - "" = "cmp.mapping.scroll_docs(4)"; - "" = "cmp.mapping.complete()"; - "" = "cmp.mapping.confirm({ select = true })"; - "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })"; - }; - }; - }; - cmp-nvim-lsp = { - enable = true; # LSP - }; - cmp-buffer = { - enable = true; - }; - cmp-path = { - enable = true; # file system paths - }; - cmp-cmdline = { - enable = true; # autocomplete for cmdline - }; - - # Extra (stuff that doesn't affect editing) - wakatime.enable = true; - presence-nvim = { - enable = true; - editingText = "Hacking %s"; - workspaceText = "The One True Text Editor"; - buttons = [ - { - label = "GitHub"; - url = "https://github.com/youwen5"; - } - { - label = "Code Forge"; - url = "https://code.youwen.dev/"; - } - ]; - }; - }; - - extraPlugins = [ - (pkgs.vimUtils.buildVimPlugin { - name = "satellite.nvim"; - src = pkgs.fetchFromGitHub { - owner = "lewis6991"; - repo = "satellite.nvim"; - rev = "777ed56e1ef45ec808df701730b6597fc4fb0fbc"; - hash = "sha256-04Js+9SB4VuCq/ACbNh5BZcolu8i8vlGU72qo5xxfpk="; - }; - }) - (pkgs.vimUtils.buildVimPlugin { - name = "render-markdown.nvim"; - src = pkgs.fetchFromGitHub { - owner = "MeanderingProgrammer"; - repo = "render-markdown.nvim"; - rev = "7986be47531d652e950776536987e01dd5b55b94"; - hash = "sha256-lc++IrXzEA3M2iUFZACAZOcH2EwVqX4p0fhET+en37o="; - }; - }) - (pkgs.vimUtils.buildVimPlugin { - name = "haskell-tools-nvim"; - src = pkgs.fetchFromGitHub { - owner = "mrcjkb"; - repo = "haskell-tools.nvim"; - rev = "959eac0fadbdd27442904a8cb363f39afb528027"; - hash = "sha256-5CS5kvUSqQJe7iFFpicinBjCQXgFPL0ElGgnrZHTT+Y="; - }; - }) - (pkgs.vimUtils.buildVimPlugin { - name = "rustaceanvim"; - src = pkgs.fetchFromGitHub { - owner = "mrcjkb"; - repo = "rustaceanvim"; - rev = "7cba8e599deca98d4b44cac1bcbd720c62937d90"; - hash = "sha256-OYfeJuo4FZUBdW9wGGCT0lZGYr/ur1uy8frcyUJMF3k="; - }; - }) - ]; - }; -} diff --git a/flake.nix b/flake.nix index ffec5d6..fe8747a 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ ... }: { homeManagerModules.default = { - imports = [nixvim.homeManagerModules.nixvim ./default.nix]; + imports = [nixvim.homeManagerModules.nixvim ./homeManagerModule]; }; }; } diff --git a/homeManagerModule/default.nix b/homeManagerModule/default.nix new file mode 100644 index 0000000..f544e6a --- /dev/null +++ b/homeManagerModule/default.nix @@ -0,0 +1,21 @@ +{pkgs, ...}: { + imports = [./plugins ./keymaps.nix]; + programs.nixvim = { + enable = true; + viAlias = true; + vimAlias = true; + withNodeJs = true; + withRuby = true; + + luaLoader.enable = true; + performance = { + combinePlugins.enable = true; + byteCompileLua.enable = true; + }; + + extraPackages = with pkgs; [ + ripgrep + yazi + fd + ]; +} diff --git a/homeManagerModule/init.nix b/homeManagerModule/init.nix new file mode 100644 index 0000000..3826d5a --- /dev/null +++ b/homeManagerModule/init.nix @@ -0,0 +1,12 @@ +# Basic housekeeping stuff that might run in a typical `init.lua` file. +{ + programs.nixvim = { + colorschemes.rose-pine.enable = true; + + opts = { + laststatus = 3; + relativenumber = true; + number = true; + }; + }; +} diff --git a/homeManagerModule/keymaps.nix b/homeManagerModule/keymaps.nix new file mode 100644 index 0000000..9c1ad28 --- /dev/null +++ b/homeManagerModule/keymaps.nix @@ -0,0 +1,360 @@ +{ + programs.nixvim = { + globals = { + mapleader = " "; + }; + + keymaps = [ + { + # Unmap space (leader) + action = ""; + key = ""; + options = { + noremap = true; + silent = true; + }; + mode = "n"; + } + { + action = "spj"; + key = "-"; + options.silent = true; + options.desc = "Split window horizontally"; + } + { + action = "vspl"; + key = "\\"; + options.silent = true; + options.desc = "Split window vertically"; + } + { + action = "ZenMode"; + key = "wz"; + options = { + silent = true; + noremap = true; + desc = "Zen mode"; + }; + } + { + action = "h"; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Move to left window"; + }; + } + { + action = "j"; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Move to lower window"; + }; + } + { + action = "k"; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Move to upper window"; + }; + } + { + action = "l"; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Move to right window"; + }; + } + { + action = "close"; + key = "wd"; + options = { + silent = true; + noremap = true; + desc = "Close current window"; + }; + } + { + action = "Telescope find_files"; + key = "ff"; + options = { + silent = true; + noremap = true; + desc = "Find files"; + }; + } + { + action = "Telescope live_grep"; + key = "/"; + options = { + silent = true; + noremap = true; + desc = "Live grep"; + }; + } + { + action = "Telescope buffers"; + key = "fb"; + options = { + silent = true; + noremap = true; + desc = "List buffers"; + }; + } + { + action = "Telescope help_tags"; + key = "fh"; + options = { + silent = true; + noremap = true; + desc = "Help tags"; + }; + } + { + action = "lua require'telescope.builtin'.lsp_definitions{}"; + key = "gd"; + options = { + silent = true; + noremap = true; + desc = "Go to definition"; + }; + } + { + action = "lua require'telescope.builtin'.git_files{}"; + key = " "; + options = { + silent = true; + noremap = true; + desc = "List Git files"; + }; + } + { + action = "lua require'telescope.builtin'.find_files{}"; + key = "ff"; + options = { + silent = true; + noremap = true; + desc = "List all files"; + }; + } + { + action = ""; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Go to normal mode in built-in terminal."; + }; + mode = "t"; + } + { + action = ":resize +4"; + key = "w="; + options = { + silent = true; + noremap = true; + desc = "Increase window height."; + }; + } + { + action = ":resize -4"; + key = "w-"; + options = { + silent = true; + noremap = true; + desc = "Decrease window height."; + }; + } + { + action = ":vertical resize +4"; + key = "w]"; + options = { + silent = true; + noremap = true; + desc = "Increase window width."; + }; + } + { + action = ":vertical resize -4"; + key = "w["; + options = { + silent = true; + noremap = true; + desc = "Decrease window width."; + }; + } + { + action = ":Bdelete!"; + key = "bd"; + options = { + silent = true; + noremap = true; + desc = "Close buffer"; + }; + } + { + action = ":bprev"; + key = "H"; + options = { + silent = true; + noremap = true; + desc = "Move to the previous buffer."; + }; + } + { + action = ":bnext"; + key = "L"; + options = { + silent = true; + noremap = true; + desc = "Move to the next buffer."; + }; + } + { + action = ":LazyGit"; + key = "gg"; + options = { + silent = true; + noremap = true; + desc = "Open LazyGit"; + }; + } + { + action = ":split | wincmd j | resize 15 | term"; + key = "tt"; + options = { + silent = true; + noremap = true; + desc = "Open a half-size horizontal terminal split"; + }; + mode = "n"; + } + { + action = ":split | wincmd j | term"; + key = "te"; + options = { + silent = true; + noremap = true; + desc = "Open a horizontal terminal split"; + }; + mode = "n"; + } + { + action = ":vsplit | wincmd l | term"; + key = "tv"; + options = { + silent = true; + noremap = true; + desc = "Open a vertical terminal split"; + }; + mode = "n"; + } + { + action = ":Trouble diagnostics"; + key = "xx"; + options = { + silent = true; + noremap = true; + desc = "View trouble diagnostics"; + }; + mode = "n"; + } + { + action = ":Trouble symbols"; + key = "xs"; + options = { + silent = true; + noremap = true; + desc = "View symbols"; + }; + mode = "n"; + } + { + action = "(YankyPutAfter)"; + key = "p"; + mode = ["n" "x"]; + } + { + action = "(YankyPutBefore)"; + key = "P"; + mode = ["n" "x"]; + } + { + action = "(YankyGPutAfter)"; + key = "gp"; + mode = ["n" "x"]; + } + { + action = "(YankyGPutBefore)"; + key = "gP"; + mode = ["n" "x"]; + } + { + action = ":Telescope yank_history"; + key = "p"; + mode = "n"; + } + { + action = '':lua require("yazi").yazi()''; + key = "mm"; + options = { + desc = "Open Yazi current nvim working directory"; + noremap = true; + silent = true; + }; + } + { + action = '':lua vim.lsp.buf.code_action()''; + key = "ca"; + options = { + desc = "View available code actions"; + noremap = true; + silent = true; + }; + } + { + action = '':lua vim.lsp.buf.rename()''; + key = "cr"; + options = { + desc = "Rename symbol"; + noremap = true; + silent = true; + }; + } + { + action = '':lua require("lsp_lines").toggle()''; + key = "cd"; + options = { + desc = "Toggle lsp lines"; + noremap = true; + silent = true; + }; + } + # { + # action = ":Yazi"; + # key = "mf"; + # options = { + # desc = "Open Yazi at current file"; + # noremap = true; + # silent = true; + # }; + # } + # { + # action = "lua require'conform'.format({ bufnr = args.bf })"; + # key = "cf"; + # options = { + # silent = true; + # noremap = true; + # desc = "Format buffer"; + # }; + # } + ]; + }; +} diff --git a/homeManagerModule/plugins/cmp.nix b/homeManagerModule/plugins/cmp.nix new file mode 100644 index 0000000..1474253 --- /dev/null +++ b/homeManagerModule/plugins/cmp.nix @@ -0,0 +1,66 @@ +{ + programs.nixvim.plugins = { + cmp-async-path.enable = true; + cmp = { + enable = true; + settings = { + autoEnableSources = true; + experimental = {ghost_text = true;}; + performance = { + debounce = 60; + fetchingTimeout = 200; + maxViewEntries = 30; + }; + snippet = {expand = "luasnip";}; + formatting = {fields = ["kind" "abbr" "menu"];}; + sources = [ + {name = "nvim_lsp";} + {name = "emoji";} + { + name = "buffer"; # text within current buffer + option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; + keywordLength = 3; + } + # { name = "copilot"; } # enable/disable copilot + { + name = "path"; # file system paths + keywordLength = 3; + } + { + name = "luasnip"; # snippets + keywordLength = 3; + } + ]; + + window = { + completion = {border = "solid";}; + documentation = {border = "solid";}; + }; + + mapping = { + "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })"; + }; + }; + }; + cmp-nvim-lsp = { + enable = true; # LSP + }; + cmp-buffer = { + enable = true; + }; + cmp-path = { + enable = true; # file system paths + }; + cmp-cmdline = { + enable = true; # autocomplete for cmdline + }; + }; +} diff --git a/homeManagerModule/plugins/default.nix b/homeManagerModule/plugins/default.nix new file mode 100644 index 0000000..7af3312 --- /dev/null +++ b/homeManagerModule/plugins/default.nix @@ -0,0 +1,3 @@ +{ + imports = [./lsps.nix ./setup.nix ./formatters.nix ./cmp.nix ./qol.nix ./mini.nix ./misc.nix ./navigation.nix ./treesitter.nix]; +} diff --git a/homeManagerModule/plugins/formatters.nix b/homeManagerModule/plugins/formatters.nix new file mode 100644 index 0000000..12f9335 --- /dev/null +++ b/homeManagerModule/plugins/formatters.nix @@ -0,0 +1,47 @@ +# Code formatters +{pkgs, ...}: { + programs.nixvim = { + extraPackages = with pkgs; [ + # TS/JS + nodePackages.prettier + + # Rust + rustfmt + + # Nix + alejandra + + # Python + black + + # Lua + stylua + + # Haskell + haskellPackages.fourmolu + + # Misc + codespell + ]; + + plugins.conform-nvim = { + enable = true; + settings = { + format_on_save = { + timeoutMs = 500; + lspFallback = true; + }; + formatters_by_ft = { + lua = ["stylua"]; + python = ["black"]; + nix = ["alejandra"]; + svelte = ["prettier"]; + rust = ["rustfmt"]; + haskell = ["fourmolu"]; + "*" = ["codespell"]; + "_" = ["trim_whitespace"]; + }; + }; + }; + }; +} diff --git a/homeManagerModule/plugins/lsps.nix b/homeManagerModule/plugins/lsps.nix new file mode 100644 index 0000000..61a1d91 --- /dev/null +++ b/homeManagerModule/plugins/lsps.nix @@ -0,0 +1,49 @@ +# LSP setup +{pkgs, ...}: { + programs.nixvim = { + extraPackages = with pkgs; [ + rust-analyzer + lua-language-server + ]; + + plugins.lsp = { + enable = true; + inlayHints = true; + servers = { + bashls.enable = true; + clangd.enable = true; + pyright.enable = true; + nixd.enable = true; + nushell.enable = true; + svelte.enable = true; + tailwindcss.enable = true; + typst-lsp.enable = true; + marksman.enable = true; + }; + }; + plugins = { + typescript-tools.enable = true; + }; + plugins.lsp-lines.enable = true; + extraPlugins = [ + (pkgs.vimUtils.buildVimPlugin { + name = "haskell-tools-nvim"; + src = pkgs.fetchFromGitHub { + owner = "mrcjkb"; + repo = "haskell-tools.nvim"; + rev = "959eac0fadbdd27442904a8cb363f39afb528027"; + hash = "sha256-5CS5kvUSqQJe7iFFpicinBjCQXgFPL0ElGgnrZHTT+Y="; + }; + }) + (pkgs.vimUtils.buildVimPlugin { + name = "rustaceanvim"; + src = pkgs.fetchFromGitHub { + owner = "mrcjkb"; + repo = "rustaceanvim"; + rev = "7cba8e599deca98d4b44cac1bcbd720c62937d90"; + hash = "sha256-OYfeJuo4FZUBdW9wGGCT0lZGYr/ur1uy8frcyUJMF3k="; + }; + }) + ]; + }; +} diff --git a/homeManagerModule/plugins/mini.nix b/homeManagerModule/plugins/mini.nix new file mode 100644 index 0000000..5ef2303 --- /dev/null +++ b/homeManagerModule/plugins/mini.nix @@ -0,0 +1,17 @@ +# All the mini.nvim stuff +{ + programs.nixvim.plugins.mini = { + enable = true; + modules = { + surround = {}; + ai = {}; + hipatterns = {}; + notify = {}; + tabline = {}; + trailspace = {}; + comment = {}; + cursorword = {}; + bracketed = {}; + }; + }; +} diff --git a/homeManagerModule/plugins/misc.nix b/homeManagerModule/plugins/misc.nix new file mode 100644 index 0000000..544d1ad --- /dev/null +++ b/homeManagerModule/plugins/misc.nix @@ -0,0 +1,23 @@ +# Misc stuff +{ + programs.nixvim.plugins = { + # Extra (stuff that doesn't affect editing) + wakatime.enable = true; + presence-nvim = { + enable = true; + editingText = "Hacking %s"; + workspaceText = "The One True Text Editor"; + buttons = [ + { + label = "GitHub"; + url = "https://github.com/youwen5"; + } + { + label = "Code Forge"; + url = "https://code.youwen.dev/"; + } + ]; + }; + }; + }; +} diff --git a/homeManagerModule/plugins/navigation.nix b/homeManagerModule/plugins/navigation.nix new file mode 100644 index 0000000..117d1f0 --- /dev/null +++ b/homeManagerModule/plugins/navigation.nix @@ -0,0 +1,67 @@ +# Getting around REALLY FAST +{ + programs.nixvim.plugins = { + telescope = { + enable = true; + extensions = { + ui-select = { + enable = true; + settings = { + codeactions = true; + }; + }; + media-files = { + enable = true; + settings = { + filetypes = [ + "png" + "webp" + "jpg" + "jpeg" + "mp4" + "svg" + "pdf" + "mov" + "mkv" + "avi" + ]; + find_cmd = "rg"; + }; + dependencies = { + imageMagick.enable = true; + pdftoppm.enable = true; + ffmpegthumbnailer.enable = true; + }; + }; + }; + }; + yazi = { + enable = true; + settings = { + open_for_directories = true; + }; + }; + harpoon = { + enable = true; + keymaps = { + addFile = "hh"; + cmdToggleQuickMenu = "hm"; + gotoTerminal = { + "1" = "ht"; + "2" = "2"; + "3" = "3"; + "4" = "4"; + }; + navFile = { + "1" = "ha"; + "2" = "hs"; + "3" = "hd"; + "4" = "hf"; + }; + navNext = "h]"; + navPrev = "h["; + toggleQuickMenu = "hk"; + }; + }; + }; +} diff --git a/homeManagerModule/plugins/qol.nix b/homeManagerModule/plugins/qol.nix new file mode 100644 index 0000000..5f90e36 --- /dev/null +++ b/homeManagerModule/plugins/qol.nix @@ -0,0 +1,46 @@ +# Quality of life plugins +{pkgs, ...}: { + programs.nixvim = { + plugins = { + zen-mode.enable = true; + direnv.enable = true; + intellitab.enable = true; + guess-indent.enable = true; + vim-bbye.enable = true; + indent-blankline.enable = true; + which-key.enable = true; + nvim-autopairs.enable = true; + yanky = { + enable = true; + enableTelescope = true; + }; + trouble.enable = true; + crates-nvim.enable = true; + # git stuff + lazygit.enable = true; + gitsigns.enable = true; + # Language specific tools + markdown-preview.enable = true; + }; + extraPlugins = [ + (pkgs.vimUtils.buildVimPlugin { + name = "satellite.nvim"; + src = pkgs.fetchFromGitHub { + owner = "lewis6991"; + repo = "satellite.nvim"; + rev = "777ed56e1ef45ec808df701730b6597fc4fb0fbc"; + hash = "sha256-04Js+9SB4VuCq/ACbNh5BZcolu8i8vlGU72qo5xxfpk="; + }; + }) + (pkgs.vimUtils.buildVimPlugin { + name = "render-markdown.nvim"; + src = pkgs.fetchFromGitHub { + owner = "MeanderingProgrammer"; + repo = "render-markdown.nvim"; + rev = "7986be47531d652e950776536987e01dd5b55b94"; + hash = "sha256-lc++IrXzEA3M2iUFZACAZOcH2EwVqX4p0fhET+en37o="; + }; + }) + ]; + }; +} diff --git a/homeManagerModule/plugins/setup.nix b/homeManagerModule/plugins/setup.nix new file mode 100644 index 0000000..0fa840f --- /dev/null +++ b/homeManagerModule/plugins/setup.nix @@ -0,0 +1,9 @@ +# Manual setup for some plugins +{ + programs.nixvim = { + extraConfigLua = '' + require("telescope").load_extension("yank_history") + vim.diagnostic.config({ virtual_lines = false }); + ''; + }; +} diff --git a/homeManagerModule/plugins/treesitter.nix b/homeManagerModule/plugins/treesitter.nix new file mode 100644 index 0000000..2e0766e --- /dev/null +++ b/homeManagerModule/plugins/treesitter.nix @@ -0,0 +1,15 @@ +{ + programs.nixvim = { + plugins = { + treesitter = { + enable = true; + settings = { + highlight.enable = true; + indent.enable = true; + folding.enable = true; + }; + }; + treesitter-context.enable = true; + }; + }; +}