From ecb2a05d6060f5ef3842f2b39559c966ff5cb6bb Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 2 Jun 2025 02:09:06 +0100 Subject: [PATCH] Use nixvim --- flake.lock | 146 ++++++++++++++- flake.nix | 3 + .../coding/neovim/config/.gitignore | 1 - .../config/after/ftplugin/gitcommit.lua | 8 - .../neovim/config/after/ftplugin/markdown.lua | 9 - .../neovim/config/after/ftplugin/php.lua | 3 - .../neovim/config/after/ftplugin/rst.lua | 20 -- .../neovim/config/after/ftplugin/term.vim | 4 - .../neovim/config/after/ftplugin/text.lua | 21 --- .../neovim/config/autoload/opdavies.vim | 12 -- .../coding/neovim/config/init.lua | 1 - .../neovim/config/lua/opdavies/globals.lua | 13 -- .../neovim/config/lua/opdavies/init.lua | 4 - .../neovim/config/lua/opdavies/keymaps.lua | 121 ------------- .../config/lua/opdavies/lsp/handlers.lua | 73 -------- .../neovim/config/lua/opdavies/lsp/init.lua | 24 --- .../neovim/config/lua/opdavies/options.lua | 53 ------ .../lua/opdavies/snippets/javascript.lua | 12 -- .../config/lua/opdavies/snippets/lua.lua | 23 --- .../config/lua/opdavies/snippets/nix.lua | 120 ------------ .../config/lua/opdavies/snippets/php.lua | 66 ------- .../config/lua/opdavies/snippets/rst.lua | 63 ------- .../config/lua/opdavies/snippets/scss.lua | 12 -- .../config/lua/opdavies/snippets/twig.lua | 28 --- .../config/lua/opdavies/snippets/yaml.lua | 47 ----- .../lua/opdavies/telescope/multigrep.lua | 57 ------ .../neovim/config/plugin/autocommands.lua | 7 - .../neovim/config/plugin/colorscheme.lua | 25 --- .../coding/neovim/config/plugin/comment.lua | 19 -- .../neovim/config/plugin/completion.lua | 76 -------- .../coding/neovim/config/plugin/conform.lua | 5 - .../coding/neovim/config/plugin/dap.lua | 69 ------- .../coding/neovim/config/plugin/filetype.lua | 15 -- .../coding/neovim/config/plugin/fugitive.lua | 25 --- .../coding/neovim/config/plugin/gitsigns.lua | 30 --- .../coding/neovim/config/plugin/harpoon.lua | 34 ---- .../coding/neovim/config/plugin/lint.lua | 12 -- .../coding/neovim/config/plugin/mini.lua | 13 -- .../coding/neovim/config/plugin/oil.lua | 16 -- .../coding/neovim/config/plugin/phpactor.lua | 2 - .../neovim/config/plugin/refactoring.lua | 12 -- .../coding/neovim/config/plugin/snippets.lua | 32 ---- .../coding/neovim/config/plugin/telescope.lua | 64 ------- .../neovim/config/plugin/treesitter.lua | 133 -------------- .../coding/neovim/config/plugin/undotree.lua | 1 - .../coding/neovim/config/plugin/vim-test.lua | 16 -- .../coding/neovim/config/spell/en.utf-8.add | 132 -------------- .../coding/neovim/config/stylua.toml | 8 - .../home-manager/coding/neovim/default.nix | 171 +++++------------- .../home-manager/coding/neovim/keymaps.nix | 62 +++++++ .../home-manager/coding/neovim/options.nix | 25 +++ .../coding/neovim/plugins/cmp.nix | 58 ++++++ .../coding/neovim/plugins/conform.nix | 3 + .../coding/neovim/plugins/fidget.nix | 3 + .../coding/neovim/plugins/fugitive.nix | 18 ++ .../coding/neovim/plugins/gitsigns.nix | 45 +++++ .../coding/neovim/plugins/harpoon.nix | 47 +++++ .../coding/neovim/plugins/lint.nix | 3 + .../coding/neovim/plugins/lsp.nix | 3 + .../coding/neovim/plugins/lualine.nix | 11 ++ .../coding/neovim/plugins/luasnip.nix | 3 + .../coding/neovim/plugins/mini.nix | 15 ++ .../coding/neovim/plugins/oil.nix | 20 ++ .../coding/neovim/plugins/phpactor.nix | 17 ++ .../coding/neovim/plugins/refactoring.nix | 47 +++++ .../coding/neovim/plugins/telescope.nix | 28 +++ .../coding/neovim/plugins/treesitter.nix | 47 +++++ .../coding/neovim/plugins/undotree.nix | 9 + .../coding/neovim/plugins/vim-dadbod.nix | 7 + .../neovim/plugins/vim-highlightedyank.nix | 9 + .../coding/neovim/plugins/vim-test.nix | 11 ++ .../coding/neovim/plugins/web-devicons.nix | 3 + 72 files changed, 691 insertions(+), 1664 deletions(-) delete mode 100644 modules/home-manager/coding/neovim/config/.gitignore delete mode 100644 modules/home-manager/coding/neovim/config/after/ftplugin/gitcommit.lua delete mode 100644 modules/home-manager/coding/neovim/config/after/ftplugin/markdown.lua delete mode 100644 modules/home-manager/coding/neovim/config/after/ftplugin/php.lua delete mode 100644 modules/home-manager/coding/neovim/config/after/ftplugin/rst.lua delete mode 100644 modules/home-manager/coding/neovim/config/after/ftplugin/term.vim delete mode 100644 modules/home-manager/coding/neovim/config/after/ftplugin/text.lua delete mode 100644 modules/home-manager/coding/neovim/config/autoload/opdavies.vim delete mode 100644 modules/home-manager/coding/neovim/config/init.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/globals.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/init.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/keymaps.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/lsp/handlers.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/lsp/init.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/options.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/snippets/javascript.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/snippets/lua.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/snippets/nix.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/snippets/php.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/snippets/rst.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/snippets/scss.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/snippets/twig.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/snippets/yaml.lua delete mode 100644 modules/home-manager/coding/neovim/config/lua/opdavies/telescope/multigrep.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/autocommands.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/colorscheme.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/comment.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/completion.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/conform.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/dap.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/filetype.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/fugitive.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/gitsigns.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/harpoon.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/lint.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/mini.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/oil.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/phpactor.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/refactoring.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/snippets.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/telescope.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/treesitter.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/undotree.lua delete mode 100644 modules/home-manager/coding/neovim/config/plugin/vim-test.lua delete mode 100644 modules/home-manager/coding/neovim/config/spell/en.utf-8.add delete mode 100644 modules/home-manager/coding/neovim/config/stylua.toml create mode 100644 modules/home-manager/coding/neovim/keymaps.nix create mode 100644 modules/home-manager/coding/neovim/options.nix create mode 100644 modules/home-manager/coding/neovim/plugins/cmp.nix create mode 100644 modules/home-manager/coding/neovim/plugins/conform.nix create mode 100644 modules/home-manager/coding/neovim/plugins/fidget.nix create mode 100644 modules/home-manager/coding/neovim/plugins/fugitive.nix create mode 100644 modules/home-manager/coding/neovim/plugins/gitsigns.nix create mode 100644 modules/home-manager/coding/neovim/plugins/harpoon.nix create mode 100644 modules/home-manager/coding/neovim/plugins/lint.nix create mode 100644 modules/home-manager/coding/neovim/plugins/lsp.nix create mode 100644 modules/home-manager/coding/neovim/plugins/lualine.nix create mode 100644 modules/home-manager/coding/neovim/plugins/luasnip.nix create mode 100644 modules/home-manager/coding/neovim/plugins/mini.nix create mode 100644 modules/home-manager/coding/neovim/plugins/oil.nix create mode 100644 modules/home-manager/coding/neovim/plugins/phpactor.nix create mode 100644 modules/home-manager/coding/neovim/plugins/refactoring.nix create mode 100644 modules/home-manager/coding/neovim/plugins/telescope.nix create mode 100644 modules/home-manager/coding/neovim/plugins/treesitter.nix create mode 100644 modules/home-manager/coding/neovim/plugins/undotree.nix create mode 100644 modules/home-manager/coding/neovim/plugins/vim-dadbod.nix create mode 100644 modules/home-manager/coding/neovim/plugins/vim-highlightedyank.nix create mode 100644 modules/home-manager/coding/neovim/plugins/vim-test.nix create mode 100644 modules/home-manager/coding/neovim/plugins/web-devicons.nix diff --git a/flake.lock b/flake.lock index de8ea04c..8a80c853 100644 --- a/flake.lock +++ b/flake.lock @@ -80,6 +80,27 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "nur", @@ -100,6 +121,24 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -142,6 +181,34 @@ "type": "github" } }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1748294338, + "narHash": "sha256-FVO01jdmUNArzBS7NmaktLdGA5qA3lUMJ4B7a05Iynw=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "cc5f390f7caf265461d4aab37e98d2292ebbdb85", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.8", + "repo": "ixx", + "type": "github" + } + }, "nixos-hardware": { "locked": { "lastModified": 1748634340, @@ -258,9 +325,32 @@ "type": "github" } }, - "nur": { + "nixvim": { "inputs": { "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ], + "nuschtosSearch": "nuschtosSearch", + "systems": "systems_3" + }, + "locked": { + "lastModified": 1748564405, + "narHash": "sha256-uCmQLJmdg0gKWBs+vhNmS9RIPJW8/ddo6TvQ/a4gupc=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "8b3a69cfea5ba2fa008c6c57ab79c99c513a349b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nur": { + "inputs": { + "flake-parts": "flake-parts_2", "nixpkgs": "nixpkgs_4", "treefmt-nix": "treefmt-nix" }, @@ -278,6 +368,29 @@ "type": "github" } }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1748298102, + "narHash": "sha256-PP11GVwUt7F4ZZi5A5+99isuq39C59CKc5u5yVisU/U=", + "owner": "NuschtOS", + "repo": "search", + "rev": "f8a1c221afb8b4c642ed11ac5ee6746b0fe1d32f", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", @@ -287,6 +400,7 @@ "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs_3", "nixpkgs-stable": "nixpkgs-stable", + "nixvim": "nixvim", "nur": "nur" } }, @@ -305,6 +419,36 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index ff20c01e..355436d6 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,9 @@ nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; + nixvim.inputs.nixpkgs.follows = "nixpkgs"; + nixvim.url = "github:nix-community/nixvim"; + nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; diff --git a/modules/home-manager/coding/neovim/config/.gitignore b/modules/home-manager/coding/neovim/config/.gitignore deleted file mode 100644 index f67ce914..00000000 --- a/modules/home-manager/coding/neovim/config/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/spell/*.spl diff --git a/modules/home-manager/coding/neovim/config/after/ftplugin/gitcommit.lua b/modules/home-manager/coding/neovim/config/after/ftplugin/gitcommit.lua deleted file mode 100644 index f1aaed51..00000000 --- a/modules/home-manager/coding/neovim/config/after/ftplugin/gitcommit.lua +++ /dev/null @@ -1,8 +0,0 @@ -vim.opt_local.colorcolumn = "50,72" -vim.opt_local.spell = true -vim.opt_local.textwidth = 72 - --- autocmd FileType gitcommit highlight ColorColumn ctermbg=8 --- filetype indent on --- filetype on --- filetype plugin on diff --git a/modules/home-manager/coding/neovim/config/after/ftplugin/markdown.lua b/modules/home-manager/coding/neovim/config/after/ftplugin/markdown.lua deleted file mode 100644 index feb36522..00000000 --- a/modules/home-manager/coding/neovim/config/after/ftplugin/markdown.lua +++ /dev/null @@ -1,9 +0,0 @@ --- TODO: Interim fix for https://github.com/nvim-treesitter/nvim-treesitter-context/issues/431. -vim.opt_local.spell = true -vim.opt_local.wrap = true - -vim.keymap.set("n", "su", "Bi{{site.url}}/") - --- Convert lines into a markdown list. -vim.keymap.set("n", "l", "vip:norm I- ") -vim.keymap.set("v", "l", ":norm I- ") diff --git a/modules/home-manager/coding/neovim/config/after/ftplugin/php.lua b/modules/home-manager/coding/neovim/config/after/ftplugin/php.lua deleted file mode 100644 index 8d33bf16..00000000 --- a/modules/home-manager/coding/neovim/config/after/ftplugin/php.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.keymap.set("v", "dd", "yodd(['pA', pA]);") -vim.keymap.set("v", "du", "yodump(['pA', pA]);") -vim.keymap.set("v", "vd", "yovar_dump(['pA', pA]);") diff --git a/modules/home-manager/coding/neovim/config/after/ftplugin/rst.lua b/modules/home-manager/coding/neovim/config/after/ftplugin/rst.lua deleted file mode 100644 index 9ea59d91..00000000 --- a/modules/home-manager/coding/neovim/config/after/ftplugin/rst.lua +++ /dev/null @@ -1,20 +0,0 @@ -local opt = vim.opt_local - -opt.spell = true -opt.wrap = true - -local cmp = require "cmp" -local sources = cmp.get_config().sources - --- TODO: confirm these aren't aleady in the list of sources to avoid duplicate suggestions. -table.insert(sources, { name = "buffer" }) -table.insert(sources, { name = "path" }) - -cmp.setup.buffer { sources = sources } - --- Convert lines into a list. -vim.keymap.set("n", "l", "vip:norm I* ") -vim.keymap.set("v", "l", ":norm I* ") - -vim.keymap.set("n", "ta", '_iTextAnnotation "A"j') -vim.keymap.set("v", "ta", ':norm ITextAnnotation "gv:norm A"') diff --git a/modules/home-manager/coding/neovim/config/after/ftplugin/term.vim b/modules/home-manager/coding/neovim/config/after/ftplugin/term.vim deleted file mode 100644 index 16bbc95e..00000000 --- a/modules/home-manager/coding/neovim/config/after/ftplugin/term.vim +++ /dev/null @@ -1,4 +0,0 @@ -setlocal norelativenumber -setlocal nonumber - -setlocal scrolloff=0 diff --git a/modules/home-manager/coding/neovim/config/after/ftplugin/text.lua b/modules/home-manager/coding/neovim/config/after/ftplugin/text.lua deleted file mode 100644 index b18b0770..00000000 --- a/modules/home-manager/coding/neovim/config/after/ftplugin/text.lua +++ /dev/null @@ -1,21 +0,0 @@ -local opt = vim.opt_local - -opt.number = false -opt.relativenumber = false -opt.spell = true -opt.wrap = true - -vim.api.nvim_create_autocmd("BufWritePre", { - buffer = 0, - callback = function() - local last_line = vim.api.nvim_buf_get_lines(0, -2, -1, false)[1] - - if last_line ~= "" then - vim.api.nvim_buf_set_lines(0, -1, -1, false, { "" }) - end - end, -}) - --- Convert lines into a markdown list. -vim.keymap.set("n", "l", "vip:norm I- ") -vim.keymap.set("v", "l", ":norm I- ") diff --git a/modules/home-manager/coding/neovim/config/autoload/opdavies.vim b/modules/home-manager/coding/neovim/config/autoload/opdavies.vim deleted file mode 100644 index 449666bf..00000000 --- a/modules/home-manager/coding/neovim/config/autoload/opdavies.vim +++ /dev/null @@ -1,12 +0,0 @@ -if !exists('*opdavies#save_and_exec') - function! opdavies#save_and_exec() abort - if &filetype == 'vim' - :silent! write - :source % - elseif &filetype == 'lua' - :silent! write - :luafile % - endif - return - endfunction -endif diff --git a/modules/home-manager/coding/neovim/config/init.lua b/modules/home-manager/coding/neovim/config/init.lua deleted file mode 100644 index 0437de40..00000000 --- a/modules/home-manager/coding/neovim/config/init.lua +++ /dev/null @@ -1 +0,0 @@ -require "opdavies" diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/globals.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/globals.lua deleted file mode 100644 index d6fd70c6..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/globals.lua +++ /dev/null @@ -1,13 +0,0 @@ -P = function(v) - print(vim.inspect(v)) - return v -end - -RELOAD = function(...) - return require("plenary.reload").reload_module(...) -end - -R = function(name) - RELOAD(name) - return require(name) -end diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/init.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/init.lua deleted file mode 100644 index 0c5c7570..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -require "opdavies.globals" -require "opdavies.options" -require "opdavies.keymaps" -require "opdavies.lsp" diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/keymaps.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/keymaps.lua deleted file mode 100644 index 09f67f9d..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/keymaps.lua +++ /dev/null @@ -1,121 +0,0 @@ -local set = vim.keymap.set - -set("n", "", "silent !tmux new-window tmux-sessionizer") - --- Execute Lua in the current file, line or range. -set("n", "x", "source %") -set("n", "x", ":.lua") -set("v", "x", ":lua") - --- Yank from the current column to the end of the line -set("n", "Y", "yg$") - --- Keep things centred -set("n", "n", "nzzzv") -set("n", "N", "Nzzzv") - --- Disable up and down arrow keys. -set("v", "", "") -set("v", "", "") - -set("n", "", "gT") -set("n", "", "gt") - --- Easily switch back to visual mode. -set("i", "jj", "") -set("i", "jk", "") - --- Easy insertion of a trailing ; or , from insert mode -set("i", ",,", "A,") -set("i", ";;", "A;") - --- Automatically resize buffers. -set("n", "=", ":wincmd =", { noremap = true, silent = true }) - --- Move line(s) up and down. -local opts = { noremap = true, silent = true } -set("i", "", ":m .+1==gi", opts) -set("i", "", ":m .-2==gi", opts) -set("n", "", ":m .+1==", opts) -set("n", "", ":m .-2==", opts) -set("v", "", ":m '>+1gv=gv", opts) -set("v", "", ":m '<-2gv=gv", opts) - --- Re-centre when navigating. -set("n", "#", "#zz", opts) -set("n", "%", "%zz", opts) -set("n", "*", "*zz", opts) -set("n", "", "zz", opts) -set("n", "", "zz", opts) -set("n", "", "zz", opts) -set("n", "", "zz", opts) -set("n", "G", "Gzz", opts) -set("n", "N", "Nzz", opts) -set("n", "gg", "ggzz", opts) -set("n", "n", "Nzz", opts) -set("n", "{", "{zz", opts) -set("n", "}", "}zz", opts) - --- Clears hlsearch after doing a search, otherwise just does normal stuff -vim.cmd [[ nnoremap {-> v:hlsearch ? ":nohl\" : "\"}() ]] - --- Quicker macro playback. -set("n", "Q", "@qj") -set("x", "Q", ":norm @q") - -set("v", "Q", "") - -set("v", "J", ":m '>+1gvrgv") -set("v", "K", ":m '<-2gv=gv") - -set("n", "J", "mzJ`z") -set("n", "", "zz") -set("n", "", "zz") -set("n", "n", "nzzzv") -set("n", "N", "Nzzzv") - -set("n", "ec", ":edit composer.json") -set("n", "ef", ":edit flake.nix") -set("n", "ej", ":edit justfile") -set("n", "en", ":edit notes.txt") -set("n", "er", ":edit run") -set("n", "et", function() vim.cmd.tabnew("todo.txt") end) - -set({ "n", "v" }, "y", [["+y]]) -set("n", "Y", [["+Y]]) - --- Re-add functionality to open the URL under the cursor. --- This is overridden by mini.operators to exchange text regions. -vim.keymap.set("n", "gx", function() - local url = vim.fn.expand "" - vim.fn["netrw#BrowseX"](url, 0) -end, { desc = "Open URL under cursor" }) - -set("n", "f", vim.lsp.buf.format); - -local notes_directory = os.getenv("NOTES_DIRECTORY") -local wiki_directory = os.getenv("XDG_DOCUMENTS_DIR") .. "/wiki" - -set("n", "gn", function() - require("telescope.builtin").live_grep({ - cwd = notes_directory, - }) -end) - -set("n", "n", function() - local filepath = string.format("%s/%s.txt", notes_directory, os.date("%Y-%m-%d")) - - vim.cmd.tabnew(vim.fn.fnameescape(filepath)) -end) - -set("n", "fw", function() - require("telescope.builtin").find_files({ - cwd = wiki_directory, - }) -end) - -set("n", "gw", function() - require("telescope.builtin").live_grep({ - cwd = wiki_directory, - }) -end) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/lsp/handlers.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/lsp/handlers.lua deleted file mode 100644 index bf0be545..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/lsp/handlers.lua +++ /dev/null @@ -1,73 +0,0 @@ -local M = {} - -local function should_remove_diagnostic(messages_to_filter, message) - for _, filter_message in ipairs(messages_to_filter) do - if message:match(filter_message) then - return true - end - end - - return false -end - -M.definition = function() - local params = vim.lsp.util.make_position_params() - - vim.lsp.buf_request(0, "textDocument/definition", params, function(err, result, ctx, config) - local bufnr = ctx.bufnr - local ft = vim.api.nvim_buf_get_option(bufnr, "filetype") - - local new_result = vim.tbl_filter(function(v) - -- Remove any definitions within the nix store via the .direnv directory. - if string.find(v.targetUri, ".direnv") then - return false - end - - -- Remove definitions within vendor-bin directory for PHP files. - if ft == "php" then - if string.find(v.targetUri, "vendor%-bin") then - return false - end - end - - return true - end, result) - - if #new_result > 0 then - result = new_result - end - - vim.lsp.handlers["textDocument/definition"](err, result, ctx, config) - vim.cmd [[normal! zz]] - end) -end - -M.on_publish_diagnostics = function(_, result, ctx, config) - local client = vim.lsp.get_client_by_id(ctx.client_id) - - if client.name == "cssls" then - local filtered_diagnostics = {} - - local messages_to_filter = { - "Unknown at rule @apply", - "Unknown at rule @plugin", - "Unknown at rule @tailwind", - "Unknown at rule @theme", - } - - -- For each diagnostic, ensure its mesages doesn't match one I want to - -- ignore before adding it to the result. If it matches, don't add it to the - -- result and it won't be shown. - for _, diagnostic in ipairs(result.diagnostics) do - if not should_remove_diagnostic(messages_to_filter, diagnostic.message) then - table.insert(filtered_diagnostics, diagnostic) - end - end - - result.diagnostics = filtered_diagnostics - end - - vim.lsp.diagnostic.on_publish_diagnostics(_, result, ctx, config) -end - -return M diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/lsp/init.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/lsp/init.lua deleted file mode 100644 index 9fa94ff6..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/lsp/init.lua +++ /dev/null @@ -1,24 +0,0 @@ -vim.diagnostic.config { - float = { source = true }, - signs = true, - underline = false, - update_in_insert = false, - virtual_text = { spacing = 2 }, -} - -vim.api.nvim_create_autocmd("LspAttach", { - callback = function() - local builtin = require "telescope.builtin" - - vim.keymap.set("n", "gd", builtin.lsp_definitions, { buffer = 0 }) - vim.keymap.set("n", "gr", builtin.lsp_references, { buffer = 0 }) - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = 0 }) - vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, { buffer = 0 }) - vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 }) - - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { buffer = 0 }) - vim.keymap.set("n", "cr", vim.lsp.buf.rename, { buffer = 0 }) - - vim.keymap.set("n", "dl", vim.diagnostic.setqflist, { buffer = 0 }) - end, -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/options.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/options.lua deleted file mode 100644 index 745bd8f7..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/options.lua +++ /dev/null @@ -1,53 +0,0 @@ -vim.g.mapleader = " " -vim.g.snippets = "luasnip" - -local settings = { - autoindent = true, - backup = false, - breakindent = true, - expandtab = true, - exrc = true, - foldlevel = 1, - foldlevelstart = 99, - foldmethod = "indent", - formatoptions = "clqjp", - hidden = false, - hlsearch = false, - inccommand = "split", - laststatus = 3, - linebreak = true, - list = true, - mouse = "a", - number = true, - pumblend = 10, - pumheight = 10, - relativenumber = true, - scrolloff = 5, - shiftwidth = 2, - showmode = false, - signcolumn = "yes:1", - smartindent = true, - softtabstop = 2, - spellfile = "/home/opdavies/Code/personal/nixos-config/modules/home-manager/cli/neovim/config/spell/en.utf-8.add", - splitbelow = true, - splitright = true, - swapfile = false, - syntax = "on", - tabstop = 2, - termguicolors = true, - textwidth = 0, - undodir = os.getenv "XDG_STATE_HOME" .. "/nvim/undodir", - undofile = true, - updatetime = 1000, - wrap = false, -} - -for key, value in pairs(settings) do - vim.o[key] = value -end - -vim.opt.backupdir:remove "." -- keep backups out of the current directory -vim.opt.completeopt = { "menu", "menuone", "noinsert", "noselect" } -vim.opt.listchars:append { - trail = "ยท", -} diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/javascript.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/javascript.lua deleted file mode 100644 index c5af9696..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/javascript.lua +++ /dev/null @@ -1,12 +0,0 @@ -require("luasnip.session.snippet_collection").clear_snippets "javascript" - -local ls = require "luasnip" - -local i = ls.insert_node -local s = ls.snippet - -local fmta = require("luasnip.extras.fmt").fmta - -ls.add_snippets("javascript", { - s("log", fmta("console.log(<>);", { i(1, "value") })), -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/lua.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/lua.lua deleted file mode 100644 index e7eb8cd1..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/lua.lua +++ /dev/null @@ -1,23 +0,0 @@ -require("luasnip.session.snippet_collection").clear_snippets "lua" - -local ls = require "luasnip" - -local f = ls.function_node -local i = ls.insert_node -local s = ls.snippet - -local fmt = require("luasnip.extras.fmt").fmt - -ls.add_snippets("lua", { - s( - "req", - fmt([[local {} = require "{}"]], { - f(function(import_name) - local parts = vim.split(import_name[1][1], ".", true) - - return parts[#parts] or "" - end, { 1 }), - i(1), - }) - ), -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/nix.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/nix.lua deleted file mode 100644 index 1ccc6ada..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/nix.lua +++ /dev/null @@ -1,120 +0,0 @@ -require("luasnip.session.snippet_collection").clear_snippets "nix" - -local ls = require "luasnip" - -local i = ls.insert_node -local s = ls.snippet - -local fmta = require("luasnip.extras.fmt").fmta - -ls.add_snippets("nix", { - s("home_packages", fmta("home.packages = with pkgs; [ <> ];", i(0))), - - s( - "homepage_options", - fmta( - [[ - homepage.name = mkOption { - default = ""; - type = types.str; - }; - - homepage.description = mkOption { - default = ""; - type = types.str; - }; - - homepage.icon = mkOption { - default = ""; - type = types.str; - }; - - homepage.category = mkOption { - default = ""; - type = types.str; - }; - ]], - { - description = i(2), - finish = i(0), - icon = i(3), - name = i(1), - } - ) - ), - - s( - "imports", - fmta( - [[ - { - imports = [ - <> - ]; - } - ]], - { i(0) } - ) - ), - - s( - "new_flake", - fmta( - [[ - { - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - }; - - outputs = - { nixpkgs, ... }: - let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - - inherit (pkgs) mkShell; - in - { - devShells.${system}.default = mkShell { - packages = with pkgs; [ ]; - }; - - formatter.${system} = pkgs.nixfmt-classic; - }; - } - ]], - { inputs = i(1), pkgs = i(2), finish = i(0) } - ) - ), - s( - "new_module", - fmta( - [[ - { config, lib, ... }: - - let - name = ""; - cfg = config..${name}; - in - { - options..${name} = { - enable = lib.mkEnableOption "Enable ${name}"; - }; - - config = lib.mkIf cfg.enable { - - }; - } - ]], - { - finish = i(0), - more_options = i(3), - name = i(1), - namespace = i(2), - }, - { repeat_duplicates = true } - ) - ), - - s("system_packages", fmta("environment.systemPackages = with pkgs; [<>];", i(0))), -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/php.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/php.lua deleted file mode 100644 index f7b5bc0b..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/php.lua +++ /dev/null @@ -1,66 +0,0 @@ -require("luasnip.session.snippet_collection").clear_snippets "php" - -local ls = require "luasnip" - -local c = ls.choice_node -local i = ls.insert_node -local s = ls.snippet -local t = ls.text_node - -local fmta = require("luasnip.extras.fmt").fmta - -ls.add_snippets("php", { - s("func", fmta("function <>(<>)<> {\n <>\n}<>", { i(1), i(2), i(3), i(4), i(0) })), - - s( - "met", - fmta( - [[ - <> function <>(<>)<> { - <> - }<> - ]], - { c(1, { t "public", t "protected", t "private" }), i(2), i(3), i(4), i(5), i(0) } - ) - ), - - s("pest", fmta("<>('<>', function() {\n <>\n});", { c(1, { t "it", t "test" }), i(2), i(0) })), - - s( - "test", - fmta( - [[ - public function test<>(): void { - <> - }<> - ]], - { i(1), i(2), i(0) } - ) - ), - - s( - "testan", - fmta( - [[ - /** @test */ - public function <>(): void { - <> - }<> - ]], - { i(1), i(2), i(0) } - ) - ), - - s( - "testat", - fmta( - [[ - [#Test] - public function <>(): void { - <> - }<> - ]], - { i(1), i(2), i(0) } - ) - ), -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/rst.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/rst.lua deleted file mode 100644 index 954dfc8f..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/rst.lua +++ /dev/null @@ -1,63 +0,0 @@ -require("luasnip.session.snippet_collection").clear_snippets "rst" - -local ls = require "luasnip" - -local i = ls.insert_node -local f = ls.function_node -local s = ls.snippet -local t = ls.text_node - -local fmta = require("luasnip.extras.fmt").fmta - -local fill_line = function(char) - return function() - local row = vim.api.nvim_win_get_cursor(0)[1] - local lines = vim.api.nvim_buf_get_lines(0, row - 2, row, false) - return string.rep(char, #lines[1]) - end -end - -ls.add_snippets("rst", { - s("class", t(".. class:: ", i(1))), - - s("footer", t(".. footer:: ", i(1))), - - s("link", t(".. _", i(1), ":")), - - s("raw", t(".. raw:: ", i(1))), - - -- TODO: add an optional new line and ":width" property. - s("image", t(".. image:: ", i(1))), - - s("head", f(fill_line "=", {})), - - s("sub", f(fill_line "-", {})), - - s("subsub", f(fill_line "^", {})), - - -- Add a page break with an optional page template. - s( - "pb", - fmta( - [[ - .. raw:: pdf - - PageBreak<> - ]], - { i(0) } - ) - ), - - -- Add a new speaker note. - s( - "ta", - fmta( - [[ - .. raw:: pdf - - TextAnnotation "<>" - ]], - { i(0) } - ) - ), -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/scss.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/scss.lua deleted file mode 100644 index 35520859..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/scss.lua +++ /dev/null @@ -1,12 +0,0 @@ -require("luasnip.session.snippet_collection").clear_snippets "scss" - -local ls = require "luasnip" - -local i = ls.insert_node -local s = ls.snippet - -local fmta = require("luasnip.extras.fmt").fmta - -ls.add_snippets("scss", { - s("bp", fmta("@include breakpoint(<>) {\n <>\n}", { i(1), i(0) })), -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/twig.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/twig.lua deleted file mode 100644 index 628e1e25..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/twig.lua +++ /dev/null @@ -1,28 +0,0 @@ -require("luasnip.session.snippet_collection").clear_snippets "twig" - -local ls = require "luasnip" - -local s = ls.snippet -local i = ls.insert_node - -local fmta = require("luasnip.extras.fmt").fmta - -ls.add_snippets("twig", { - s("do", fmta("{% <> %}<>", { i(1), i(0) })), - s("dump", fmta("{{ dump(<>) }}<>", { i(1), i(0) })), - s("echo", fmta("{{ <> }}<>", { i(1), i(0) })), - - s( - "for", - fmta( - [[ - {% for <> in <> %} - <> - {% endfor %}<> - ]], - { i(1), i(2), i(3), i(0) } - ) - ), - - s("if", fmta("{% if <> %}<>{% endif %}<>", { i(1), i(2), i(0) })), -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/yaml.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/yaml.lua deleted file mode 100644 index 399a3072..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/snippets/yaml.lua +++ /dev/null @@ -1,47 +0,0 @@ -require("luasnip.session.snippet_collection").clear_snippets "yaml" - -local ls = require "luasnip" - -local c = ls.choice_node -local i = ls.insert_node -local s = ls.snippet -local t = ls.text_node - -local fmta = require("luasnip.extras.fmt").fmta -local rep = require("luasnip.extras").rep - -ls.add_snippets("yaml", { - s( - "drupal_info", - fmta( - [[ - name: - description: - core_version_requirement: ^10 || ^11 - type: - package: - ]], - { module_name = i(1), description = i(2), type = c(3, { t "module", t "theme" }), package = i(0) } - ) - ), - - s( - "drupal_route", - fmta( - [[ - .: - path: / - defaults: - _controller: Drupal\\Controller\ - # _form: - # _title: - # _title_callback: - methods: [GET] - requirements: - _permission: access content - # _access: TRUE - ]], - { module = i(1), route = i(2), path = i(3), module_same = rep(1), class = i(4), finish = i(0) } - ) - ), -}) diff --git a/modules/home-manager/coding/neovim/config/lua/opdavies/telescope/multigrep.lua b/modules/home-manager/coding/neovim/config/lua/opdavies/telescope/multigrep.lua deleted file mode 100644 index d4418c5d..00000000 --- a/modules/home-manager/coding/neovim/config/lua/opdavies/telescope/multigrep.lua +++ /dev/null @@ -1,57 +0,0 @@ -local conf = require("telescope.config").values -local finders = require "telescope.finders" -local make_entry = require "telescope.make_entry" -local pickers = require "telescope.pickers" - -local M = {} - -local live_multigrep = function(opts) - opts = opts or {} - opts.cwd = opts.cwd or vim.uv.cwd() - - local finder = finders.new_async_job { - command_generator = function(prompt) - if not prompt or prompt == "" then - return nil - end - - local pieces = vim.split(prompt, " ") - local args = { "rg" } - - if pieces[1] then - table.insert(args, "-e") - table.insert(args, pieces[1]) - end - - if pieces[2] then - table.insert(args, "-g") - table.insert(args, pieces[2]) - end - - ---@diagnostic disable-next-line: deprecated - return vim.tbl_flatten { - args, - { "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" }, - } - end, - - cwd = opts.cwd, - entry_maker = make_entry.gen_from_vimgrep(opts), - } - - pickers - .new(opts, { - debounce = 100, - finder = finder, - previewer = conf.grep_previewer(opts), - prompt_title = "Multi Grep", - sorter = require("telescope.sorters").empty(), - }) - :find() -end - -M.setup = function() - vim.keymap.set("n", "fg", live_multigrep) -end - -return M diff --git a/modules/home-manager/coding/neovim/config/plugin/autocommands.lua b/modules/home-manager/coding/neovim/config/plugin/autocommands.lua deleted file mode 100644 index c4641b1c..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/autocommands.lua +++ /dev/null @@ -1,7 +0,0 @@ -vim.api.nvim_create_autocmd("TextYankPost", { - desc = "Highlight when yanking (copying) text", - group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) diff --git a/modules/home-manager/coding/neovim/config/plugin/colorscheme.lua b/modules/home-manager/coding/neovim/config/plugin/colorscheme.lua deleted file mode 100644 index d949f5fd..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/colorscheme.lua +++ /dev/null @@ -1,25 +0,0 @@ -local status_ok, catppuccin = pcall(require, "catppuccin") -if not status_ok then - return -end - -catppuccin.setup { - flavour = "macchiato", - integrations = { - cmp = true, - gitsigns = true, - mini = { - enabled = true, - indentscope_color = "", - }, - native_lsp = { - enabled = true, - }, - telescope = true, - treesitter = true, - }, - term_colors = true, - transparent_background = true, -} - -vim.cmd.colorscheme "catppuccin" diff --git a/modules/home-manager/coding/neovim/config/plugin/comment.lua b/modules/home-manager/coding/neovim/config/plugin/comment.lua deleted file mode 100644 index eb350eb9..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/comment.lua +++ /dev/null @@ -1,19 +0,0 @@ -local status_ok, comment = pcall(require, "Comment") -if not status_ok then - return -end - -comment.setup { - padding = true, - - opleader = { - line = "gc", - block = "gb", - }, - - mappings = { - basic = true, - extra = true, - extended = false, - }, -} diff --git a/modules/home-manager/coding/neovim/config/plugin/completion.lua b/modules/home-manager/coding/neovim/config/plugin/completion.lua deleted file mode 100644 index d1a8a111..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/completion.lua +++ /dev/null @@ -1,76 +0,0 @@ -local cmp = require "cmp" -local ls = require "luasnip" - -vim.opt.shortmess:append "c" - -cmp.setup { - snippet = { - expand = function(args) - ls.lsp_expand(args.body) - end, - }, - - mapping = cmp.mapping.preset.insert { - [""] = cmp.mapping.close(), - - [""] = cmp.mapping(function() - if ls.locally_jumpable(-1) then - ls.jump(-1) - end - end, { "i", "s" }), - - [""] = cmp.mapping(function() - if ls.expand_or_locally_jumpable() then - ls.expand_or_jump() - end - end, { "i", "s" }), - - [""] = cmp.mapping.confirm { select = true }, - [""] = cmp.config.disable, - }, - - sources = { - { name = "nvim_lsp" }, - { name = "nvim_lua" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "calc" }, - }, - - sorting = { - comparators = { - cmp.config.compare.offset, - cmp.config.compare.exact, - cmp.config.compare.score, - cmp.config.compare.kind, - cmp.config.compare.sort_text, - cmp.config.compare.length, - cmp.config.compare.order, - }, - }, - - formatting = { - format = require("lspkind").cmp_format { - with_text = true, - menu = { - buffer = "[buf]", - cmp_tabnine = "[tn]", - luasnip = "[snip]", - nvim_lsp = "[lsp]", - nvim_lua = "[lua]", - path = "[path]", - }, - }, - }, - - experimental = { - native_menu = false, - }, -} - -cmp.setup.filetype({ "mysql", "sql" }, { - sources = { - { name = "vim-dadbod-completion" }, - { name = "buffer" }, - }, -}) diff --git a/modules/home-manager/coding/neovim/config/plugin/conform.lua b/modules/home-manager/coding/neovim/config/plugin/conform.lua deleted file mode 100644 index 733eaca4..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/conform.lua +++ /dev/null @@ -1,5 +0,0 @@ -local conform = require "conform" - -conform.setup { - formatters_by_ft = {} -} diff --git a/modules/home-manager/coding/neovim/config/plugin/dap.lua b/modules/home-manager/coding/neovim/config/plugin/dap.lua deleted file mode 100644 index f9c1f3ce..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/dap.lua +++ /dev/null @@ -1,69 +0,0 @@ -local dap = require "dap" -local ui = require "dapui" - -dap.adapters.php = { - type = "executable", - command = "node", - args = { os.getenv "HOME" .. "/build/vscode-php-debug/out/phpDebug.js" }, -} - -dap.configurations.php = { - { - type = "php", - request = "launch", - name = "Listen for Xdebug", - port = 9003, - pathMappings = { - ["/app"] = "${workspaceFolder}", - ["/var/www/html"] = "${workspaceFolder}", - }, - }, -} - -dap.listeners.after.event_initialized["ui_config"] = function() - ui.open() -end - -dap.listeners.before.event_terminated["ui_config"] = function() - ui.close() -end - -dap.listeners.before.event_exited["ui_config"] = function() - ui.close() -end - -ui.setup { - layouts = { - { - elements = { - { id = "scopes", size = 0.25 }, - "breakpoints", - "stacks", - "watches", - }, - size = 40, -- 40 columns - position = "right", - }, - { - elements = { - "repl", - "console", - }, - size = 0.25, -- 25% of total lines - position = "bottom", - }, - }, -} - -require("nvim-dap-virtual-text").setup { - commented = true, -} - -vim.keymap.set("n", "b", dap.toggle_breakpoint) -vim.keymap.set("n", "gb", dap.run_to_cursor) - -vim.keymap.set("n", "", dap.continue) -vim.keymap.set("n", "", dap.step_into) -vim.keymap.set("n", "", dap.step_over) -vim.keymap.set("n", "", dap.step_out) -vim.keymap.set("n", "", dap.step_back) diff --git a/modules/home-manager/coding/neovim/config/plugin/filetype.lua b/modules/home-manager/coding/neovim/config/plugin/filetype.lua deleted file mode 100644 index cf0ab512..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/filetype.lua +++ /dev/null @@ -1,15 +0,0 @@ -vim.filetype.add { - extension = { - inc = "php", - install = "php", - module = "php", - neon = "yaml", - pcss = "scss", - theme = "php", - }, - - filename = { - ["composer.lock"] = "json", - ["phpstan.neon.dist"] = "yaml", - }, -} diff --git a/modules/home-manager/coding/neovim/config/plugin/fugitive.lua b/modules/home-manager/coding/neovim/config/plugin/fugitive.lua deleted file mode 100644 index 4aded48c..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/fugitive.lua +++ /dev/null @@ -1,25 +0,0 @@ -vim.keymap.set("n", "gc", "Git commitK") - --- Open the ":Git" window in its own buffer, not a split. -vim.keymap.set("n", "gs", "0Git") - -vim.api.nvim_create_autocmd("BufWinEnter", { - pattern = "*", - - callback = function() - if vim.bo.ft ~= "fugitive" then - return - end - - local bufnr = vim.api.nvim_get_current_buf() - local opts = { buffer = bufnr, remap = false } - - vim.keymap.set("n", "p", function() - vim.cmd.Git "push" - end, opts) - - vim.keymap.set("n", "P", function() - vim.cmd.Git { "pull", "--rebase" } - end, opts) - end, -}) diff --git a/modules/home-manager/coding/neovim/config/plugin/gitsigns.lua b/modules/home-manager/coding/neovim/config/plugin/gitsigns.lua deleted file mode 100644 index 16b2f800..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/gitsigns.lua +++ /dev/null @@ -1,30 +0,0 @@ -local gitsigns = require "gitsigns" - -gitsigns.setup { - linehl = false, - numhl = true, -} - -local set = vim.keymap.set - -set("n", "[h", "Gitsigns prev_hunk") -set("n", "]h", "Gitsigns next_hunk") - -set("n", "hR", gitsigns.reset_buffer) -set("n", "hS", gitsigns.stage_buffer) -set("n", "hb", gitsigns.blame_line) -set("n", "hp", gitsigns.preview_hunk) -set("n", "hr", gitsigns.reset_hunk) -set("n", "hs", gitsigns.stage_hunk) -set("n", "hu", gitsigns.undo_stage_hunk) - -set("v", "hr", function() - gitsigns.reset_hunk { vim.fn.line ".", vim.fn.line "v" } -end) - -set("v", "hs", function() - gitsigns.stage_hunk { vim.fn.line ".", vim.fn.line "v" } -end) - --- Text object. -set({ "o", "x" }, "ih", ":Gitsigns select_hunk") diff --git a/modules/home-manager/coding/neovim/config/plugin/harpoon.lua b/modules/home-manager/coding/neovim/config/plugin/harpoon.lua deleted file mode 100644 index 738ca9cc..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/harpoon.lua +++ /dev/null @@ -1,34 +0,0 @@ -local harpoon = require "harpoon" - -harpoon:setup() - -vim.keymap.set("n", "a", function() - harpoon:list():add() -end) - -vim.keymap.set("n", "", function() - harpoon.ui:toggle_quick_menu(harpoon:list()) -end) - -vim.keymap.set("n", "", function() - harpoon:list():select(1) -end) - -vim.keymap.set("n", "", function() - harpoon:list():select(2) -end) - -vim.keymap.set("n", "", function() - harpoon:list():select(3) -end) - -vim.keymap.set("n", "", function() - harpoon:list():select(4) -end) - --- Set 1..5 be my shortcuts to moving to the files -for _, idx in ipairs { 1, 2, 3, 4, 5 } do - vim.keymap.set("n", string.format("%d", idx), function() - harpoon:list():select(idx) - end) -end diff --git a/modules/home-manager/coding/neovim/config/plugin/lint.lua b/modules/home-manager/coding/neovim/config/plugin/lint.lua deleted file mode 100644 index 249cf0f8..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/lint.lua +++ /dev/null @@ -1,12 +0,0 @@ -local lint = require "lint" - -lint.linters_by_ft = {}; - -local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) - -vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { - group = lint_augroup, - callback = function() - lint.try_lint() - end, -}) diff --git a/modules/home-manager/coding/neovim/config/plugin/mini.lua b/modules/home-manager/coding/neovim/config/plugin/mini.lua deleted file mode 100644 index 933bb1e9..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/mini.lua +++ /dev/null @@ -1,13 +0,0 @@ -require("mini.ai").setup { n_lines = 500 } - -require("mini.align").setup {} - -require("mini.bracketed").setup {} - -require("mini.move").setup {} - -require("mini.operators").setup {} - -require("mini.splitjoin").setup {} - -require("mini.surround").setup {} diff --git a/modules/home-manager/coding/neovim/config/plugin/oil.lua b/modules/home-manager/coding/neovim/config/plugin/oil.lua deleted file mode 100644 index d6b3cfd0..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/oil.lua +++ /dev/null @@ -1,16 +0,0 @@ -require("oil").setup { - columns = {}, - - keymaps = { - [""] = false, - [""] = "actions.select_split", - }, - - skip_confirm_for_simple_edits = true, - - view_options = { - show_hidden = true, - }, -} - -vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) diff --git a/modules/home-manager/coding/neovim/config/plugin/phpactor.lua b/modules/home-manager/coding/neovim/config/plugin/phpactor.lua deleted file mode 100644 index 873d853c..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/phpactor.lua +++ /dev/null @@ -1,2 +0,0 @@ -vim.keymap.set("n", "pm", "PhpactorContextMenu") -vim.keymap.set("n", "pn", "PhpactorClassNew") diff --git a/modules/home-manager/coding/neovim/config/plugin/refactoring.lua b/modules/home-manager/coding/neovim/config/plugin/refactoring.lua deleted file mode 100644 index a23a0bb2..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/refactoring.lua +++ /dev/null @@ -1,12 +0,0 @@ -local refactoring = require "refactoring" - --- TODO: add keymaps - https://github.com/ThePrimeagen/refactoring.nvim#configuration-for-refactoring-operations -refactoring.setup {} - -local opts = { silent = true } - -vim.keymap.set("n", "ri", "lua require 'refactoring'.refactor 'Inline Variable'", opts) - -vim.keymap.set("v", "re", "lua require 'refactoring'.refactor 'Extract Function'", opts) -vim.keymap.set("v", "ri", "lua require 'refactoring'.refactor 'Inline Variable'", opts) -vim.keymap.set("v", "rv", "lua require 'refactoring'.refactor 'Extract Variable'", opts) diff --git a/modules/home-manager/coding/neovim/config/plugin/snippets.lua b/modules/home-manager/coding/neovim/config/plugin/snippets.lua deleted file mode 100644 index c483d35a..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/snippets.lua +++ /dev/null @@ -1,32 +0,0 @@ -local ls = require "luasnip" - -ls.config.set_config { - enable_autosnippets = true, - history = true, - updateevents = "TextChanged,TextChangedI", -} - -for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/opdavies/snippets/*.lua", true)) do - loadfile(ft_path)() -end - --- Expand the current item or just to the next item within the snippet. -vim.keymap.set({ "i", "s" }, "", function() - if ls.expand_or_jumpable() then - ls.expand_or_jump() - end -end, { silent = true }) - --- Jump backwards. -vim.keymap.set({ "i", "s" }, "", function() - if ls.jumpable(-1) then - ls.jump(-1) - end -end, { silent = true }) - --- Select within a list of options. -vim.keymap.set("i", "", function() - if ls.choice_active() then - ls.change_choice(1) - end -end) diff --git a/modules/home-manager/coding/neovim/config/plugin/telescope.lua b/modules/home-manager/coding/neovim/config/plugin/telescope.lua deleted file mode 100644 index 81e58eef..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/telescope.lua +++ /dev/null @@ -1,64 +0,0 @@ -local telescope = require "telescope" - -telescope.setup { - defaults = { - layout_config = { prompt_position = "top" }, - path_display = { truncate = 1 }, - prompt_prefix = "$ ", - sorting_strategy = "ascending", - }, - - pickers = { - lsp_references = { - previewer = false, - }, - }, - - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown {}, - }, - }, -} - -telescope.load_extension "fzf" -telescope.load_extension "refactoring" -telescope.load_extension "ui-select" - -local builtin = require "telescope.builtin" - -local M = {} - -M.grep_bluecheese = function() - builtin.live_grep { cwd = "web/sites/default/themes/bluecheese" } -end - -M.grep_drupalorg_theme = function() - builtin.live_grep { cwd = "web/themes/contrib/drupalorg_theme" } -end - -M.search_all_files = function() - builtin.find_files { - find_command = { "rg", "--no-ignore", "--files" }, - } -end - -vim.keymap.set("n", "/", builtin.current_buffer_fuzzy_find) -vim.keymap.set("n", "fb", builtin.buffers) -vim.keymap.set("n", "fd", builtin.find_files) -vim.keymap.set("n", "fh", builtin.help_tags) -vim.keymap.set("n", "fi", M.search_all_files) -vim.keymap.set("n", "fk", builtin.keymaps) -vim.keymap.set("n", "fr", builtin.lsp_references) -vim.keymap.set("n", "ft", builtin.git_files) - -vim.keymap.set("n", "ds", builtin.lsp_document_symbols) - -vim.keymap.set("n", "gw", builtin.grep_string) - -vim.keymap.set("n", "dgb", M.grep_bluecheese) -vim.keymap.set("n", "dgd", M.grep_drupalorg_theme) - -vim.keymap.set({ "n", "v" }, "gw", builtin.grep_string) - -require("opdavies.telescope.multigrep").setup {} diff --git a/modules/home-manager/coding/neovim/config/plugin/treesitter.lua b/modules/home-manager/coding/neovim/config/plugin/treesitter.lua deleted file mode 100644 index 88e08991..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/treesitter.lua +++ /dev/null @@ -1,133 +0,0 @@ -local configs = require "nvim-treesitter.configs" -local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move" - -configs.setup { - autotag = { - enable = true, - }, - - context_commenting = { - enable = true, - }, - - highlight = { - enable = true, - }, - - indent = { - disable = { "yaml" }, - enable = true, - }, - - matchup = { - enable = true, - }, - - textobjects = { - select = { - enable = true, - lookahead = true, - - keymaps = { - ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" }, - ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" }, - ["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" }, - ["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" }, - - ["a:"] = { query = "@property.outer", desc = "Select outer part of an object property" }, - ["i:"] = { query = "@property.inner", desc = "Select inner part of an object property" }, - ["l:"] = { query = "@property.lhs", desc = "Select left part of an object property" }, - ["r:"] = { query = "@property.rhs", desc = "Select right part of an object property" }, - - ["aa"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/argument" }, - ["ia"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/argument" }, - - ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" }, - ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" }, - - ["af"] = { query = "@call.outer", desc = "Select outer part of a function call" }, - ["if"] = { query = "@call.inner", desc = "Select inner part of a function call" }, - - ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" }, - ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" }, - - ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" }, - ["il"] = { query = "@loop.inner", desc = "Select inner part of a loop" }, - - ["am"] = { query = "@function.outer", desc = "Select outer part of a method/function definition" }, - ["im"] = { query = "@function.inner", desc = "Select inner part of a method/function definition" }, - }, - }, - }, - - swap = { - enable = true, - - swap_next = { - ["na"] = "@parameter.inner", -- swap parameters/argument with next - ["n:"] = "@property.outer", -- swap object property with next - ["nm"] = "@function.outer", -- swap function with next - }, - - swap_previous = { - ["pa"] = "@parameter.inner", -- swap parameters/argument with prev - ["p:"] = "@property.outer", -- swap object property with prev - ["pm"] = "@function.outer", -- swap function with previous - }, - }, - - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - - goto_next_start = { - ["]f"] = { query = "@call.outer", desc = "Next function call start" }, - ["]m"] = { query = "@function.outer", desc = "Next method/function def start" }, - ["]c"] = { query = "@class.outer", desc = "Next class start" }, - ["]i"] = { query = "@conditional.outer", desc = "Next conditional start" }, - ["]l"] = { query = "@loop.outer", desc = "Next loop start" }, - - ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, - ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, - }, - - goto_next_end = { - ["]F"] = { query = "@call.outer", desc = "Next function call end" }, - ["]M"] = { query = "@function.outer", desc = "Next method/function def end" }, - ["]C"] = { query = "@class.outer", desc = "Next class end" }, - ["]I"] = { query = "@conditional.outer", desc = "Next conditional end" }, - ["]L"] = { query = "@loop.outer", desc = "Next loop end" }, - }, - - goto_previous_start = { - ["[f"] = { query = "@call.outer", desc = "Prev function call start" }, - ["[m"] = { query = "@function.outer", desc = "Prev method/function def start" }, - ["[c"] = { query = "@class.outer", desc = "Prev class start" }, - ["[i"] = { query = "@conditional.outer", desc = "Prev conditional start" }, - ["[l"] = { query = "@loop.outer", desc = "Prev loop start" }, - }, - - goto_previous_end = { - ["[F"] = { query = "@call.outer", desc = "Prev function call end" }, - ["[M"] = { query = "@function.outer", desc = "Prev method/function def end" }, - ["[C"] = { query = "@class.outer", desc = "Prev class end" }, - ["[I"] = { query = "@conditional.outer", desc = "Prev conditional end" }, - ["[L"] = { query = "@loop.outer", desc = "Prev loop end" }, - }, - }, -} - -local set = vim.keymap.set - -set("n", "th", "TSHighlightCapturesUnderCursor") -set("n", "tp", "TSPlaygroundToggle") - --- vim way: ; goes to the direction you were moving. -set({ "n", "o", "x" }, ";", ts_repeat_move.repeat_last_move) -set({ "n", "o", "x" }, ",", ts_repeat_move.repeat_last_move_opposite) - --- Optionally, make builtin f, F, t, T also repeatable with ; and , -set({ "n", "o", "x" }, "f", ts_repeat_move.builtin_f) -set({ "n", "o", "x" }, "F", ts_repeat_move.builtin_F) -set({ "n", "o", "x" }, "t", ts_repeat_move.builtin_t) -set({ "n", "o", "x" }, "T", ts_repeat_move.builtin_T) diff --git a/modules/home-manager/coding/neovim/config/plugin/undotree.lua b/modules/home-manager/coding/neovim/config/plugin/undotree.lua deleted file mode 100644 index b6b9276a..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/undotree.lua +++ /dev/null @@ -1 +0,0 @@ -vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) diff --git a/modules/home-manager/coding/neovim/config/plugin/vim-test.lua b/modules/home-manager/coding/neovim/config/plugin/vim-test.lua deleted file mode 100644 index 26aaf70f..00000000 --- a/modules/home-manager/coding/neovim/config/plugin/vim-test.lua +++ /dev/null @@ -1,16 +0,0 @@ -local set = vim.keymap.set - -local options = { - silent = true, -} - -set("n", "tf", ":TestFile", options) -set("n", "tg", ":TestVisit", options) -set("n", "tl", ":TestLast", options) -set("n", "tn", ":TestNearest", options) -set("n", "ts", ":TestSuite", options) - -vim.cmd [[ - let test#php#phpunit#options = '--colors=always --testdox' - let g:test#strategy = 'vimux' -]] diff --git a/modules/home-manager/coding/neovim/config/spell/en.utf-8.add b/modules/home-manager/coding/neovim/config/spell/en.utf-8.add deleted file mode 100644 index 6d36619c..00000000 --- a/modules/home-manager/coding/neovim/config/spell/en.utf-8.add +++ /dev/null @@ -1,132 +0,0 @@ -ANP -AWS -Acquia -Ansible -Appnovation -Architected -BAU -Behat -Bitbucket -Bluecheese -BrumPHP -CMSes -CTI -Cachix -Centarro -CiviCRM -Configs -D7 -DDEV -DevOps -DigitalOcean -Drupal -Drupal's -DrupalCamp -DrupalCon -DrupalEasy -Drupaler -Drush -FPM -FTSE -GitLab -Gitea -HDN -HashiCorp -Hetzner -Homelab -Immich -InvalidArgumentException -Inviqa -JSON -Jellyfin -Kickstart -Lando -Laravel -Linode -Magento -MariaDB -Microserve -Mischa -MySQL -NGINX -Neovim -Netlify -Nginx -NixOS -NodeInterface -Nomensa -OpenID -OpenTofu -PDOException -PHPDoc -PHPStan -PHPUnit -Packagist -PhpStorm -PostBuilder -PostNodeRepository -Pulumi -S3 -SHA -SQLSTATE -SQLite -SSO -Sculpin -Silex -SimpleTest -Sylius -Symfony -TODO -TermInterface -Themers -Traefik -TypeScript -Ubercart -VSCode -Vaultwarden -WCAG -WSL -Wellbeing -ZSH -Zellij -Zettelkasten -architected -assertContainsOnlyInstancesOf -assertSame -bootcamp -contrib -devenv -dotfiles -drupal -eCommerce -foreach -getPost -ghostty -hotfix -isNotPublished -isPublished -localhost -macOS -mentees -nixpkgs -nodeStorage -opdavies -osCommerce -param -reStructuredText -rebase -rebasing -roadmapping -rst2pdf -rwxrob -src -stylesheet -stylesheets -testbot -tmux -url -vhost -wildcard -worktree -worktrees -www diff --git a/modules/home-manager/coding/neovim/config/stylua.toml b/modules/home-manager/coding/neovim/config/stylua.toml deleted file mode 100644 index 2c7fb8a9..00000000 --- a/modules/home-manager/coding/neovim/config/stylua.toml +++ /dev/null @@ -1,8 +0,0 @@ -indent_type = "Spaces" -indent_width = 2 -line_endings = "Unix" -no_call_parentheses = true -quote_style = "AutoPreferDouble" - -[sort_requires] -enabled = true diff --git a/modules/home-manager/coding/neovim/default.nix b/modules/home-manager/coding/neovim/default.nix index eb4e5551..1f859a86 100644 --- a/modules/home-manager/coding/neovim/default.nix +++ b/modules/home-manager/coding/neovim/default.nix @@ -1,5 +1,6 @@ { config, + inputs, lib, pkgs, ... @@ -11,134 +12,60 @@ let cfg = config.coding.neovim; in { + imports = [ + inputs.nixvim.homeManagerModules.nixvim + ]; + options.coding.neovim.enable = mkEnableOption "Enable neovim"; config = mkIf cfg.enable { - programs.neovim = - let - php = pkgs.php82; - in - { + programs.nixvim = { + enable = true; + + # TODO: re-add DAP. + # TODO: re-add snippets. + # TODO: re-configure spell. + + viAlias = true; + vimAlias = true; + + imports = [ + ./keymaps.nix + ./options.nix + ./plugins/cmp.nix + ./plugins/conform.nix + ./plugins/fidget.nix + ./plugins/fugitive.nix + ./plugins/gitsigns.nix + ./plugins/harpoon.nix + ./plugins/lint.nix + ./plugins/lsp.nix + ./plugins/lualine.nix + ./plugins/luasnip.nix + ./plugins/mini.nix + ./plugins/oil.nix + ./plugins/phpactor.nix + ./plugins/refactoring.nix + ./plugins/telescope.nix + ./plugins/treesitter.nix + ./plugins/undotree.nix + ./plugins/vim-dadbod.nix + ./plugins/vim-highlightedyank.nix + ./plugins/vim-test.nix + ./plugins/web-devicons.nix + ]; + + colorschemes.catppuccin = { enable = true; - - plugins = with pkgs.vimPlugins; [ - comment-nvim - gitsigns-nvim - harpoon2 - mini-nvim - nvim-web-devicons - oil-nvim - phpactor - refactoring-nvim - undotree - vim-nix - - # Testing - vim-test - vimux - - # Git - vim-fugitive - - # Debugging - nvim-dap - nvim-dap-ui - nvim-dap-virtual-text - - # Treesitter - (pkgs.vimPlugins.nvim-treesitter.withPlugins ( - plugins: with plugins; [ - bash - comment - css - csv - dockerfile - gitattributes - gitignore - go - html - javascript - json - kdl - lua - luadoc - make - markdown - markdown_inline - nix - php - phpdoc - query - rst - scss - sql - terraform - twig - typescript - vim - vimdoc - vue - xml - yaml - ] - )) - nvim-treesitter-textobjects - - # LSP, linting and formatting - conform-nvim - lsp-status-nvim - nvim-lint - nvim-lspconfig - - # Completion - cmp-buffer - cmp-calc - cmp-cmdline - cmp-nvim-lsp - cmp-path - cmp-treesitter - cmp_luasnip - lspkind-nvim - nvim-cmp - - # Snippets - luasnip - - # Telescope - plenary-nvim - popup-nvim - telescope-frecency-nvim - telescope-fzf-native-nvim - telescope-live-grep-args-nvim - telescope-nvim - telescope-ui-select-nvim - - # Databases - vim-dadbod - vim-dadbod-ui - vim-dadbod-completion - - # Themes - catppuccin-nvim - ]; - - extraPackages = with pkgs; [ - ripgrep - ]; + settings.flavour = "mocha"; }; - xdg.configFile.nvim = { - source = ./config; - recursive = true; + extraPackages = with pkgs; [ + nixfmt-rfc-style + stylua + ]; + + globals.mapleader = " "; }; - - home.file.".markdownlint.yaml".text = '' - default: true - - line-length: false - - no-duplicate-heading: - siblings_only: true - ''; }; } diff --git a/modules/home-manager/coding/neovim/keymaps.nix b/modules/home-manager/coding/neovim/keymaps.nix new file mode 100644 index 00000000..a05cdb17 --- /dev/null +++ b/modules/home-manager/coding/neovim/keymaps.nix @@ -0,0 +1,62 @@ +{ + keymaps = [ + { + action = "A,"; + key = ",,"; + mode = "i"; + } + + { + action = "A;"; + key = ";;"; + mode = "i"; + } + + { + action = "lua vim.lsp.buf.format()"; + key = "f"; + } + + { + action = "\"+y"; + key = "y"; + mode = "x"; + } + + { + action = "@q"; + key = "Q"; + } + + { + action = "silent !tmux new-window tmux-sessionizer"; + key = ""; + } + + { + action = ":w"; + key = ""; + mode = ["i" "n"]; + } + + { + action = "tabnew"; + key = ""; + } + + { + action = "!composer install"; + key = "ci"; + } + + { + action = "edit composer.json"; + key = "ec"; + } + + { + action = "edit flake.nix"; + key = "ef"; + } + ]; +} diff --git a/modules/home-manager/coding/neovim/options.nix b/modules/home-manager/coding/neovim/options.nix new file mode 100644 index 00000000..f17e9410 --- /dev/null +++ b/modules/home-manager/coding/neovim/options.nix @@ -0,0 +1,25 @@ +{ + opts = { + expandtab = true; + exrc = true; + foldlevel = 1; + foldlevelstart = 99; + foldmethod = "indent"; + inccommand = "split"; + laststatus = 3; + list = true; + number = true; + relativenumber = true; + shiftwidth = 2; + smartindent = true; + softtabstop = 2; + splitbelow = true; + splitright = true; + swapfile = false; + syntax = "on"; + tabstop = 2; + termguicolors = true; + updatetime = 1000; + wrap = false; + }; +} diff --git a/modules/home-manager/coding/neovim/plugins/cmp.nix b/modules/home-manager/coding/neovim/plugins/cmp.nix new file mode 100644 index 00000000..1c31ec3f --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/cmp.nix @@ -0,0 +1,58 @@ +{ + plugins.cmp = { + enable = true; + + autoEnableSources = true; + + settings = { + mapping = { + "" = "cmp.mapping.close()"; + + "" = '' + cmp.mapping(function() + if ls.locally_jumpable(-1) then + ls.jump(-1) + end + end) + ''; + + "" = '' + cmp.mapping(function() + if ls.expand_or_locally_jumpable() then + ls.expand_or_jump() + end + end) + ''; + + "" = "cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select })"; + "" = "cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select })"; + + "" = "cmp.mapping.confirm({ select = true })"; + + "" = "nil"; + "" = "nil"; + "" = "nil"; + }; + + snippet.expand = '' + function(args) + require('luasnip').lsp_expand(args.body) + end + ''; + + sources = [ + { name = "nvim_lsp"; } + { name = "nvim_lua"; } + { + name = "luasnip"; + keyword_length = 2; + } + { + name = "buffer"; + keyword_length = 3; + } + { name = "calc"; } + ]; + }; + }; +} diff --git a/modules/home-manager/coding/neovim/plugins/conform.nix b/modules/home-manager/coding/neovim/plugins/conform.nix new file mode 100644 index 00000000..50dce5af --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/conform.nix @@ -0,0 +1,3 @@ +{ + plugins.conform-nvim.enable = true; +} diff --git a/modules/home-manager/coding/neovim/plugins/fidget.nix b/modules/home-manager/coding/neovim/plugins/fidget.nix new file mode 100644 index 00000000..b18a7175 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/fidget.nix @@ -0,0 +1,3 @@ +{ + plugins.fidget.enable = true; +} diff --git a/modules/home-manager/coding/neovim/plugins/fugitive.nix b/modules/home-manager/coding/neovim/plugins/fugitive.nix new file mode 100644 index 00000000..6fc46e10 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/fugitive.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: + +{ + plugins.fugitive.enable = true; + + keymaps = lib.mkIf config.plugins.fugitive.enable [ + { + key = "gc"; + action = "Git commitK"; + } + + { + # Open the ":Git" window in its own buffer, not a split. + key = "gs"; + action = "0Git"; + } + ]; +} diff --git a/modules/home-manager/coding/neovim/plugins/gitsigns.nix b/modules/home-manager/coding/neovim/plugins/gitsigns.nix new file mode 100644 index 00000000..7595d756 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/gitsigns.nix @@ -0,0 +1,45 @@ +{ config, lib, ... }: + +{ + plugins.gitsigns.enable = true; + + keymaps = lib.mkIf config.plugins.gitsigns.enable [ + { + action = "Gitsigns prev_hunk"; + key = "[h"; + } + + { + action = "Gitsigns next_hunk"; + key = "]h"; + } + + { + action = "Gitsigns reset_hunk"; + key = "hr"; + } + + { + action = "Gitsigns reset_buffer"; + key = "hR"; + } + + { + action = "Gitsigns stage_hunk"; + key = "hs"; + mode = ["n" "v"]; + } + + { + action = "Gitsigns stage_buffer"; + key = "hS"; + mode = "x"; + } + + { + action = "Gitsigns undo_stage_hunk"; + key = "hu"; + mode = "x"; + } + ]; +} diff --git a/modules/home-manager/coding/neovim/plugins/harpoon.nix b/modules/home-manager/coding/neovim/plugins/harpoon.nix new file mode 100644 index 00000000..95d59718 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/harpoon.nix @@ -0,0 +1,47 @@ +{ config, lib, ... }: + +let + leaderBinding = key: command: { + key = "${key}"; + action = "${command}"; + options.silent = true; + }; +in +{ + plugins.harpoon = { + enable = true; + enableTelescope = true; + }; + + keymaps = lib.mkIf config.plugins.harpoon.enable ( + [ + { + key = "a"; + action.__raw = "function() require'harpoon':list():add() end"; + } + + { + key = ""; + action.__raw = '' + function() + require 'harpoon'.ui:toggle_quick_menu(require'harpoon':list()) + end + ''; + } + ] + ++ (map + (num: leaderBinding "${toString num}" "lua require(\"harpoon\"):list():select(${toString num})") + [ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + ] + ) + ); +} diff --git a/modules/home-manager/coding/neovim/plugins/lint.nix b/modules/home-manager/coding/neovim/plugins/lint.nix new file mode 100644 index 00000000..ff65a0d2 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/lint.nix @@ -0,0 +1,3 @@ +{ + plugins.lint.enable = true; +} diff --git a/modules/home-manager/coding/neovim/plugins/lsp.nix b/modules/home-manager/coding/neovim/plugins/lsp.nix new file mode 100644 index 00000000..a4fd7750 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/lsp.nix @@ -0,0 +1,3 @@ +{ + plugins.lsp.enable = true; +} diff --git a/modules/home-manager/coding/neovim/plugins/lualine.nix b/modules/home-manager/coding/neovim/plugins/lualine.nix new file mode 100644 index 00000000..d8de83ad --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/lualine.nix @@ -0,0 +1,11 @@ +{ + plugins.lualine = { + enable = true; + + settings.options = { + component_separators = ""; + icons_enabled = false; + section_separators = ""; + }; + }; +} diff --git a/modules/home-manager/coding/neovim/plugins/luasnip.nix b/modules/home-manager/coding/neovim/plugins/luasnip.nix new file mode 100644 index 00000000..6dc508db --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/luasnip.nix @@ -0,0 +1,3 @@ +{ + plugins.luasnip.enable = true; +} diff --git a/modules/home-manager/coding/neovim/plugins/mini.nix b/modules/home-manager/coding/neovim/plugins/mini.nix new file mode 100644 index 00000000..6f05654d --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/mini.nix @@ -0,0 +1,15 @@ +{ + plugins.mini = { + enable = true; + + modules = { + ai = {}; + align = {}; + bracketed = {}; + move = {}; + operators = {}; + splitjoin = {}; + surround = {}; + }; + }; +} diff --git a/modules/home-manager/coding/neovim/plugins/oil.nix b/modules/home-manager/coding/neovim/plugins/oil.nix new file mode 100644 index 00000000..bf91a77f --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/oil.nix @@ -0,0 +1,20 @@ +{ config, lib, ... }: + +{ + plugins.oil = { + enable = true; + + settings = { + delete_to_trash = true; + + keymaps."-" = "actions.parent"; + + skip_confirm_for_simple_edits = true; + view_options.show_hidden = true; + }; + }; + + keymaps = lib.mkIf config.plugins.oil.enable [ + { action = "Oil"; key = "-"; } + ]; +} diff --git a/modules/home-manager/coding/neovim/plugins/phpactor.nix b/modules/home-manager/coding/neovim/plugins/phpactor.nix new file mode 100644 index 00000000..1c4f6387 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/phpactor.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: + +{ + extraPlugins = with pkgs.vimPlugins; [ phpactor ]; + + keymaps = [ + { + key = "pm"; + action = "PhpactorContextMenu"; + } + + { + key = "pn"; + action = "PhpactorClassNew"; + } + ]; +} diff --git a/modules/home-manager/coding/neovim/plugins/refactoring.nix b/modules/home-manager/coding/neovim/plugins/refactoring.nix new file mode 100644 index 00000000..e696e538 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/refactoring.nix @@ -0,0 +1,47 @@ +{ config, lib, ... }: + +{ + plugins.refactoring = { + enable = true; + enableTelescope = true; + }; + + keymaps = + lib.mkIf config.plugins.refactoring.enable ([ + { + key = "ri"; + action = "Refactor inline_var"; + mode = "n"; + } + + { + key = "re"; + action = "Refactor extract"; + mode = "x"; + } + + { + key = "ri"; + action = "Refactor inline_var"; + mode = "x"; + } + + { + key = "rv"; + action = "Refactor extract_var"; + mode = "x"; + } + ] + ++ lib.optionals (config.plugins.refactoring.enable && config.plugins.refactoring.enableTelescope) [ + { + mode = "n"; + key = "rR"; + action.__raw = '' + function() + require('telescope').extensions.refactoring.refactors() + end + ''; + options.silent = true; + } + ]); +} diff --git a/modules/home-manager/coding/neovim/plugins/telescope.nix b/modules/home-manager/coding/neovim/plugins/telescope.nix new file mode 100644 index 00000000..8c376561 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/telescope.nix @@ -0,0 +1,28 @@ +{ + plugins.telescope = { + enable = true; + + extensions = { + live-grep-args.enable = true; + fzf-native.enable = true; + ui-select.enable = true; + }; + + keymaps = { + "fb" = "buffers"; + "fd" = "find_files"; + "fg" = "live_grep"; + + "gw" = { + action = "grep_string"; + mode = [ + "n" + "v" + ]; + }; + }; + + settings.defaults.layout_config.prompt_position = "top"; + }; +} + diff --git a/modules/home-manager/coding/neovim/plugins/treesitter.nix b/modules/home-manager/coding/neovim/plugins/treesitter.nix new file mode 100644 index 00000000..fd6647a1 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/treesitter.nix @@ -0,0 +1,47 @@ +{ pkgs, ... }: + +{ + plugins = { + treesitter = { + enable = true; + + grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [ + bash + comment + css + csv + dockerfile + gitattributes + gitignore + go + html + javascript + json + kdl + lua + luadoc + make + markdown + markdown_inline + nix + php + phpdoc + query + rst + scss + sql + terraform + twig + typescript + vim + vimdoc + vue + xml + yaml + ]; + }; + + treesitter-textobjects.enable = true; + }; +} + diff --git a/modules/home-manager/coding/neovim/plugins/undotree.nix b/modules/home-manager/coding/neovim/plugins/undotree.nix new file mode 100644 index 00000000..4a262eb9 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/undotree.nix @@ -0,0 +1,9 @@ +{ config, lib, ... }: + +{ + plugins.undotree.enable = true; + + keymaps = lib.mkIf config.plugins.undotree.enable [ + { action = "UndotreeToggle"; key = "u"; } + ]; +} diff --git a/modules/home-manager/coding/neovim/plugins/vim-dadbod.nix b/modules/home-manager/coding/neovim/plugins/vim-dadbod.nix new file mode 100644 index 00000000..13168c91 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/vim-dadbod.nix @@ -0,0 +1,7 @@ +{ + plugins = { + vim-dadbod.enable = true; + vim-dadbod-completion.enable = true; + vim-dadbod-ui.enable = true; + }; +} diff --git a/modules/home-manager/coding/neovim/plugins/vim-highlightedyank.nix b/modules/home-manager/coding/neovim/plugins/vim-highlightedyank.nix new file mode 100644 index 00000000..2ecb38f3 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/vim-highlightedyank.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: + +{ + extraPlugins = with pkgs.vimPlugins; [ vim-highlightedyank ]; + + extraConfigVim = '' + let g:highlightedyank_highlight_duration = 100 + ''; +} diff --git a/modules/home-manager/coding/neovim/plugins/vim-test.nix b/modules/home-manager/coding/neovim/plugins/vim-test.nix new file mode 100644 index 00000000..e6e443d4 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/vim-test.nix @@ -0,0 +1,11 @@ +{ config, lib, ... }: + +{ + plugins.vim-test.enable = true; + + keymaps = lib.mkIf config.plugins.vim-test.enable [ + { key = "tf"; action = "TestFile"; } + { key = "tl"; action = "TestLast"; } + { key = "tn"; action = "TestNearest"; } + ]; +} diff --git a/modules/home-manager/coding/neovim/plugins/web-devicons.nix b/modules/home-manager/coding/neovim/plugins/web-devicons.nix new file mode 100644 index 00000000..927f85e1 --- /dev/null +++ b/modules/home-manager/coding/neovim/plugins/web-devicons.nix @@ -0,0 +1,3 @@ +{ + plugins.web-devicons.enable = false; +}