diff --git a/home/programs/neovim/default.nix b/home/programs/neovim/default.nix index 9c34efb..64a8d93 100644 --- a/home/programs/neovim/default.nix +++ b/home/programs/neovim/default.nix @@ -1,6 +1,18 @@ { pkgs, config, ... }: -{ +let + obsidian-nvim = pkgs.vimUtils.buildVimPlugin { + pname = "obsidian.nvim"; + version = "v3.5.1"; + src = pkgs.fetchFromGitHub { + owner = "epwalsh"; + repo = "obsidian.nvim"; + rev = "4eb44381811ab6af67b9f9fe3117616afbe1e118"; + sha256 = "sha256-/zj12pwppb1RGi3EovXla6Ahzkoxh3qhxQFOfnfPwac="; + }; + meta.homepage = "https://github.com/epwalsh/obsidian.nvim"; + }; +in { home.sessionVariables = { EDITOR = "nvim"; }; programs.neovim = { @@ -9,14 +21,25 @@ withPython3 = true; plugins = with pkgs.vimPlugins; [ + # Plugin-Manager lazy-nvim + # Theme catppuccin-nvim + + # Obsidian + obsidian-nvim + + plenary-nvim + telescope-nvim + + nvim-cmp + + nvim-treesitter.withAllGrammars ]; extraLuaConfig = '' vim.g.mapleader = " " - require("plugins") require("lazy").setup({ spec = { -- Import plugins from lua/plugins @@ -33,7 +56,7 @@ pkgs.vimUtils.packDir config.programs.neovim.finalPackage.passthru.packpathDirs }/pack/myNeovimPackages/start", - patterns = {"folke", "catppuccin"}, + patterns = {"folke", "catppuccin", "epwalsh"}, }, install = { -- Safeguard in case we forget to install a plugin with Nix diff --git a/home/programs/neovim/lua/plugins/colorscheme.lua b/home/programs/neovim/lua/plugins/colorscheme.lua index 0443e8d..dec75b9 100644 --- a/home/programs/neovim/lua/plugins/colorscheme.lua +++ b/home/programs/neovim/lua/plugins/colorscheme.lua @@ -8,6 +8,7 @@ return { vim.cmd.colorscheme("catppuccin") end, opts = { + flavor = "mocha", integrations = { nvimtree = true, dashboard = true, diff --git a/home/programs/neovim/lua/plugins/nvim-cmp.lua b/home/programs/neovim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..b120e8e --- /dev/null +++ b/home/programs/neovim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,77 @@ +return { + -- auto completion + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + "hrsh7th/cmp-nvim-lsp", + "L3MON4D3/LuaSnip", -- snippet engine + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + "PaterJason/cmp-conjure", -- nvim-cmp source for conjure. + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + + -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + completion = { + completeopt = "menu,menuone,noinsert", + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), -- Up + [""] = cmp.mapping.scroll_docs(4), -- Down + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close completion window + [""] = cmp.mapping.confirm({ select = false }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + { name = "buffer" }, + { name = "conjure" }, + }), + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + -- configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + end, + }, +} + diff --git a/home/programs/neovim/lua/plugins/obsidian.lua b/home/programs/neovim/lua/plugins/obsidian.lua new file mode 100644 index 0000000..86c749b --- /dev/null +++ b/home/programs/neovim/lua/plugins/obsidian.lua @@ -0,0 +1,36 @@ +return { + { + "epwalsh/obsidian.nvim", + lazy = true, + event = { + "BufReadPre " .. vim.fn.expand("~") .. "/Notes/**.md", + "BufNewFile " .. vim.fn.expand("~") .. "/Notes/**.md", + }, + dependencies = { + "nvim-lua/plenary.nvim", + "hrsh7th/nvim-cmp", + "nvim-telescope/telescope.nvim", + "nvim-treesitter", + }, + config = function() + vim.opt.conceallevel = 2 + require("obsidian").setup({ + workspaces = { + { + name = "personal", + path = "~/Notes/personal", + }, + { + name = "work", + path = "~/Notes/work", + }, + { + name = "studies", + path = "~/Notes/studies", + }, + }, + }) + end, + }, +} + diff --git a/home/programs/neovim/lua/plugins/tools.lua b/home/programs/neovim/lua/plugins/tools.lua new file mode 100644 index 0000000..6c04134 --- /dev/null +++ b/home/programs/neovim/lua/plugins/tools.lua @@ -0,0 +1,20 @@ +return { + { "nvim-lua/plenary.nvim" }, + { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("telescope").setup({}) + end, + }, + { + "nvim-telescope/telescope-fzf-native.nvim", + config = function() + require("telescope").setup({}) + -- To get fzf loaded and working with telescope, you need to call + -- load_extension, somewhere after setup function: + require("telescope").load_extension("fzf") + end, + }, +} + diff --git a/home/programs/neovim/lua/plugins/treesitter.lua b/home/programs/neovim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..9190496 --- /dev/null +++ b/home/programs/neovim/lua/plugins/treesitter.lua @@ -0,0 +1,56 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local treesitter = require("nvim-treesitter.configs") + + treesitter.setup({ + highlight = { + enable = true, + disable = { "latex" }, + additional_vim_regex_highlighting = { "latex", "markdown" }, + }, + indent = { enable = true }, + }) + end, + dependencies = { + "HiPhish/rainbow-delimiters", + config = function() + -- This module contains a number of default definitions + local rainbow_delimiters = require("rainbow-delimiters") + + vim.g.rainbow_delimiters = { + strategy = { + [""] = rainbow_delimiters.strategy["global"], + vim = rainbow_delimiters.strategy["local"], + }, + query = { + [""] = "rainbow-delimiters", + lua = "rainbow-blocks", + }, + priority = { + [""] = 110, + lua = 210, + }, + highlight = { + "RainbowDelimiterRed", + "RainbowDelimiterYellow", + "RainbowDelimiterBlue", + "RainbowDelimiterOrange", + "RainbowDelimiterGreen", + "RainbowDelimiterViolet", + "RainbowDelimiterCyan", + }, + } + end, + }, + }, + { + "nvim-treesitter/nvim-treesitter-textobjects", + dependencies = { + "nvim-treesitter/nvim-treesitter", + }, + }, +} +