diff --git a/.gitignore b/.gitignore index 7d7aacf..a0e76af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ .netrwhist -plugin/packer_compiled.lua diff --git a/init.lua b/init.lua index e821617..380eebf 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,23 @@ require("valeth.options") require("valeth.keymaps") -require("valeth.packer") + +local function lazy_setup() + local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + + if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) + end + + vim.opt.rtp:prepend(lazypath) + + require("lazy").setup("valeth.plugins") +end + +lazy_setup() diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..ff48f39 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,41 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "ea7d7ea510c641c4f15042becd27f35b3e5b3c2b" }, + "ayu-nvim": { "branch": "main", "commit": "4418a0c07d45026b05cfd948fd11644d3adb8ac6" }, + "cloak.nvim": { "branch": "main", "commit": "ff5e746e787de14675396beb642bf5010b8bc96d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "crates.nvim": { "branch": "main", "commit": "1dffccc0a95f656ebe00cacb4de282473430c5a1" }, + "formatter.nvim": { "branch": "master", "commit": "44c89f09dcc220dc2a9b056e93c3a87c86e79804" }, + "friendly-snippets": { "branch": "main", "commit": "00e191fea2cfbbdd378243f35b5953296537a116" }, + "gitsigns.nvim": { "branch": "main", "commit": "44adf808ace6cb65a3353bd61fa585a2d8fe0db3" }, + "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, + "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" }, + "lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "f084f4a6a716f55bf9c4026e73027bb24a0325a3" }, + "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, + "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "dfdd771b792fbb4bad8e057d72558255695aa1a7" }, + "mason.nvim": { "branch": "main", "commit": "0942198fb9a998b6ccee36fb8dd7495eb8ba659c" }, + "neogit": { "branch": "master", "commit": "08d23c7ae1e7c3c66802990d5aa16269bdd996a7" }, + "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, + "nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" }, + "nvim-nu": { "branch": "main", "commit": "f45f36a97fb0ea6e39f08cc2fac7a2fb3dc3999b" }, + "nvim-tree.lua": { "branch": "master", "commit": "00741206c2df9c4b538055def19b99790f0c95c8" }, + "nvim-treesitter": { "branch": "master", "commit": "63260da18bf273c76b8e2ea0db84eb901cab49ce" }, + "nvim-treesitter-context": { "branch": "master", "commit": "31692b26d76ff1f7c6e0ab51814dd55e7417e96c" }, + "nvim-treesitter-endwise": { "branch": "master", "commit": "9298b3ac8fd6d0d8f9e321194c6d3fd37e417cf9" }, + "nvim-ufo": { "branch": "main", "commit": "890b94870f052773d77175d07a51f2e083210632" }, + "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, + "overseer.nvim": { "branch": "master", "commit": "d8c5be15ff0f7ccecbaa8f3612a6764b22fc07ff" }, + "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, + "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" }, + "rainbow_csv.nvim": { "branch": "main", "commit": "763994066877cebae2d5159a46f8b423c50f82da" }, + "resession.nvim": { "branch": "master", "commit": "635e83a204b6800ec501a80f867a524a14cfce51" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, + "undotree": { "branch": "main", "commit": "2685ce282702ab0b79c65916f352db2265b245dd" }, + "vim-wakatime": { "branch": "master", "commit": "0d2efa2daff34b27b0d227d4c3b136811c93db93" } +} \ No newline at end of file diff --git a/lua/valeth/packer.lua b/lua/valeth/packer.lua deleted file mode 100644 index 1aef44d..0000000 --- a/lua/valeth/packer.lua +++ /dev/null @@ -1,304 +0,0 @@ -local function install_packer(path) - vim.fn.system({ - "git", "clone", "--depth", "1", - "https://github.com/wbthomason/packer.nvim", - path - }) - - vim.cmd [[packadd packer.nvim]] -end - -local function ensure_packer() - local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" - - if vim.fn.isdirectory(install_path) == 0 then - install_packer(install_path) - return true - end - - return false -end - -local packer_bootstrap = ensure_packer() - - --- Plugins - -local function spec(use) - use "wbthomason/packer.nvim" - - use { - "nvim-treesitter/nvim-treesitter", - requires = { - { "nvim-treesitter/nvim-treesitter-context" } - }, - run = function() - require("valeth.packer.treesitter") - end - } - - use { - "wakatime/vim-wakatime", - cond = function() - return not (os.getenv("WAKATIME_HOME") == nil) - end - } - - -- Currently doesn't seem to have an option to make it off by default easily - use { - "andweeb/presence.nvim", - config = function() - require("valeth.packer.presence") - end - } - - use { - "stevearc/resession.nvim", - config = function() - require("valeth.packer.session") - end - } - - - ---- Language Specific Stuff - - use { - "saecki/crates.nvim", - tag = "v0.3.0", - requires = { - { "nvim-lua/plenary.nvim" }, - { "hrsh7th/nvim-cmp" }, - }, - config = function() - require("valeth.packer.crates") - end - } - - use { - "LhKipp/nvim-nu" - } - - use { - "cameron-wags/rainbow_csv.nvim", - config = function() - require("rainbow_csv").setup() - end - } - - - ---- LSP Stuff - - use { - "VonHeikemen/lsp-zero.nvim", - branch = "v2.x", - requires = { - { "neovim/nvim-lspconfig" }, - -- completion - { "hrsh7th/nvim-cmp" }, - { "hrsh7th/cmp-nvim-lsp" }, - { "hrsh7th/cmp-path" }, - { "onsails/lspkind.nvim" }, - -- formatting - { "mhartington/formatter.nvim" }, - -- snippets - { "saadparwaiz1/cmp_luasnip" }, - { "L3MON4D3/LuaSnip" }, - { "rafamadriz/friendly-snippets" }, - -- lsp manager - { "williamboman/mason.nvim" }, - { "williamboman/mason-lspconfig.nvim" }, - -- code folding - { "kevinhwang91/nvim-ufo" }, - { "kevinhwang91/promise-async" }, - }, - config = function() - require("valeth.packer.lsp") - end - } - - - ---- Just Visual Stuff - - use { - "CantoroMC/ayu-nvim", - config = function() - vim.g.ayu_mirage = true - vim.cmd.colorscheme("ayu") - end - } - - use "nvim-tree/nvim-web-devicons" - - use { - "lewis6991/gitsigns.nvim", - config = function() - require("gitsigns").setup() - end - } - - use { - "nvim-lualine/lualine.nvim", - requires = { - { "nvim-tree/nvim-web-devicons" }, - { "stevearc/overseer.nvim" }, - }, - config = function() - require("valeth.packer.lualine") - end - } - - use { - "lukas-reineke/indent-blankline.nvim", - config = function() - require("indent_blankline").setup { - space_char_blankline = " ", - show_current_context = true, - show_current_context_start = false, - } - end - } - - use { - "laytan/cloak.nvim", - config = function() - require("cloak").setup({ - cloak_length = 5, - patterns = { - { file_pattern = "*.env*", cloak_pattern = "=.+" } - } - }) - end - } - - - ---- Shortcuts - - use { - "numToStr/Comment.nvim", - config = function() - require("Comment").setup() - end - } - - use { - "windwp/nvim-autopairs", - config = function() - local cmp_autopairs = require("nvim-autopairs.completion.cmp") - local cmp = require("cmp") - require("nvim-autopairs").setup() - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) - end - } - - use { - "RRethy/nvim-treesitter-endwise", - requires = { - { "nvim-treesitter/nvim-treesitter" }, - } - } - - use { - "NeogitOrg/neogit", - requires = { - { "nvim-lua/plenary.nvim" }, - }, - config = function () - require("valeth.packer.neogit") - end - } - - - ---- Navigation - - use { - "nvim-telescope/telescope.nvim", - tag = "0.1.1", - requires = { - { "nvim-lua/plenary.nvim" }, - { "nvim-treesitter/nvim-treesitter" }, - }, - config = function() - require("valeth.packer.telescope") - end - } - - use { - "prichrd/netrw.nvim", - disable = true, - config = function() - require("netrw").setup() - end - } - - use { - "ThePrimeagen/harpoon", - requires = { - { "nvim-lua/plenary.nvim" }, - } - } - - use { - "jiaoshijie/undotree", - requires = { - "nvim-lua/plenary.nvim" - }, - config = function() - require("valeth.packer.undotree") - end - } - - use { - "nvim-tree/nvim-tree.lua", - requires = { - { "nvim-tree/nvim-web-devicons" }, - }, - config = function() - require("valeth.packer.nvim-tree") - end - } - - use { - "stevearc/overseer.nvim", - config = function() - require('overseer').setup() - end - } - - if packer_bootstrap then - require("packer").sync() - end -end - - --- Automatically reload packer configuration on write -vim.api.nvim_create_autocmd("BufWritePost", { - group = vim.api.nvim_create_augroup("PackerUserConfig", { clear = true }), - pattern = { "packer.lua", vim.fn.stdpath("config") .. "/lua/valeth/packer/*.lua" }, - callback = function(_) - local source_file = vim.fn.stdpath("config") .. "/lua/valeth/packer.lua" - vim.cmd("source " .. source_file) - require("packer").compile() - end -}) - -return require("packer").startup { - spec, - config = { - display = { - open_fn = function() - return require("packer.util").float({ - border = { - { '╭', 'FloatBorder' }, - { '─', 'FloatBorder' }, - { '╮', 'FloatBorder' }, - { '│', 'FloatBorder' }, - { '╯', 'FloatBorder' }, - { '─', 'FloatBorder' }, - { '╰', 'FloatBorder' }, - { '│', 'FloatBorder' }, - }, - }) - end - } - } -} diff --git a/lua/valeth/packer/crates.lua b/lua/valeth/packer/crates.lua deleted file mode 100644 index d4e19df..0000000 --- a/lua/valeth/packer/crates.lua +++ /dev/null @@ -1,10 +0,0 @@ -require("crates").setup() -local cmp = require("cmp") - -vim.api.nvim_create_autocmd("BufRead", { - group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }), - pattern = "Cargo.toml", - callback = function() - cmp.setup.buffer({ sources = { { name = "crates" } } }) - end, -}) diff --git a/lua/valeth/packer/lsp.lua b/lua/valeth/packer/lsp.lua deleted file mode 100644 index 002db19..0000000 --- a/lua/valeth/packer/lsp.lua +++ /dev/null @@ -1,88 +0,0 @@ -local lsp_zero = require("lsp-zero").preset({}) -local ufo = require("ufo") -local tsb = require("telescope.builtin") - -lsp_zero.ensure_installed { - "lua_ls", - "rust_analyzer", -} - -lsp_zero.on_attach(function(_, buffnr) - local opts = { buffer = buffnr, remap = false } - - ufo.attach(buffnr) - - vim.keymap.set("n", "gd", tsb.lsp_definitions, opts) - vim.keymap.set("n", "gr", tsb.lsp_references, opts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) - vim.keymap.set("n", "ci", vim.diagnostic.open_float, opts) - vim.keymap.set("n", "re", vim.lsp.buf.rename, opts) - vim.keymap.set({ "n", "i" }, "", vim.lsp.buf.signature_help, opts) - - vim.keymap.set("n", "fmt", function() - vim.lsp.buf.format({ async = false, timeout_ms = 5000 }) - end) -end) - - --- NOTE: Format on save does not support async formatting -lsp_zero.format_on_save({ - servers = { - ["rust_analyzer"] = { "rust" } - } -}) - -local lsp_config = require("lspconfig") - -lsp_config.lua_ls.setup(lsp_zero.nvim_lua_ls()) - -lsp_config.rust_analyzer.setup { - settings = { - ["rust-analyzer"] = { - cargo = { - features = "all" - }, - rustfmt = { - -- needs to use nightly channel to use unstable options - extraArgs = { "+nightly" } - } - } - } -} - -ufo.setup { - close_fold_kinds = {"comment", "imports"}, -} - -lsp_zero.setup() - -local cmp = require("cmp") -local lspk = require("lspkind") - -local cmp_select = { behavior = cmp.SelectBehavior.Select } -cmp.setup { - formatting = { - format = lspk.cmp_format({}), - }, - mapping = { - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping.select_prev_item(cmp_select), - [""] = cmp.mapping.select_next_item(cmp_select), - [""] = cmp.mapping.complete(), - [""] = nil, - [""] = nil, - } -} - -vim.diagnostic.config({ - virtual_text = false, -}) - --- Gimme pretty icons -lsp_zero.set_sign_icons({ - error = '✘', - warn = '▲', - hint = '⚑', - info = '»' -}) diff --git a/lua/valeth/packer/lualine.lua b/lua/valeth/packer/lualine.lua deleted file mode 100644 index 0a758a1..0000000 --- a/lua/valeth/packer/lualine.lua +++ /dev/null @@ -1,31 +0,0 @@ -local overseer = require("overseer") - -local task_status = { - "overseer", - colored = true, - symbols = { - [overseer.STATUS.FAILURE] = "✗ ", - [overseer.STATUS.CANCELED] = "o ", - [overseer.STATUS.SUCCESS] = "✓ ", - [overseer.STATUS.RUNNING] = "⟳ ", - }, -} - -require("lualine").setup({ - sections = { - lualine_b = { - "branch", - "diff", - { - "diagnostics", - symbols = { error = "E:", warn = "W:", info = "I:", hint = "H:" } - }, - }, - lualine_x = { - task_status, - "encoding", - { "fileformat", icons_enabled = false }, - "filetype" - } - }, -}) diff --git a/lua/valeth/packer/neogit.lua b/lua/valeth/packer/neogit.lua deleted file mode 100644 index fcf0b88..0000000 --- a/lua/valeth/packer/neogit.lua +++ /dev/null @@ -1,14 +0,0 @@ -local neogit = require("neogit") - -local function git_status() - neogit.open() -end - -local function git_commit() - neogit.open({ "commit" }) -end - -vim.keymap.set("n", "vs", git_status) -vim.keymap.set("n", "vc", git_commit) - -neogit.setup() diff --git a/lua/valeth/packer/nvim-tree.lua b/lua/valeth/packer/nvim-tree.lua deleted file mode 100644 index 58bc32c..0000000 --- a/lua/valeth/packer/nvim-tree.lua +++ /dev/null @@ -1,29 +0,0 @@ -local nvim_tree = require("nvim-tree") -local nvim_tree_api = require("nvim-tree.api") - -vim.keymap.set("n", "ft", nvim_tree_api.tree.open) - -local function kmap_opts(bufnr, desc) - return { - desc = "nvim-tree: " .. desc, - buffer = bufnr, - noremap = true, - silent = true, - nowait = true - } -end - -local function on_attach(bufnr) - nvim_tree_api.config.mappings.default_on_attach(bufnr) - - vim.keymap.set("n", "", nvim_tree_api.tree.close, kmap_opts(bufnr, "Close")) -end - -nvim_tree.setup({ - view = { - float = { - enable = true - } - }, - on_attach = on_attach, -}) diff --git a/lua/valeth/packer/presence.lua b/lua/valeth/packer/presence.lua deleted file mode 100644 index 48cb4df..0000000 --- a/lua/valeth/packer/presence.lua +++ /dev/null @@ -1,43 +0,0 @@ -local presence = require("presence") -local presence_disabled = true - -local presence_augroup = vim.api.nvim_create_augroup("PresenceEvents", { clear = true }) -local presence_autocmds = { - { "FocusGained", "handle_focus_gained" }, - { "TextChanged", "handle_text_changed" }, - { "VimLeavePre", "handle_vim_leave_pre" }, - { "WinEnter", "handle_win_enter" }, - { "WinLeave", "handle_win_leave" }, - { "BufEnter", "handle_buf_enter" }, - { "BufAdd", "handle_buf_add" }, -} -for _, item in ipairs(presence_autocmds) do - local event = item[1] - local callback_fn = item[2] - vim.api.nvim_create_autocmd(event, { - group = presence_augroup, - callback = function() - if not presence_disabled then - presence[callback_fn](presence) - end - end - }) -end - -vim.api.nvim_create_user_command("DiscordToggle", - function() - if presence_disabled then - presence_disabled = false - presence:handle_win_enter() - else - presence_disabled = true - presence:cancel() - end - end, - { nargs = 0 } -) - -presence.setup({ - auto_update = false, - show_time = false, -}) diff --git a/lua/valeth/packer/session.lua b/lua/valeth/packer/session.lua deleted file mode 100644 index 28ab820..0000000 --- a/lua/valeth/packer/session.lua +++ /dev/null @@ -1,34 +0,0 @@ -local resession = require("resession") - -local function session_name() - local working_dir = vim.fn.getcwd() - local git_branch = vim.fn.system("git branch --show-current") - if vim.v.shell_error == 0 then - return working_dir .. git_branch - else - return working_dir - end -end - -local function started_without_args() - return vim.fn.argc(-1) == 0 -end - --- Only restore and save session if NeoVim was started without any arguments -vim.api.nvim_create_autocmd("VimEnter", { - callback = function() - if started_without_args() then - resession.load(session_name(), { dir = "dirsession", silence_errors = true }) - end - end -}) - -vim.api.nvim_create_autocmd("VimLeavePre", { - callback = function() - if started_without_args() then - resession.save(session_name(), { dir = "dirsession", notify = false }) - end - end -}) - -resession.setup() diff --git a/lua/valeth/packer/telescope.lua b/lua/valeth/packer/telescope.lua deleted file mode 100644 index 51c3df4..0000000 --- a/lua/valeth/packer/telescope.lua +++ /dev/null @@ -1,37 +0,0 @@ -local telescope = require("telescope") -local actions = require("telescope.actions") - -telescope.load_extension("harpoon") - -telescope.setup { - defaults = { - initial_mode = "insert" - }, - pickers = { - buffers = { - mappings = { - i = { - [""] = actions.delete_buffer + actions.move_to_top, - }, - n = { - ["dd"] = actions.delete_buffer, - } - } - }, - } -} - -local telescope_builtin = require("telescope.builtin") - -vim.keymap.set("n", "ff", telescope_builtin.find_files) -vim.keymap.set("n", "fb", telescope_builtin.buffers) -vim.keymap.set("n", "fg", telescope_builtin.live_grep) - -local telescope_ext = require("telescope").extensions -local harpoon_mark = require("harpoon.mark") -local harpoon_ui = require("harpoon.ui") - -vim.keymap.set("n", "fh", telescope_ext.harpoon.marks) -vim.keymap.set("n", "am", harpoon_mark.add_file) -vim.keymap.set("n", "gn", harpoon_ui.nav_next) -vim.keymap.set("n", "gp", harpoon_ui.nav_prev) diff --git a/lua/valeth/packer/treesitter.lua b/lua/valeth/packer/treesitter.lua deleted file mode 100644 index 01830b8..0000000 --- a/lua/valeth/packer/treesitter.lua +++ /dev/null @@ -1,16 +0,0 @@ -require("nvim-treesitter.configs").setup { - ensure_installed = { "rust", "lua", "javascript", "typescript" }, - - auto_install = true, - - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - - endwise = { enable = true } -} - -require("treesitter-context").setup() - -require("nvim-treesitter.install").update({ with_sync = true })() diff --git a/lua/valeth/packer/undotree.lua b/lua/valeth/packer/undotree.lua deleted file mode 100644 index 369ccb8..0000000 --- a/lua/valeth/packer/undotree.lua +++ /dev/null @@ -1,5 +0,0 @@ -local undotree = require("undotree") - -vim.keymap.set("n", "u", undotree.toggle, { noremap = true, silent = true }) - -undotree.setup() diff --git a/lua/valeth/plugins/autopairs.lua b/lua/valeth/plugins/autopairs.lua new file mode 100644 index 0000000..564d0e2 --- /dev/null +++ b/lua/valeth/plugins/autopairs.lua @@ -0,0 +1,14 @@ +local spec = { + "windwp/nvim-autopairs", +} + +spec.config = function() + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + + require("nvim-autopairs").setup() + + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) +end + +return spec diff --git a/lua/valeth/plugins/cloak.lua b/lua/valeth/plugins/cloak.lua new file mode 100644 index 0000000..16a38f3 --- /dev/null +++ b/lua/valeth/plugins/cloak.lua @@ -0,0 +1,9 @@ +return { + "laytan/cloak.nvim", + opts = { + cloak_length = 5, + patterns = { + { file_pattern = "*.env*", cloak_pattern = "=.+" } + } + } +} diff --git a/lua/valeth/plugins/crates.lua b/lua/valeth/plugins/crates.lua new file mode 100644 index 0000000..75aa994 --- /dev/null +++ b/lua/valeth/plugins/crates.lua @@ -0,0 +1,25 @@ +local spec = { + "saecki/crates.nvim", + tag = "v0.3.0", +} + +spec.dependencies = { + "nvim-lua/plenary.nvim", + "hrsh7th/nvim-cmp", +} + +spec.config = function() + require("crates").setup() + + local cmp = require("cmp") + + vim.api.nvim_create_autocmd("BufRead", { + group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }), + pattern = "Cargo.toml", + callback = function() + cmp.setup.buffer({ sources = { { name = "crates" } } }) + end, + }) +end + +return spec diff --git a/lua/valeth/plugins/fancy.lua b/lua/valeth/plugins/fancy.lua new file mode 100644 index 0000000..911b630 --- /dev/null +++ b/lua/valeth/plugins/fancy.lua @@ -0,0 +1,21 @@ +return { + { + "CantoroMC/ayu-nvim", + priority = 1000, -- make sure this is loaded first + config = function() + vim.g.ayu_mirage = true + vim.cmd.colorscheme("ayu") + end + }, + + { + "lukas-reineke/indent-blankline.nvim", + opts = { + space_char_blankline = " ", + show_current_context = true, + show_current_context_start = false, + } + }, + + "lewis6991/gitsigns.nvim", +} diff --git a/lua/valeth/plugins/init.lua b/lua/valeth/plugins/init.lua new file mode 100644 index 0000000..ee0080f --- /dev/null +++ b/lua/valeth/plugins/init.lua @@ -0,0 +1,6 @@ +return { + "cameron-wags/rainbow_csv.nvim", + "LhKipp/nvim-nu", + "stevearc/overseer.nvim", + "numToStr/Comment.nvim", +} diff --git a/lua/valeth/plugins/lsp.lua b/lua/valeth/plugins/lsp.lua new file mode 100644 index 0000000..edc625f --- /dev/null +++ b/lua/valeth/plugins/lsp.lua @@ -0,0 +1,118 @@ +local spec = { + "VonHeikemen/lsp-zero.nvim", + branch = "v2.x", +} + +spec.dependencies = { + "neovim/nvim-lspconfig", + -- completion + "hrsh7th/nvim-cmp", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "onsails/lspkind.nvim", + -- formatting + "mhartington/formatter.nvim", + -- snippets + "saadparwaiz1/cmp_luasnip", + "L3MON4D3/LuaSnip", + "rafamadriz/friendly-snippets", + -- lsp manager + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + -- code folding + "kevinhwang91/nvim-ufo", + "kevinhwang91/promise-async", +} + +spec.config = function() + local lsp_zero = require("lsp-zero").preset({}) + local ufo = require("ufo") + local tsb = require("telescope.builtin") + + lsp_zero.ensure_installed { + "lua_ls", + "rust_analyzer", + } + + lsp_zero.on_attach(function(_, buffnr) + local opts = { buffer = buffnr, remap = false } + + ufo.attach(buffnr) + + vim.keymap.set("n", "gd", tsb.lsp_definitions, opts) + vim.keymap.set("n", "gr", tsb.lsp_references, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "ci", vim.diagnostic.open_float, opts) + vim.keymap.set("n", "re", vim.lsp.buf.rename, opts) + vim.keymap.set({ "n", "i" }, "", vim.lsp.buf.signature_help, opts) + + vim.keymap.set("n", "fmt", function() + vim.lsp.buf.format({ async = false, timeout_ms = 5000 }) + end) + end) + + + -- NOTE: Format on save does not support async formatting + lsp_zero.format_on_save({ + servers = { + ["rust_analyzer"] = { "rust" } + } + }) + + local lsp_config = require("lspconfig") + + lsp_config.lua_ls.setup(lsp_zero.nvim_lua_ls()) + + lsp_config.rust_analyzer.setup { + settings = { + ["rust-analyzer"] = { + cargo = { + features = "all" + }, + rustfmt = { + -- needs to use nightly channel to use unstable options + extraArgs = { "+nightly" } + } + } + } + } + + ufo.setup { + close_fold_kinds = {"comment", "imports"}, + } + + lsp_zero.setup() + + local cmp = require("cmp") + local lspk = require("lspkind") + + local cmp_select = { behavior = cmp.SelectBehavior.Select } + cmp.setup { + formatting = { + format = lspk.cmp_format({}), + }, + mapping = { + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.select_prev_item(cmp_select), + [""] = cmp.mapping.select_next_item(cmp_select), + [""] = cmp.mapping.complete(), + [""] = nil, + [""] = nil, + } + } + + vim.diagnostic.config({ + virtual_text = false, + }) + + -- Gimme pretty icons + lsp_zero.set_sign_icons({ + error = '✘', + warn = '▲', + hint = '⚑', + info = '»' + }) +end + +return spec diff --git a/lua/valeth/plugins/lualine.lua b/lua/valeth/plugins/lualine.lua new file mode 100644 index 0000000..88bb5c9 --- /dev/null +++ b/lua/valeth/plugins/lualine.lua @@ -0,0 +1,44 @@ +local spec = { + "nvim-lualine/lualine.nvim", +} + +spec.dependencies = { + "nvim-tree/nvim-web-devicons", + "stevearc/overseer.nvim", +} + +spec.config = function() + local overseer = require("overseer") + + local task_status = { + "overseer", + colored = true, + symbols = { + [overseer.STATUS.FAILURE] = "✗ ", + [overseer.STATUS.CANCELED] = "o ", + [overseer.STATUS.SUCCESS] = "✓ ", + [overseer.STATUS.RUNNING] = "⟳ ", + }, + } + + require("lualine").setup({ + sections = { + lualine_b = { + "branch", + "diff", + { + "diagnostics", + symbols = { error = "E:", warn = "W:", info = "I:", hint = "H:" } + }, + }, + lualine_x = { + task_status, + "encoding", + { "fileformat", icons_enabled = false }, + "filetype" + } + }, + }) +end + +return spec diff --git a/lua/valeth/plugins/neogit.lua b/lua/valeth/plugins/neogit.lua new file mode 100644 index 0000000..990d74a --- /dev/null +++ b/lua/valeth/plugins/neogit.lua @@ -0,0 +1,26 @@ +local spec = { + "NeogitOrg/neogit", +} + +spec.dependencies = { + "nvim-lua/plenary.nvim", +} + +spec.config = function() + local neogit = require("neogit") + + local function git_status() + neogit.open() + end + + local function git_commit() + neogit.open({ "commit" }) + end + + vim.keymap.set("n", "vs", git_status) + vim.keymap.set("n", "vc", git_commit) + + neogit.setup() +end + +return spec diff --git a/lua/valeth/plugins/nvim_tree.lua b/lua/valeth/plugins/nvim_tree.lua new file mode 100644 index 0000000..cb434ed --- /dev/null +++ b/lua/valeth/plugins/nvim_tree.lua @@ -0,0 +1,41 @@ +local spec = { + "nvim-tree/nvim-tree.lua", +} + +spec.dependencies = { + "nvim-tree/nvim-web-devicons" +} + +spec.config = function() + local nvim_tree = require("nvim-tree") + local nvim_tree_api = require("nvim-tree.api") + + vim.keymap.set("n", "ft", nvim_tree_api.tree.open) + + local function kmap_opts(bufnr, desc) + return { + desc = "nvim-tree: " .. desc, + buffer = bufnr, + noremap = true, + silent = true, + nowait = true + } + end + + local function on_attach(bufnr) + nvim_tree_api.config.mappings.default_on_attach(bufnr) + + vim.keymap.set("n", "", nvim_tree_api.tree.close, kmap_opts(bufnr, "Close")) + end + + nvim_tree.setup({ + view = { + float = { + enable = true + } + }, + on_attach = on_attach, + }) +end + +return spec diff --git a/lua/valeth/plugins/presence.lua b/lua/valeth/plugins/presence.lua new file mode 100644 index 0000000..4f637a5 --- /dev/null +++ b/lua/valeth/plugins/presence.lua @@ -0,0 +1,51 @@ +local spec = { + "andweeb/presence.nvim", +} + +spec.config = function() + local presence = require("presence") + local presence_disabled = true + + local presence_augroup = vim.api.nvim_create_augroup("PresenceEvents", { clear = true }) + local presence_autocmds = { + { "FocusGained", "handle_focus_gained" }, + { "TextChanged", "handle_text_changed" }, + { "VimLeavePre", "handle_vim_leave_pre" }, + { "WinEnter", "handle_win_enter" }, + { "WinLeave", "handle_win_leave" }, + { "BufEnter", "handle_buf_enter" }, + { "BufAdd", "handle_buf_add" }, + } + for _, item in ipairs(presence_autocmds) do + local event = item[1] + local callback_fn = item[2] + vim.api.nvim_create_autocmd(event, { + group = presence_augroup, + callback = function() + if not presence_disabled then + presence[callback_fn](presence) + end + end + }) + end + + vim.api.nvim_create_user_command("DiscordToggle", + function() + if presence_disabled then + presence_disabled = false + presence:handle_win_enter() + else + presence_disabled = true + presence:cancel() + end + end, + { nargs = 0 } + ) + + presence.setup({ + auto_update = false, + show_time = false, + }) +end + +return spec diff --git a/lua/valeth/plugins/resession.lua b/lua/valeth/plugins/resession.lua new file mode 100644 index 0000000..9c87b69 --- /dev/null +++ b/lua/valeth/plugins/resession.lua @@ -0,0 +1,42 @@ +local spec = { + "stevearc/resession.nvim", +} + +spec.config = function() + local resession = require("resession") + + local function session_name() + local working_dir = vim.fn.getcwd() + local git_branch = vim.fn.system("git branch --show-current") + if vim.v.shell_error == 0 then + return working_dir .. git_branch + else + return working_dir + end + end + + local function started_without_args() + return vim.fn.argc(-1) == 0 + end + + -- Only restore and save session if NeoVim was started without any arguments + vim.api.nvim_create_autocmd("VimEnter", { + callback = function() + if started_without_args() then + resession.load(session_name(), { dir = "dirsession", silence_errors = true }) + end + end + }) + + vim.api.nvim_create_autocmd("VimLeavePre", { + callback = function() + if started_without_args() then + resession.save(session_name(), { dir = "dirsession", notify = false }) + end + end + }) + + resession.setup() +end + +return spec diff --git a/lua/valeth/plugins/telescope.lua b/lua/valeth/plugins/telescope.lua new file mode 100644 index 0000000..b222a13 --- /dev/null +++ b/lua/valeth/plugins/telescope.lua @@ -0,0 +1,52 @@ +local spec = { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", +} + +spec.dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "ThePrimeagen/harpoon", +} + +spec.config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + + telescope.load_extension("harpoon") + + telescope.setup { + defaults = { + initial_mode = "insert" + }, + pickers = { + buffers = { + mappings = { + i = { + [""] = actions.delete_buffer + actions.move_to_top, + }, + n = { + ["dd"] = actions.delete_buffer, + } + } + }, + } + } + + local telescope_builtin = require("telescope.builtin") + + vim.keymap.set("n", "ff", telescope_builtin.find_files) + vim.keymap.set("n", "fb", telescope_builtin.buffers) + vim.keymap.set("n", "fg", telescope_builtin.live_grep) + + local telescope_ext = require("telescope").extensions + local harpoon_mark = require("harpoon.mark") + local harpoon_ui = require("harpoon.ui") + + vim.keymap.set("n", "fh", telescope_ext.harpoon.marks) + vim.keymap.set("n", "am", harpoon_mark.add_file) + vim.keymap.set("n", "gn", harpoon_ui.nav_next) + vim.keymap.set("n", "gp", harpoon_ui.nav_prev) +end + +return spec diff --git a/lua/valeth/plugins/treesitter.lua b/lua/valeth/plugins/treesitter.lua new file mode 100644 index 0000000..a3cffb1 --- /dev/null +++ b/lua/valeth/plugins/treesitter.lua @@ -0,0 +1,30 @@ +local spec = { + "nvim-treesitter/nvim-treesitter", + tag = "v0.9.1", +} + +spec.dependencies = { + "nvim-treesitter/nvim-treesitter-context", + "RRethy/nvim-treesitter-endwise", +} + +spec.config = function() + require("nvim-treesitter.configs").setup { + ensure_installed = { "rust", "lua", "javascript", "typescript" }, + + auto_install = true, + + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + + endwise = { enable = true } + } + + require("treesitter-context").setup() + + require("nvim-treesitter.install").update({ with_sync = true })() +end + +return spec diff --git a/lua/valeth/plugins/undotree.lua b/lua/valeth/plugins/undotree.lua new file mode 100644 index 0000000..e79ae93 --- /dev/null +++ b/lua/valeth/plugins/undotree.lua @@ -0,0 +1,13 @@ +local spec = { + "jiaoshijie/undotree", +} + +spec.config = function() + local undotree = require("undotree") + + vim.keymap.set("n", "u", undotree.toggle, { noremap = true, silent = true }) + + undotree.setup() +end + +return spec diff --git a/lua/valeth/plugins/wakatime.lua b/lua/valeth/plugins/wakatime.lua new file mode 100644 index 0000000..1f68ae8 --- /dev/null +++ b/lua/valeth/plugins/wakatime.lua @@ -0,0 +1,6 @@ +return { + "wakatime/vim-wakatime", + cond = function() + return not (os.getenv("WAKATIME_HOME") == nil) + end +}