From 6c2813f2e494b00d7ac54e853f37c421003be172 Mon Sep 17 00:00:00 2001 From: Tomodachi94 Date: Wed, 19 Jun 2024 21:07:38 -0700 Subject: [PATCH] wip --- home/common/nvim-new/default.nix | 9 +++ .../lua/tomodachi94/plugins/nerdtree.lua | 4 ++ .../lua/tomodachi94/plugins/nvim-cmp.lua | 59 +++++++++++++++++++ .../lua/tomodachi94/plugins/telescope.lua | 7 +++ .../lua/tomodachi94/plugins/trouble.lua | 3 + home/common/nvim-new/plugins/completion.nix | 45 ++++++++++++++ home/common/nvim-new/plugins/default.nix | 6 ++ home/common/nvim-new/plugins/filetree.nix | 29 +++++++++ home/common/nvim-new/plugins/git.nix | 29 +++++++++ home/common/nvim-new/plugins/insert-mode.nix | 1 + home/common/nvim-new/plugins/lsp/default.nix | 1 + home/common/nvim-new/plugins/lsp/none-ls.nix | 1 + home/common/nvim-new/plugins/movement.nix | 1 + .../nvim-new/plugins/per-language/elixir.nix | 1 + .../plugins/per-language/mediawiki.nix | 1 + home/common/nvim-new/plugins/pickers.nix | 37 ++++++++++++ home/common/nvim-new/plugins/snippets.nix | 1 + .../nvim/lua/tomodachi94/plugins/tools.lua | 54 ----------------- 18 files changed, 235 insertions(+), 54 deletions(-) create mode 100644 home/common/nvim-new/default.nix create mode 100644 home/common/nvim-new/lua/tomodachi94/plugins/nerdtree.lua create mode 100644 home/common/nvim-new/lua/tomodachi94/plugins/nvim-cmp.lua create mode 100644 home/common/nvim-new/lua/tomodachi94/plugins/telescope.lua create mode 100644 home/common/nvim-new/lua/tomodachi94/plugins/trouble.lua create mode 100644 home/common/nvim-new/plugins/completion.nix create mode 100644 home/common/nvim-new/plugins/default.nix create mode 100644 home/common/nvim-new/plugins/filetree.nix create mode 100644 home/common/nvim-new/plugins/git.nix create mode 100644 home/common/nvim-new/plugins/insert-mode.nix create mode 100644 home/common/nvim-new/plugins/lsp/default.nix create mode 100644 home/common/nvim-new/plugins/lsp/none-ls.nix create mode 100644 home/common/nvim-new/plugins/movement.nix create mode 100644 home/common/nvim-new/plugins/per-language/elixir.nix create mode 100644 home/common/nvim-new/plugins/per-language/mediawiki.nix create mode 100644 home/common/nvim-new/plugins/pickers.nix create mode 100644 home/common/nvim-new/plugins/snippets.nix diff --git a/home/common/nvim-new/default.nix b/home/common/nvim-new/default.nix new file mode 100644 index 0000000..a8ec8fc --- /dev/null +++ b/home/common/nvim-new/default.nix @@ -0,0 +1,9 @@ +{ + imports = [ + ./plugins + ]; + + programs.neovim = { + enable = true; + }; +} diff --git a/home/common/nvim-new/lua/tomodachi94/plugins/nerdtree.lua b/home/common/nvim-new/lua/tomodachi94/plugins/nerdtree.lua new file mode 100644 index 0000000..d022357 --- /dev/null +++ b/home/common/nvim-new/lua/tomodachi94/plugins/nerdtree.lua @@ -0,0 +1,4 @@ +return function() + vim.g.NERDTreeMinimalUI = 1 + vim.keymap.set("n", "n", ":NERDTree") +end diff --git a/home/common/nvim-new/lua/tomodachi94/plugins/nvim-cmp.lua b/home/common/nvim-new/lua/tomodachi94/plugins/nvim-cmp.lua new file mode 100644 index 0000000..1c08f34 --- /dev/null +++ b/home/common/nvim-new/lua/tomodachi94/plugins/nvim-cmp.lua @@ -0,0 +1,59 @@ +return function() + -- Set up nvim-cmp. + local cmp = require("cmp") + local lspkind = require("lspkind") + + vim.opt.completeopt = { "menu", "menuone", "noselect" } + + cmp.setup { + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert { + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm { select = true }, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }, + formatting = { + format = lspkind.cmp_format(), + }, + sources = cmp.config.sources { + { name = "nvim_lsp" }, + { name = "luasnip" }, -- For luasnip users. + { name = "buffer" }, + { name = "git" }, + }, + } + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + + -- Set up lspconfig. + local capabilities = require("cmp_nvim_lsp").default_capabilities() + require("lspconfig")["lua_ls"].setup { + capabilities = capabilities, + } +end diff --git a/home/common/nvim-new/lua/tomodachi94/plugins/telescope.lua b/home/common/nvim-new/lua/tomodachi94/plugins/telescope.lua new file mode 100644 index 0000000..f87148c --- /dev/null +++ b/home/common/nvim-new/lua/tomodachi94/plugins/telescope.lua @@ -0,0 +1,7 @@ +return function() + local builtin = require("telescope.builtin") + vim.keymap.set("n", "ff", builtin.find_files, {}) + vim.keymap.set("n", "fg", builtin.live_grep, {}) + vim.keymap.set("n", "fr", builtin.lsp_references, {}) + vim.keymap.set("n", "fs", builtin.lsp_symbols, {}) +end diff --git a/home/common/nvim-new/lua/tomodachi94/plugins/trouble.lua b/home/common/nvim-new/lua/tomodachi94/plugins/trouble.lua new file mode 100644 index 0000000..13f6906 --- /dev/null +++ b/home/common/nvim-new/lua/tomodachi94/plugins/trouble.lua @@ -0,0 +1,3 @@ +return function() + require("trouble").setup() +end diff --git a/home/common/nvim-new/plugins/completion.nix b/home/common/nvim-new/plugins/completion.nix new file mode 100644 index 0000000..5f5d8d3 --- /dev/null +++ b/home/common/nvim-new/plugins/completion.nix @@ -0,0 +1,45 @@ +{ pkgs, ... }: +{ + programs.neovim.plugins = [ + { + plugin = pkgs.vimPlugins.nvim-cmp; + config = '' + require("lz.n").load { + "nvim-cmp", + event = "InsertEnter", + after = require("tomodachi94.plugins.nvim-cmp"), + } + ''; + type = "lua"; + optional = true; + } + { + plugin = pkgs.vimPlugins.cmp-buffer; + optional = true; + } + { + plugin = pkgs.vimPlugins.cmp-path; + optional = true; + } + { + plugin = pkgs.vimPlugins.cmp-nvim-lsp; + optional = true; + } + { + plugin = pkgs.vimPlugins.cmp-buffer; + optional = true; + } + { + plugin = pkgs.vimPlugins.cmp_luasnip; + optional = true; + } + { + plugin = pkgs.vimPlugins.cmp-git; + optional = true; + } + { + plugin = pkgs.vimPlugins.lspkind-nvim; + optional = true; + } + ]; +} diff --git a/home/common/nvim-new/plugins/default.nix b/home/common/nvim-new/plugins/default.nix new file mode 100644 index 0000000..37668cd --- /dev/null +++ b/home/common/nvim-new/plugins/default.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +{ + programs.neovim.plugins = [ + pkgs.vimPlugins.lz-n + ]; +} diff --git a/home/common/nvim-new/plugins/filetree.nix b/home/common/nvim-new/plugins/filetree.nix new file mode 100644 index 0000000..d946d4b --- /dev/null +++ b/home/common/nvim-new/plugins/filetree.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: +{ + programs.neovim.plugins = [ + { + plugin = pkgs.vimPlugins.nerdtree; + config = '' + require("lz.n").load { + "nerdtree", + cmd = { + "NERDTree", + "NERDTreeVCS", + "NERDTreeFromBookmark", + "NERDTreeToggle", + "NERDTreeToggleVCS", + "NERDTreeFocus", + "NERDTreeMirror", + "NERDTreeClose", + "NERDTreeFind", + "NERDTreeCWD", + "NERDTreeRefreshRoot", + }, + after = require("tomodachi94.plugins.nerdtree"), + } + ''; + type = "lua"; + optional = true; + } + ]; +} diff --git a/home/common/nvim-new/plugins/git.nix b/home/common/nvim-new/plugins/git.nix new file mode 100644 index 0000000..7a9434b --- /dev/null +++ b/home/common/nvim-new/plugins/git.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: +{ + programs.neovim.plugins = [ + { + plugin = pkgs.vimPlugins.vim-fugitive; + config = '' + require("lz.n").load { + "vim-fugitive", + cmd = { + "Gedit", + "Gdiffsplit", + "Gread", + "Gwrite", + "Ggrep", + "Glgrep", + "GMove", + "GRename", + "GDelete", + "GBrowse", + "G", + "Git", + }, + } + ''; + type = "lua"; + optional = true; + } + ]; +} diff --git a/home/common/nvim-new/plugins/insert-mode.nix b/home/common/nvim-new/plugins/insert-mode.nix new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/common/nvim-new/plugins/insert-mode.nix @@ -0,0 +1 @@ + diff --git a/home/common/nvim-new/plugins/lsp/default.nix b/home/common/nvim-new/plugins/lsp/default.nix new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/common/nvim-new/plugins/lsp/default.nix @@ -0,0 +1 @@ + diff --git a/home/common/nvim-new/plugins/lsp/none-ls.nix b/home/common/nvim-new/plugins/lsp/none-ls.nix new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/common/nvim-new/plugins/lsp/none-ls.nix @@ -0,0 +1 @@ + diff --git a/home/common/nvim-new/plugins/movement.nix b/home/common/nvim-new/plugins/movement.nix new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/common/nvim-new/plugins/movement.nix @@ -0,0 +1 @@ + diff --git a/home/common/nvim-new/plugins/per-language/elixir.nix b/home/common/nvim-new/plugins/per-language/elixir.nix new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/common/nvim-new/plugins/per-language/elixir.nix @@ -0,0 +1 @@ + diff --git a/home/common/nvim-new/plugins/per-language/mediawiki.nix b/home/common/nvim-new/plugins/per-language/mediawiki.nix new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/common/nvim-new/plugins/per-language/mediawiki.nix @@ -0,0 +1 @@ + diff --git a/home/common/nvim-new/plugins/pickers.nix b/home/common/nvim-new/plugins/pickers.nix new file mode 100644 index 0000000..0f2ba72 --- /dev/null +++ b/home/common/nvim-new/plugins/pickers.nix @@ -0,0 +1,37 @@ +{ pkgs, tomolib, ... }: +{ + programs.neovim.plugins = [ + { + plugin = pkgs.vimPlugins.telescope-nvim; + config = '' + require("lz.n").load { + "telescope", + cmd = "Telescope", + } + ''; + type = "lua"; + optional = true; + } + { + plugin = pkgs.vimPlugins.trouble-nvim; + config = '' + require("lz.n").load { + "trouble", + cmd = { + "Trouble", + "TroubleClose", + "TroubleToggle", + "TroubleRefresh", + }, + after = function() + require("trouble").setup() + end, + } + ''; + type = "lua"; + optional = true; + } + ]; +} + + diff --git a/home/common/nvim-new/plugins/snippets.nix b/home/common/nvim-new/plugins/snippets.nix new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/home/common/nvim-new/plugins/snippets.nix @@ -0,0 +1 @@ + diff --git a/home/common/nvim/lua/tomodachi94/plugins/tools.lua b/home/common/nvim/lua/tomodachi94/plugins/tools.lua index 7e76d9c..79b2f7b 100644 --- a/home/common/nvim/lua/tomodachi94/plugins/tools.lua +++ b/home/common/nvim/lua/tomodachi94/plugins/tools.lua @@ -1,47 +1,3 @@ -local M = { - "tpope/vim-fugitive", - lazy = true, - cmd = { - "Gedit", - "Gdiffsplit", - "Gread", - "Gwrite", - "Ggrep", - "Glgrep", - "GMove", - "GRename", - "GDelete", - "GBrowse", - "G", - "Git", - }, - config = false, - dependencies = { "tpope/vim-rhubarb" }, -} - -local N = { - "preservim/nerdtree", - lazy = true, - cmd = { - "NERDTree", - "NERDTreeVCS", - "NERDTreeFromBookmark", - "NERDTreeToggle", - "NERDTreeToggleVCS", - "NERDTreeFocus", - "NERDTreeMirror", - "NERDTreeClose", - "NERDTreeFind", - "NERDTreeCWD", - "NERDTreeRefreshRoot", - }, -} - -function N.config() - vim.g.NERDTreeMinimalUI = 1 - vim.keymap.set("n", "n", ":NERDTree") -end - local O = { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" }, @@ -65,14 +21,4 @@ end local P = { "liuchengxu/vim-which-key", lazy = true, cmd = "WhichKey" } -local Q = { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons", "https://github.com/folke/lsp-colors.nvim" }, - cmd = { "Trouble", "TroubleClose", "TroubleToggle", "TroubleRefresh" }, -} - -function Q.config() - require("trouble").setup {} -end - return { M, N, O, P, Q }