From 866a877889990d59c203a8aa88eb1f3e567963da Mon Sep 17 00:00:00 2001 From: hyper Date: Sun, 6 Oct 2024 13:13:53 +0800 Subject: [PATCH] init --- config/lazy.lua | 35 +++++++++++++++ plugins/editing.lua | 103 ++++++++++++++++++++++++++++++++++++++++++++ plugins/tsdev.lua | 45 +++++++++++++++++++ plugins/visuals.lua | 41 ++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 config/lazy.lua create mode 100644 plugins/editing.lua create mode 100644 plugins/tsdev.lua create mode 100644 plugins/visuals.lua diff --git a/config/lazy.lua b/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/config/lazy.lua @@ -0,0 +1,35 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/plugins/editing.lua b/plugins/editing.lua new file mode 100644 index 0000000..4e086e1 --- /dev/null +++ b/plugins/editing.lua @@ -0,0 +1,103 @@ +return { + { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end + }, + { + 'echasnovski/mini.pairs', + version = '*' , + event = "VeryLazy", + config = function() + require('mini.pairs').setup({}) + end + }, + { 'echasnovski/mini.ai', version = '*' , }, + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + }, + config = function() + vim.keymap.set("n", "e", function() + vim.cmd [[Neotree]] + end, { desc = "Run Neotree" }) + end + }, { + 'MagicDuck/grug-far.nvim', + config = function() + require('grug-far').setup({ + -- options, see Configuration section below + -- there are no required options atm + -- engine = 'ripgrep' is default, but 'astgrep' can be specified + }); + + vim.keymap.set("n", "g", function() + vim.cmd [[GrugFar]] + end, { desc = "Run GrugFar" }) + end + }, { + "folke/flash.nvim", + event = "VeryLazy", + ---@type Flash.Config + opts = {}, + -- stylua: ignore + }, { + 'nvim-telescope/telescope.nvim', tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local builtin = require('telescope.builtin') + local utils = require('telescope.utils') + + vim.keymap.set('n', 'l', builtin.live_grep, { desc = 'Telescope live grep' }) + vim.keymap.set('n', 'b', builtin.buffers, { desc = 'Telescope buffers' }) + vim.keymap.set('n', 'h', builtin.help_tags, { desc = 'Telescope help tags' }) + vim.keymap.set('n', 't', function() + vim.cmd [[TodoTelescope]] + end, { desc = 'Telescope Todo' }) + + vim.keymap.set('n', 'cd', builtin.diagnostics, { desc = 'Telescope diagnostics' }) + vim.keymap.set('n', 'cr', builtin.lsp_references, { desc = 'Telescope lsp references' }) + vim.keymap.set('n', 'cs', builtin.treesitter, { desc = 'Telescope treesitter' }) + + vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) + vim.keymap.set('n', 'fb', function() + builtin.find_files({ cwd = utils.buffer_dir() }) + end, { desc = 'Telescope find in buffer dir' }) + + vim.keymap.set('n', 'fs', function() + vim.cmd [[w]] + end, { desc = 'Save' }) + + vim.keymap.set('n', 'fq', function() + vim.cmd [[q]] + end, { desc = 'Close' }) + + vim.keymap.set('n', 'fQ', function() + vim.cmd [[q!]] + end, { desc = 'Force close' }) + + vim.keymap.set('n', 'fd', function() + vim.cmd [[wq]] + end, { desc = 'Save and close' }) + end + }, { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + }, { + "aznhe21/actions-preview.nvim", + config = function() + vim.keymap.set({ "v", "n" }, "ca", require("actions-preview").code_actions, { desc = "Telescope code actions"}) + end, + } +} diff --git a/plugins/tsdev.lua b/plugins/tsdev.lua new file mode 100644 index 0000000..4801e50 --- /dev/null +++ b/plugins/tsdev.lua @@ -0,0 +1,45 @@ +return { + { + "pmizio/typescript-tools.nvim", + dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, + opts = {}, + config = function() + require('typescript-tools').setup({}) + end + },{ + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + }, + config = function() + require('cmp').setup({ + completion = { + keyword_length = 1, + max_item_count = 6 + }, + sources = { + { name = "nvim_lsp", keyword_length = 1, max_item_count = 6 }, + { name = "buffer", keyword_length = 1, max_item_count = 6 }, + { name = "path", keyword_length = 1, max_item_count = 6 }, + } + }) + end + },{ + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function () + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { "tsx", "typescript", "javascript", "html" }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end + } +} + diff --git a/plugins/visuals.lua b/plugins/visuals.lua new file mode 100644 index 0000000..a5a5175 --- /dev/null +++ b/plugins/visuals.lua @@ -0,0 +1,41 @@ +return { + { + "ellisonleao/gruvbox.nvim", + config = function() + vim.cmd([[colorscheme gruvbox]]) + end + }, + { + 'akinsho/bufferline.nvim', + version = "*", + dependencies = 'nvim-tree/nvim-web-devicons', + event = "VeryLazy", + config = function() + require("bufferline").setup() + end + },{ + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + event = "VeryLazy", + config = function() + require("lualine").setup() + end + }, { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require('todo-comments').setup({}) + + vim.keymap.set("n", "]t", function() + require("todo-comments").jump_next() + end, { desc = "Next todo comment" }) + + vim.keymap.set("n", "[t", function() + require("todo-comments").jump_prev() + end, { desc = "Previous todo comment" }) + end + },{ + "folke/which-key.nvim", + event = "VeryLazy", + } +}