From 76f234e538ee38534deb43b12f561ec1a93589cc Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sun, 9 Jul 2023 02:29:29 +0100 Subject: [PATCH] feat: add Neovim config --- home/apps/nvim.nix | 16 ++- home/apps/nvim/.neoconf.json | 15 +++ home/apps/nvim/init.lua | 2 + home/apps/nvim/lazy-lock.json | 62 ++++++++++++ home/apps/nvim/lua/config/autocmds.lua | 3 + home/apps/nvim/lua/config/keymaps.lua | 52 ++++++++++ home/apps/nvim/lua/config/lazy.lua | 38 ++++++++ home/apps/nvim/lua/config/options.lua | 10 ++ home/apps/nvim/lua/plugins/colourscheme.lua | 25 +++++ home/apps/nvim/lua/plugins/disabled.lua | 26 +++++ home/apps/nvim/lua/plugins/discord.lua | 8 ++ home/apps/nvim/lua/plugins/editor.lua | 66 +++++++++++++ home/apps/nvim/lua/plugins/lsp.lua | 102 ++++++++++++++++++++ home/apps/nvim/stylua.toml | 3 + 14 files changed, 425 insertions(+), 3 deletions(-) create mode 100644 home/apps/nvim/.neoconf.json create mode 100644 home/apps/nvim/init.lua create mode 100644 home/apps/nvim/lazy-lock.json create mode 100644 home/apps/nvim/lua/config/autocmds.lua create mode 100644 home/apps/nvim/lua/config/keymaps.lua create mode 100644 home/apps/nvim/lua/config/lazy.lua create mode 100644 home/apps/nvim/lua/config/options.lua create mode 100644 home/apps/nvim/lua/plugins/colourscheme.lua create mode 100644 home/apps/nvim/lua/plugins/disabled.lua create mode 100644 home/apps/nvim/lua/plugins/discord.lua create mode 100644 home/apps/nvim/lua/plugins/editor.lua create mode 100644 home/apps/nvim/lua/plugins/lsp.lua create mode 100644 home/apps/nvim/stylua.toml diff --git a/home/apps/nvim.nix b/home/apps/nvim.nix index 8f337a7..678de14 100644 --- a/home/apps/nvim.nix +++ b/home/apps/nvim.nix @@ -1,4 +1,14 @@ -{pkgs, ...}: { +{ + config, + pkgs, + flakePath, + ... +}: let + symlink = fileName: {recursive ? false}: { + source = config.lib.file.mkOutOfStoreSymlink "${flakePath}/${fileName}"; + inherit recursive; + }; +in { programs.neovim = { enable = true; vimAlias = true; @@ -22,7 +32,7 @@ SUDO_EDITOR = "nvim"; }; - programs.fish.shellAbbrs = { - "lvim" = "NVIM_APPNAME=lazyvim nvim"; + xdg.configFile = { + "nvim" = symlink "home/apps/nvim" {recursive = true;}; }; } diff --git a/home/apps/nvim/.neoconf.json b/home/apps/nvim/.neoconf.json new file mode 100644 index 0000000..7c48087 --- /dev/null +++ b/home/apps/nvim/.neoconf.json @@ -0,0 +1,15 @@ +{ + "neodev": { + "library": { + "enabled": true, + "plugins": true + } + }, + "neoconf": { + "plugins": { + "lua_ls": { + "enabled": true + } + } + } +} diff --git a/home/apps/nvim/init.lua b/home/apps/nvim/init.lua new file mode 100644 index 0000000..2514f9e --- /dev/null +++ b/home/apps/nvim/init.lua @@ -0,0 +1,2 @@ +-- bootstrap lazy.nvim, LazyVim and your plugins +require("config.lazy") diff --git a/home/apps/nvim/lazy-lock.json b/home/apps/nvim/lazy-lock.json new file mode 100644 index 0000000..4eb3913 --- /dev/null +++ b/home/apps/nvim/lazy-lock.json @@ -0,0 +1,62 @@ +{ + "LazyVim": { "branch": "main", "commit": "abea2807ce13c994d5697f0ff19d80f85f678b1b" }, + "LuaSnip": { "branch": "master", "commit": "a658ae2906344a1d2b9c507738e585cf68e685c7" }, + "SchemaStore.nvim": { "branch": "main", "commit": "78c53f2ce05b7209bf5e2e2b2e25c72a3c1444b2" }, + "alpha-nvim": { "branch": "main", "commit": "9e33db324b8bb7a147bce9ea5496686ee859461d" }, + "catppuccin": { "branch": "main", "commit": "278bfeb61bd627dc2a8885180a0441a1ebe65a41" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "crates.nvim": { "branch": "main", "commit": "4ce7c51b881e58f1e2f8f437f30e4e583cbac319" }, + "dressing.nvim": { "branch": "master", "commit": "e6eff7a5a950a853c3903d906dbcea03f778db5f" }, + "friendly-snippets": { "branch": "main", "commit": "7f6681b7d1eebba024f0caf6576fc1e94578b9cc" }, + "gitsigns.nvim": { "branch": "main", "commit": "dc2962f7fce953a2a98e7c6d3d7fc4c1d1f66758" }, + "indent-blankline.nvim": { "branch": "master", "commit": "4541d690816cb99a7fc248f1486aa87f3abce91c" }, + "lazy.nvim": { "branch": "main", "commit": "5af331ea65418dc9361769891921fdee4bcc837a" }, + "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "82685fdd0f67a694b244cb058b83761f54664d68" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "e4d56b400e9757b1dc77d620fd3069396e92d5fc" }, + "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, + "mini.ai": { "branch": "main", "commit": "5218ea75e635df78a807bc9d5a7162594fb76d02" }, + "mini.comment": { "branch": "main", "commit": "877acea5b2a32ff55f808fc0ebe9aa898648318c" }, + "mini.indentscope": { "branch": "main", "commit": "f60e9b51a6214c73a170ffc5445ce91560981031" }, + "mini.pairs": { "branch": "main", "commit": "dfa9f6e2576bb8853be277d96b735af59d9be7c2" }, + "mini.surround": { "branch": "main", "commit": "9d1956b576d7051da3a483b251dfc778121c60db" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "7f6fa04dbd8e8c79d1af33bc90e856b65d8641da" }, + "neoconf.nvim": { "branch": "main", "commit": "08f146d53e075055500dca35e93281faff95716b" }, + "neodev.nvim": { "branch": "main", "commit": "0705c72c281626f45c78d0916151d3e2bfb53fae" }, + "neotest-rust": { "branch": "main", "commit": "6dce8963e5395adf079bf22e931dfce65d3fed25" }, + "noice.nvim": { "branch": "main", "commit": "6c87c1d11c38180fb72bf8f45518a0a3e081afc1" }, + "nui.nvim": { "branch": "main", "commit": "d146966a423e60699b084eeb28489fe3b6427599" }, + "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, + "nvim-cmp": { "branch": "main", "commit": "2743dd989e9b932e1b4813a4927d7b84272a14e2" }, + "nvim-dap": { "branch": "master", "commit": "bb1ddce6cd951ef3c1319e4fd8596131113163c3" }, + "nvim-dap-ui": { "branch": "master", "commit": "c020f660b02772f9f3d11f599fefad3268628a9e" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "57f1dbd0458dd84a286b27768c142e1567f3ce3b" }, + "nvim-lspconfig": { "branch": "master", "commit": "deade69789089c3da15237697156334fb3e943f0" }, + "nvim-navic": { "branch": "master", "commit": "6e8850a524307814decc1b195a2c8a51482a9886" }, + "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" }, + "nvim-spectre": { "branch": "master", "commit": "dc3f0bd41e09148924ef04a4746cb708539d08db" }, + "nvim-treesitter": { "branch": "master", "commit": "d9104a1d10023ed9e7eacf68639ad887425246eb" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "52f1f3280d9092bfaee5c45be5962fabee3d9654" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" }, + "nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" }, + "persistence.nvim": { "branch": "main", "commit": "4b8051c01f696d8849a5cb8afa9767be8db16e40" }, + "plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" }, + "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, + "rust-tools.nvim": { "branch": "master", "commit": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f" }, + "telescope.nvim": { "branch": "master", "commit": "276362a8020c6e94c7a76d49aa00d4923b0c02f3" }, + "todo-comments.nvim": { "branch": "main", "commit": "09b0b17d824d2d56f02ff15967e8a2499a89c731" }, + "toggleterm.nvim": { "branch": "main", "commit": "2249e974faed67e795ffc2ca2be13b93c5d51938" }, + "tokyonight.nvim": { "branch": "main", "commit": "284667adfff02b9a0adc65968c553c6096b543b6" }, + "trouble.nvim": { "branch": "main", "commit": "d99e2abd10808ef91738ce98a5c767e6a51df449" }, + "typescript.nvim": { "branch": "main", "commit": "de304087e6e49981fde01af8ccc5b21e8519306f" }, + "vim-illuminate": { "branch": "master", "commit": "a2907275a6899c570d16e95b9db5fd921c167502" }, + "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "vim-startuptime": { "branch": "master", "commit": "454b3de856b7bd298700de33d79774ca9b9e3875" }, + "vimtex": { "branch": "master", "commit": "bab96ed04dd951b22663b08c670ff33960fc6419" }, + "which-key.nvim": { "branch": "main", "commit": "d871f2b664afd5aed3dc1d1573bef2fb24ce0484" } +} \ No newline at end of file diff --git a/home/apps/nvim/lua/config/autocmds.lua b/home/apps/nvim/lua/config/autocmds.lua new file mode 100644 index 0000000..27e9e06 --- /dev/null +++ b/home/apps/nvim/lua/config/autocmds.lua @@ -0,0 +1,3 @@ +-- Autocmds are automatically loaded on the VeryLazy event +-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua +-- Add any additional autocmds here diff --git a/home/apps/nvim/lua/config/keymaps.lua b/home/apps/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..447dc06 --- /dev/null +++ b/home/apps/nvim/lua/config/keymaps.lua @@ -0,0 +1,52 @@ +-- Keymaps are automatically loaded on the VeryLazy event +-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua +-- Add any additional keymaps here + +local function unmap(mode, key) + vim.keymap.del(mode, key, {}) +end + +unmap("n", "ww") +unmap("n", "w-") +unmap("n", "w|") +unmap("n", "wd") +unmap("n", "l") +unmap("n", "H") +unmap("n", "L") +unmap("i", "") +unmap("i", "") +require("which-key").register({ + ["w"] = "which_key_ignore", +}) + +local function map(mode, lhs, rhs, opts) + local keys = require("lazy.core.handler").handlers.keys + ---@cast keys LazyKeysHandler + -- do not create the keymap if a lazy keys handler exists + if not keys.active[keys.parse({ lhs, mode = mode }).id] then + opts = opts or {} + opts.silent = opts.silent ~= false + if opts.remap and not vim.g.vscode then + opts.remap = nil + end + vim.keymap.set(mode, lhs, rhs, opts) + end +end + +map("n", "0", "0^", { desc = "which_key_ignore " }) +map("n", "", "o", { desc = "which_key_ignore " }) +map("n", "", "zz", { desc = "which_key_ignore " }) +map("n", "", "zz", { desc = "which_key_ignore " }) + +map("n", "w", "w", { desc = "which_key_ignore", nowait = true }) +map("n", "Q", "qa", { desc = "which_key_ignore" }) +map("n", "q", "q", { desc = "which_key_ignore", nowait = true }) + +-- Clipboard +map("n", "y", [["+y]], { desc = "which_key_ignore" }) +map("n", "p", [["+p]], { desc = "which_key_ignore" }) + +map("n", "", "h", { desc = "Go to left window", remap = true }) +map("n", "", "j", { desc = "Go to lower window", remap = true }) +map("n", "", "k", { desc = "Go to upper window", remap = true }) +map("n", "", "l", { desc = "Go to right window", remap = true }) diff --git a/home/apps/nvim/lua/config/lazy.lua b/home/apps/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..59be487 --- /dev/null +++ b/home/apps/nvim/lua/config/lazy.lua @@ -0,0 +1,38 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + -- bootstrap lazy.nvim + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +require("lazy").setup({ + spec = { + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + { import = "lazyvim.plugins.extras.lang.rust" }, + { import = "lazyvim.plugins.extras.util.project" }, + { import = "lazyvim.plugins.extras.dap.core" }, + { import = "lazyvim.plugins.extras.lang.typescript" }, + { import = "lazyvim.plugins.extras.lang.json" }, + { import = "plugins" }, + }, + defaults = { + lazy = false, + -- It's recommended to leave version=false for now, since a lot the plugin that support versioning, + -- have outdated releases, which may break your Neovim install. + version = false, -- always use the latest git commit + }, + install = { colorscheme = { "catppuccin" } }, + checker = { enabled = true }, -- automatically check for plugin updates + performance = { + rtp = { + disabled_plugins = { + "gzip", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/home/apps/nvim/lua/config/options.lua b/home/apps/nvim/lua/config/options.lua new file mode 100644 index 0000000..ad15a10 --- /dev/null +++ b/home/apps/nvim/lua/config/options.lua @@ -0,0 +1,10 @@ +-- Options are automatically loaded before lazy.nvim startup +-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua +-- Add any additional options here + +vim.opt.conceallevel = 0 +vim.opt.clipboard = "" +vim.opt.laststatus = 3 +vim.opt.cmdheight = 0 +vim.opt.updatetime = 100 +vim.opt.list = false diff --git a/home/apps/nvim/lua/plugins/colourscheme.lua b/home/apps/nvim/lua/plugins/colourscheme.lua new file mode 100644 index 0000000..88e4f89 --- /dev/null +++ b/home/apps/nvim/lua/plugins/colourscheme.lua @@ -0,0 +1,25 @@ +return { + { + "catppuccin/nvim", + name = "catppuccin", + opts = { + styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): + comments = { "italic" }, -- Change the style of comments + }, + integrations = { + navic = { + custom_bg = "#181825", + }, + }, + custom_highlights = function(c) + return { + ["@parameter"] = { style = {} }, + ["@conditional"] = { style = {} }, + Conditional = { style = {} }, + ["@namespace"] = { style = {} }, + MiniIndentscopeSymbol = { fg = c.pink }, + } + end, + }, + }, +} diff --git a/home/apps/nvim/lua/plugins/disabled.lua b/home/apps/nvim/lua/plugins/disabled.lua new file mode 100644 index 0000000..ff8355e --- /dev/null +++ b/home/apps/nvim/lua/plugins/disabled.lua @@ -0,0 +1,26 @@ +return { + { + "ggandor/leap.nvim", + enabled = false, + keys = false, + config = function() end, + }, + { + "ggandor/flit.nvim", + enabled = false, + keys = false, + config = function() end, + }, + { + "akinsho/bufferline.nvim", + enabled = false, + keys = false, + config = function() end, + }, + { + "echasnovski/mini.bufremove", + enabled = false, + keys = false, + config = function() end, + }, +} diff --git a/home/apps/nvim/lua/plugins/discord.lua b/home/apps/nvim/lua/plugins/discord.lua new file mode 100644 index 0000000..d8975dd --- /dev/null +++ b/home/apps/nvim/lua/plugins/discord.lua @@ -0,0 +1,8 @@ +return { + { + "andweeb/presence.nvim", + opts = { + neovim_image_text = "Home Sweet Home", + }, + }, +} diff --git a/home/apps/nvim/lua/plugins/editor.lua b/home/apps/nvim/lua/plugins/editor.lua new file mode 100644 index 0000000..431266c --- /dev/null +++ b/home/apps/nvim/lua/plugins/editor.lua @@ -0,0 +1,66 @@ +return { + { + "LazyVim/LazyVim", + opts = { + colorscheme = "catppuccin", + }, + }, + { + "folke/noice.nvim", + opts = { + presets = { + lsp_doc_border = true, + }, + }, + }, + { + "folke/persistence.nvim", + keys = function() + -- stylua: ignore + return { + { "as", function() require("persistence").load() end, desc = "Restore Session", }, + { "al", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session", }, + { "ad", function() require("persistence").stop() end, desc = "Don't Save Current Session", }, + } + end, + }, + { + "nvim-neo-tree/neo-tree.nvim", + opts = { + window = { + mappings = { + ["o"] = "open", + }, + }, + }, + }, + { + "stevearc/dressing.nvim", + opts = { + input = { + insert_only = false, + }, + }, + }, + { + "akinsho/toggleterm.nvim", + config = true, + cmd = "ToggleTerm", + keys = { + { [[]], "ToggleTerm", desc = "Toggle Terminal" }, + }, + opts = { + -- TODO: Add in keymaps for for toggleterm + open_mapping = [["] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + -- You could replace select_next_item() with confirm({ select = true }) to get VS Code autocompletion behavior + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- this way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + 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" }), + }) + end, + }, + { + "simrat39/rust-tools.nvim", + opts = { + tools = { + inlay_hints = { + auto = false, + }, + }, + }, + }, + { + "lervag/vimtex", + }, + { + "echasnovski/mini.surround", + opts = { + mappings = { + add = "gsa", + delete = "gsd", + find = "gsf", + find_left = "gsF", + highlight = "gsh", + replace = "gsr", + update_n_lines = "gsn", + }, + }, + }, +} diff --git a/home/apps/nvim/stylua.toml b/home/apps/nvim/stylua.toml new file mode 100644 index 0000000..5d6c50d --- /dev/null +++ b/home/apps/nvim/stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 2 +column_width = 120 \ No newline at end of file